3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 require_once 'CiviTest/CiviUnitTestCase.php';
34 * Test class for UFGroup API - civicrm_uf_*
35 * @todo Split UFGroup and UFJoin tests
39 class api_v3_UFMatchTest
extends CiviUnitTestCase
{
40 // ids from the uf_group_test.xml fixture
41 protected $_ufGroupId = 11;
42 protected $_ufFieldId;
43 protected $_contactId;
44 protected $_apiversion;
45 protected $_params = array();
49 protected function setUp() {
51 $this->_apiversion
= 3;
61 $this->_contactId
= $this->individualCreate();
62 $op = new PHPUnit_Extensions_Database_Operation_Insert
;
65 new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet(dirname(__FILE__
) . '/dataset/uf_group_test.xml')
68 $this->_params
= array(
69 'contact_id' => $this->_contactId
,
71 'uf_name' => 'blahdyblah@gmail.com',
77 // Truncate the tables
90 * fetch contact id by uf id
92 public function testGetUFMatchID() {
96 $result = $this->callAPISuccess('uf_match', 'get', $params);
97 $this->assertEquals($result['values'][$result['id']]['contact_id'], 69);
100 function testGetUFMatchIDWrongParam() {
101 $params = 'a string';
102 $result = $this->callAPIFailure('uf_match', 'get', $params);
106 * fetch uf id by contact id
108 public function testGetUFID() {
112 $result = $this->callAPIAndDocument('uf_match', 'get', $params, __FUNCTION__
, __FILE__
);
113 $this->assertEquals($result['values'][$result['id']]['uf_id'], 42);
116 function testGetUFIDWrongParam() {
117 $params = 'a string';
118 $result = $this->callAPIFailure('uf_match', 'get', $params);
122 * Test civicrm_activity_create() using example code
124 function testUFMatchGetExample() {
125 require_once 'api/v3/examples/UFMatch/Get.php';
126 $result = UF_match_get_example();
127 $expectedResult = UF_match_get_expectedresult();
128 $this->assertEquals($result, $expectedResult);
131 function testCreate() {
132 $result = $this->callAPISuccess('uf_match', 'create', $this->_params
);
133 $this->getAndCheck($this->_params
, $result['id'], 'uf_match');
136 function testDelete() {
137 $result = $this->callAPISuccess('uf_match', 'create', $this->_params
);
138 $this->assertEquals(1, $this->callAPISuccess('uf_match', 'getcount', array( 'id' => $result['id'],
140 $this->callAPISuccess('uf_match', 'delete', array( 'id' => $result['id'],
142 $this->assertEquals(0, $this->callAPISuccess('uf_match', 'getcount', array('id' => $result['id'],