X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fapi%2Fv3%2FPriceFieldTest.php;h=65d47a0bb89538e796186304261e63f1c47761d8;hb=b94eea5170f9b25e817067941198129b5de3224c;hp=32d64b96233f321a8fb6dd7a39d3c79ef51ba894;hpb=47d11b6d6765bc80ed2fea7ddd4cc012df508e9d;p=civicrm-core.git diff --git a/tests/phpunit/api/v3/PriceFieldTest.php b/tests/phpunit/api/v3/PriceFieldTest.php index 32d64b9623..65d47a0bb8 100644 --- a/tests/phpunit/api/v3/PriceFieldTest.php +++ b/tests/phpunit/api/v3/PriceFieldTest.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ -| Copyright CiviCRM LLC (c) 2004-2017 | +| Copyright CiviCRM LLC (c) 2004-2018 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -115,4 +115,44 @@ class api_v3_PriceFieldTest extends CiviUnitTestCase { $this->assertEquals(1, $result['values']['options_per_line']['type']); } + /** + * CRM-19741 + * Test updating the label of a texte price field and ensure price field value label is also updated + */ + public function testUpdatePriceFieldLabel() { + $field = $this->callAPISuccess($this->_entity, 'create', $this->_params); + $this->callAPISuccess('price_field_value', 'create', array( + 'price_field_id' => $field['id'], + 'name' => 'rye grass', + 'label' => 'juicy and healthy', + 'amount' => 1, + 'financial_type_id' => 1, + )); + $priceField = $this->callAPISuccess($this->_entity, 'create', array('id' => $field['id'], 'label' => 'Rose Variety')); + $priceFieldValue = $this->callAPISuccess('price_field_value', 'get', array('price_field_id' => $field['id'])); + $this->assertEquals($priceField['values'][$priceField['id']]['label'], $priceFieldValue['values'][$priceFieldValue['id']]['label']); + $this->callAPISuccess('price_field_value', 'delete', array('id' => $priceFieldValue['id'])); + $this->callAPISuccess($this->_entity, 'delete', array('id' => $field['id'])); + } + + /** + * CRM-19741 + * Confirm value label only updates if fiedl type is html. + */ + public function testUpdatePriceFieldLabelNotUpdateField() { + $field = $this->callAPISuccess($this->_entity, 'create', array_merge($this->_params, array('html_type' => 'Radio'))); + $this->callAPISuccess('price_field_value', 'create', array( + 'price_field_id' => $field['id'], + 'name' => 'rye grass', + 'label' => 'juicy and healthy', + 'amount' => 1, + 'financial_type_id' => 1, + )); + $priceField = $this->callAPISuccess($this->_entity, 'create', array('id' => $field['id'], 'label' => 'Rose Variety')); + $priceFieldValue = $this->callAPISuccess('price_field_value', 'get', array('price_field_id' => $field['id'])); + $this->assertEquals('juicy and healthy', $priceFieldValue['values'][$priceFieldValue['id']]['label']); + $this->callAPISuccess('price_field_value', 'delete', array('id' => $priceFieldValue['id'])); + $this->callAPISuccess($this->_entity, 'delete', array('id' => $field['id'])); + } + }