<?php
-
/*
+--------------------------------------------------------------------+
-| CiviCRM version 4.5 |
+| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
*/
require_once 'CiviTest/CiviUnitTestCase.php';
+
+/**
+ * Class api_v3_PriceFieldValueTest
+ */
class api_v3_PriceFieldValueTest extends CiviUnitTestCase {
protected $_apiversion = 3;
protected $_params;
'is_reserved' => 1,
);
- $price_set = $this->callAPISuccess('price_set', 'create',$priceSetparams);
+ $price_set = $this->callAPISuccess('price_set', 'create', $priceSetparams);
$this->priceSetID = $price_set['id'];
$priceFieldparams = array(
'is_enter_qty' => 1,
'is_active' => 1,
);
- $priceField = $this->callAPISuccess('price_field','create', $priceFieldparams);
+ $priceField = $this->callAPISuccess('price_field', 'create', $priceFieldparams);
$this->priceFieldID = $priceField['id'];
$this->_params = array(
'price_field_id' => $this->priceFieldID,
'name' => 'ryegrass',
'label' => 'juicy and healthy',
- 'amount' => 1
- );
+ 'amount' => 1,
+ );
$membershipOrgId = $this->organizationCreate(NULL);
$this->_membershipTypeID = $this->membershipTypeCreate(array('member_of_contact_id' => $membershipOrgId));
'is_quick_config' => 1,
'is_reserved' => 1,
);
- $price_set1 = $this->callAPISuccess('price_set', 'create',$priceSetparams1);
+ $price_set1 = $this->callAPISuccess('price_set', 'create', $priceSetparams1);
$this->priceSetID1 = $price_set1['id'];
$priceFieldparams1 = array(
'price_set_id' => $this->priceSetID1,
'is_enter_qty' => 1,
'is_active' => 1,
);
- $priceField1 = $this->callAPISuccess('price_field','create', $priceFieldparams1);
+ $priceField1 = $this->callAPISuccess('price_field', 'create', $priceFieldparams1);
$this->priceFieldID1 = $priceField1['id'];
}
- function tearDown() {
+ public function tearDown() {
$tablesToTruncate = array(
- 'civicrm_contact',
- 'civicrm_contribution',
+ 'civicrm_contact',
+ 'civicrm_contribution',
);
$this->quickCleanup($tablesToTruncate);
$this->membershipTypeDelete(array('id' => $this->_membershipTypeID));
- $this->callAPISuccess('PriceField','delete', array(
- 'id' => $this->priceFieldID1,
+ $this->callAPISuccess('PriceField', 'delete', array(
+ 'id' => $this->priceFieldID1,
));
- $this->callAPISuccess('PriceSet','delete', array(
+ $this->callAPISuccess('PriceSet', 'delete', array(
'id' => $this->priceSetID1,
));
- $this->callAPISuccess('PriceField','delete', array(
- 'id' => $this->priceFieldID,
+ $this->callAPISuccess('PriceField', 'delete', array(
+ 'id' => $this->priceFieldID,
));
- $delete = $this->callAPISuccess('PriceSet','delete', array(
+ $delete = $this->callAPISuccess('PriceSet', 'delete', array(
'id' => $this->priceSetID,
));
);
$getResult = $this->callAPIAndDocument($this->_entity, 'get', $getParams, __FUNCTION__, __FILE__);
$this->assertEquals(1, $getResult['count'], 'In line ' . __LINE__);
- $this->callAPISuccess('price_field_value','delete', array('id' => $createResult['id']));
+ $this->callAPISuccess('price_field_value', 'delete', array('id' => $createResult['id']));
}
public function testDeletePriceFieldValue() {
public function testCreatePriceFieldValuewithMultipleTerms() {
$params = array(
'price_field_id' => $this->priceFieldID1,
- 'membership_type_id' => $this->_membershipTypeID,
+ 'membership_type_id' => $this->_membershipTypeID,
'name' => 'memType1',
'label' => 'memType1',
'amount' => 90,
'membership_num_terms' => 2,
'is_active' => 1,
'financial_type_id' => 2,
- );
+ );
$result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__);
$this->assertEquals($result['values'][$result['id']]['membership_num_terms'], 2);
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
$this->callAPISuccess($this->_entity, 'delete', array('id' => $result['id']));
}
+
public function testGetPriceFieldValuewithMultipleTerms() {
$params1 = array(
'price_field_id' => $this->priceFieldID1,
- 'membership_type_id' => $this->_membershipTypeID,
+ 'membership_type_id' => $this->_membershipTypeID,
'name' => 'memType1',
'label' => 'memType1',
'amount' => 90,
'membership_num_terms' => 2,
'is_active' => 1,
'financial_type_id' => 2,
- );
+ );
$params2 = array(
'price_field_id' => $this->priceFieldID1,
- 'membership_type_id' => $this->_membershipTypeID,
+ 'membership_type_id' => $this->_membershipTypeID,
'name' => 'memType2',
'label' => 'memType2',
'amount' => 120,
'membership_num_terms' => 3,
'is_active' => 1,
'financial_type_id' => 2,
- );
+ );
$result1 = $this->callAPISuccess($this->_entity, 'create', $params1);
$result2 = $this->callAPISuccess($this->_entity, 'create', $params2);
- $result = $this->callAPISuccess($this->_entity, 'get', array('price_field_id' =>$this->priceFieldID1 ));
+ $result = $this->callAPISuccess($this->_entity, 'get', array('price_field_id' => $this->priceFieldID1));
$this->assertEquals(2, $result['count'], 'In line ' . __LINE__);
- $this->callAPISuccess($this->_entity,'delete', array('id' => $result1['id']));
- $this->callAPISuccess($this->_entity,'delete', array('id' => $result2['id']));
+ $this->callAPISuccess($this->_entity, 'delete', array('id' => $result1['id']));
+ $this->callAPISuccess($this->_entity, 'delete', array('id' => $result2['id']));
}
}
-