_apiversion = 3; $this->quickCleanup( array( 'civicrm_group', 'civicrm_contact', 'civicrm_uf_group', 'civicrm_uf_join', 'civicrm_uf_match', ) ); $this->_contactId = $this->individualCreate(); $op = new PHPUnit_Extensions_Database_Operation_Insert(); $op->execute( $this->_dbconn, $this->createFlatXMLDataSet(dirname(__FILE__) . '/dataset/uf_group_test.xml') ); $this->_params = array( 'contact_id' => $this->_contactId, 'uf_id' => '2', 'uf_name' => 'blahdyblah@gmail.com', 'domain_id' => 1, ); } public function tearDown() { // Truncate the tables $this->quickCleanup( array( 'civicrm_group', 'civicrm_contact', 'civicrm_uf_group', 'civicrm_uf_join', 'civicrm_uf_match', ) ); } /** * Fetch contact id by uf id */ public function testGetUFMatchID() { $params = array( 'uf_id' => 42, ); $result = $this->callAPISuccess('uf_match', 'get', $params); $this->assertEquals($result['values'][$result['id']]['contact_id'], 69); } public function testGetUFMatchIDWrongParam() { $params = 'a string'; $result = $this->callAPIFailure('uf_match', 'get', $params); } /** * Fetch uf id by contact id */ public function testGetUFID() { $params = array( 'contact_id' => 69, ); $result = $this->callAPIAndDocument('uf_match', 'get', $params, __FUNCTION__, __FILE__); $this->assertEquals($result['values'][$result['id']]['uf_id'], 42); } public function testGetUFIDWrongParam() { $params = 'a string'; $result = $this->callAPIFailure('uf_match', 'get', $params); } /** * Test civicrm_activity_create() using example code */ public function testUFMatchGetExample() { require_once 'api/v3/examples/UFMatch/Get.php'; $result = UF_match_get_example(); $expectedResult = UF_match_get_expectedresult(); $this->assertEquals($result, $expectedResult); } public function testCreate() { $result = $this->callAPISuccess('uf_match', 'create', $this->_params); $this->getAndCheck($this->_params, $result['id'], 'uf_match'); } public function testDelete() { $result = $this->callAPISuccess('uf_match', 'create', $this->_params); $this->assertEquals(1, $this->callAPISuccess('uf_match', 'getcount', array( 'id' => $result['id'], ))); $this->callAPISuccess('uf_match', 'delete', array( 'id' => $result['id'], )); $this->assertEquals(0, $this->callAPISuccess('uf_match', 'getcount', array( 'id' => $result['id'], ))); } }