From: Tim Otten Date: Tue, 1 Oct 2013 21:49:30 +0000 (+0200) Subject: CRM-13312 - CRM_Utils_API_MatchOptionTest X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d0d21f467825c35d10fe123673582a8b08c59111;p=civicrm-core.git CRM-13312 - CRM_Utils_API_MatchOptionTest Make sure that the "noise" records are not touched by other operations. Clean up noise. See http://forum.civicrm.org/index.php/topic,30133.0.html ---------------------------------------- * CRM-13312: Implement API support for options.match http://issues.civicrm.org/jira/browse/CRM-13312 --- diff --git a/tests/phpunit/CRM/Utils/API/MatchOptionTest.php b/tests/phpunit/CRM/Utils/API/MatchOptionTest.php index 1f0ef717fc..089bb87558 100644 --- a/tests/phpunit/CRM/Utils/API/MatchOptionTest.php +++ b/tests/phpunit/CRM/Utils/API/MatchOptionTest.php @@ -6,12 +6,45 @@ require_once 'CiviTest/CiviUnitTestCase.php'; */ class CRM_Utils_API_MatchOptionTest extends CiviUnitTestCase { + /** + * @var array + */ + var $noise; + function setUp() { parent::setUp(); $this->assertDBQuery(0, "SELECT count(*) FROM civicrm_contact WHERE first_name='Jeffrey' and last_name='Lebowski'"); // Create noise to ensure we don't accidentally/coincidentally match the first record - $this->individualCreate(array('email' => 'ignore1@example.com')); + $this->noise['individual'] = $this->individualCreate(array( + 'email' => 'ignore1@example.com', + // 'street_address-1' => 'Irrelevant' + 'api.Address.create' => array( + 'location_type_id' => 1, + 'street_address' => '123 Irrelevant Str', + 'supplemental_address_1' => 'Room 987', + ), + )); + } + + function tearDown() { + $noise = $this->callAPISuccess('Contact', 'get', array( + 'id' => $this->noise['individual'], + 'return' => array('email'), + 'api.Address.get' => 1, + )); + $this->assertEquals(1, count($noise['values'])); + foreach ($noise['values'] as $value) { + $this->assertEquals('ignore1@example.com', $value['email']); + $this->assertEquals(1, count($value['api.Address.get']['values'])); + } + CRM_core_DAO::executeQuery('DELETE FROM civicrm_address WHERE contact_id=%1', array( + 1 => array($this->noise['individual'], 'Positive') + )); + $this->callAPISuccess('Contact', 'delete', array( + 'id' => $this->noise['individual'], + )); + parent::tearDown(); } /**