Skip to content
Snippets Groups Projects
Commit d0d21f46 authored by totten's avatar totten
Browse files

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
parent 69ce6f4d
No related branches found
No related tags found
No related merge requests found
......@@ -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();
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment