From: Eileen McNaughton Date: Mon, 20 Jan 2014 10:44:46 +0000 (+1300) Subject: fix failing test, check contribution creating with default date of now X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d5d148ab08ad49dab36ed055a963bb784e006909;p=civicrm-core.git fix failing test, check contribution creating with default date of now --- diff --git a/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php b/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php index 2169552b6c..617753d5dd 100644 --- a/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php @@ -469,6 +469,13 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $dao = new CRM_Core_DAO(); $contribution_page = $dao->createTestObject('CRM_Contribute_DAO_ContributionPage'); $contribution->contribution_page_id = $contributionPageID = $contribution_page->id; + //for unknown reasons trying to do a find & save on a contribution with a receive_date set + // doesn't work. This seems of minimal relevance to this test so ignoring + // note that in tests it worked sometimes & not others - dependent on which other tests run. + // running all CRM_Core tests caused failure as did just the single failing test. But running + // just this class succeeds - because it actually doesn't do a mysql update on the following save + // (unknown reason) + unset($contribution->receive_date); $contribution->save(); } diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 6e55739313..c05465c931 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -513,6 +513,20 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00, 'In line ' . __LINE__); $this->assertEquals($contribution['values'][$contribution['id']]['source'], 'SSF', 'In line ' . __LINE__); } + + /* + * Create test with unique field name on source + */ + function testCreateDefaultNow() { + + $params = $this->_params; + unset($params['receive_date']); + + $contribution = $this->callAPISuccess('contribution', 'create', $params); + $contribution = $this->callAPISuccessGetSingle('contribution', array('id' => $contribution['id'])); + $this->assertEquals(date('Y-m-d'), date('Y-m-d', strtotime($contribution['receive_date']))); + } + /* * Create test with unique field name on source */