From: Tim Otten Date: Thu, 1 Aug 2013 22:41:01 +0000 (-0700) Subject: CRM-13120 - Reproduce 'null' problem with a core API X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=76fa28f189144947a6de7d974b5c23c2b7f33ff6;p=civicrm-core.git CRM-13120 - Reproduce 'null' problem with a core API ---------------------------------------- * CRM-13120: http://issues.civicrm.org/jira/browse/CRM-13120 --- diff --git a/CRM/Contribute/BAO/ContributionPage.php b/CRM/Contribute/BAO/ContributionPage.php index 51a9eacef3..d0b4029704 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -49,7 +49,7 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio */ public static function &create(&$params) { $financialTypeId = NULL; - if (CRM_Utils_Array::value('id', $params) && !CRM_Price_BAO_Set::getFor('civicrm_contribution_page', $params['id'], NULL, 1)) { + if (CRM_Utils_Array::value('id', $params) && !CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $params['id'], NULL, 1)) { $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $params['id'], 'financial_type_id'); } $dao = new CRM_Contribute_DAO_ContributionPage(); diff --git a/tests/phpunit/api/v3/APITest.php b/tests/phpunit/api/v3/APITest.php index 05eda06641..826bd4ecbc 100644 --- a/tests/phpunit/api/v3/APITest.php +++ b/tests/phpunit/api/v3/APITest.php @@ -182,5 +182,37 @@ class api_v3_APITest extends CiviUnitTestCase { $this->fail('Exception was expected'); } + public function testCreate_NoStringNullResult() { + // create an example contact + // $contact = CRM_Core_DAO::createTestObject('CRM_Contribute_DAO_ContributionPage')->toArray(); + $result = $this->callAPISuccess('ContributionPage', 'create', array( + 'title' => "Test Contribution Page", + 'financial_type_id' => 1, + 'currency' => 'USD', + 'goal_amount' => 100, + )); + $contact = array_shift($result['values']); + + $this->assertTrue(is_numeric($contact['id'])); + $this->assertNotEmpty($contact['title']); + // preferred_mail_format preferred_communication_method preferred_language gender_id + // currency + $this->assertNotEmpty($contact['currency']); + + // update the contact + $result = $this->callAPISuccess('ContributionPage', 'create', array( + 'id' => $contact['id'], + 'title' => 'New title', + 'currency' => '', + )); + + // check return format + $this->assertEquals(1, $result['count']); + foreach ($result['values'] as $resultValue) { + $this->assertEquals('New title', $resultValue['title']); + $this->assertEquals('', $resultValue['currency']); // BUG: $resultValue['location'] === 'null' + } + } + }