*/
class CRM_Price_BAO_PriceFieldTest extends CiviUnitTestCase {
- /**
- * Sets up the fixtures.
- */
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Tears down the fixture.
- */
- protected function tearDown() {
- }
-
/**
* Test that when re-submitting the price field values with the option ids added
* in the format that the contribution page / event page configuration screen
* does it it doesn't duplicate the options
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitPriceFieldWithOptions() {
- $this->priceSet = civicrm_api3('PriceSet', 'create', [
+ $priceSet = $this->callAPISuccess('PriceSet', 'create', [
'is_active' => 1,
'extends' => 2,
'is_quick_config' => 1,
'name' => 'test_price_set',
'title' => 'Test Price Set',
]);
- $this->priceFieldParams = [
+ $priceFieldParams = [
'name' => 'contribution_amount',
'is_active' => 1,
'weight' => 2,
3 => 3,
],
'default_option' => 2,
- 'price_set_id' => $this->priceSet['id'],
+ 'price_set_id' => $priceSet['id'],
];
- $this->priceField = civicrm_api3('PriceField', 'create', $this->priceFieldParams);
- $this->priceFieldParams['id'] = $this->priceField['id'];
- $fieldOptions = civicrm_api3('PriceFieldValue', 'get', ['price_field_id' => $this->priceField['id']]);
+ $priceField = $this->callAPISuccess('PriceField', 'create', $priceFieldParams);
+ $priceFieldParams['id'] = $priceField['id'];
+ $fieldOptions = $this->callAPISuccess('PriceFieldValue', 'get', ['price_field_id' => $priceField['id']]);
foreach ($fieldOptions['values'] as $fieldOption) {
if ($fieldOption['amount'] < 20) {
$key = 1;
else {
$key = 3;
}
- $this->priceFieldParams['option_id'][$key] = $fieldOption['id'];
+ $priceFieldParams['option_id'][$key] = $fieldOption['id'];
}
- $this->priceFieldParams['default_option'] = 3;
- $options = $this->callAPISuccess('PriceFieldValue', 'get', ['price_field_id' => $this->priceField['id']]);
+ $priceFieldParams['default_option'] = 3;
+ $options = $this->callAPISuccess('PriceFieldValue', 'get', ['price_field_id' => $priceField['id']]);
$this->assertEquals(3, $options['count']);
}
+ /**
+ * Test the name can be retrieved from the id using the pseudoConstant.
+ */
+ public function testGetFromPseudoConstant() {
+ $this->assertNotEmpty(CRM_Core_PseudoConstant::getKey('CRM_Price_BAO_PriceField', 'price_set_id', 'default_contribution_amount'));
+ }
+
}
*
* (these are denoted as 'quickConfig' in the code - but quickConfig is only supposed to refer to the
* configuration interface - there should be no different post process.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testGetAmountLevelTextAmount() {
$priceSetID = $this->eventPriceSetCreate(9);
/**
* CRM-20237 Test that Copied price set does not generate long name and unneded information
+ *
+ * @throws \CRM_Core_Exception
*/
public function testCopyPriceSet() {
$priceSetID = $this->eventPriceSetCreate(9);
/**
* Test CRM_Price_BAO_PriceSet::getMembershipCount() that return correct number of
* membership type occurances against it's corresponding member orgaisation
+ *
+ * @throws \CRM_Core_Exception
*/
public function testGetMembershipCount() {
// create two organisations