5 +--------------------------------------------------------------------+
6 | CiviCRM version 4.3 |
7 +--------------------------------------------------------------------+
8 | Copyright CiviCRM LLC (c) 2004-2013 |
9 +--------------------------------------------------------------------+
10 | This file is a part of CiviCRM. |
12 | CiviCRM is free software; you can copy, modify, and distribute it |
13 | under the terms of the GNU Affero General Public License |
14 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
16 | CiviCRM is distributed in the hope that it will be useful, but |
17 | WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
19 | See the GNU Affero General Public License for more details. |
21 | You should have received a copy of the GNU Affero General Public |
22 | License and the CiviCRM Licensing Exception along |
23 | with this program; if not, contact CiviCRM LLC |
24 | at info[AT]civicrm[DOT]org. If you have questions about the |
25 | GNU Affero General Public License or the licensing of CiviCRM, |
26 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
27 +--------------------------------------------------------------------+
33 require_once 'CiviTest/CiviUnitTestCase.php';
36 * Test class for UFGroup API - civicrm_uf_*
37 * @todo Split UFGroup and UFJoin tests
41 class api_v3_UFMatchTest
extends CiviUnitTestCase
{
42 // ids from the uf_group_test.xml fixture
43 protected $_ufGroupId = 11;
44 protected $_ufFieldId;
45 protected $_contactId;
46 protected $_apiversion;
47 protected $_params = array();
49 public $_eNoticeCompliant = TRUE;
51 protected function setUp() {
53 $this->_apiversion
= 3;
63 $this->_contactId
= $this->individualCreate();
64 $op = new PHPUnit_Extensions_Database_Operation_Insert
;
67 new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet(dirname(__FILE__
) . '/dataset/uf_group_test.xml')
70 $this->_params
= array(
71 'contact_id' => $this->_contactId
,
73 'uf_name' => 'blahdyblah@gmail.com',
80 // Truncate the tables
93 * fetch contact id by uf id
95 public function testGetUFMatchID() {
98 'version' => $this->_apiversion
,
100 $result = civicrm_api('uf_match', 'get', $params);
101 $this->assertEquals($result['values'][$result['id']]['contact_id'], 69);
102 $this->assertAPISuccess($result);
105 function testGetUFMatchIDWrongParam() {
106 $params = 'a string';
107 $result = civicrm_api('uf_match', 'get', $params);
108 $this->assertEquals($result['is_error'], 1);
112 * fetch uf id by contact id
114 public function testGetUFID() {
117 'version' => $this->_apiversion
,
119 $result = civicrm_api('uf_match', 'get', $params);
120 $this->documentMe($params, $result, __FUNCTION__
, __FILE__
);
121 $this->assertEquals($result['values'][$result['id']]['uf_id'], 42);
122 $this->assertAPISuccess($result);
125 function testGetUFIDWrongParam() {
126 $params = 'a string';
127 $result = civicrm_api('uf_match', 'get', $params);
128 $this->assertEquals($result['is_error'], 1);
132 * Test civicrm_activity_create() using example code
134 function testUFMatchGetExample() {
135 require_once 'api/v3/examples/UFMatchGet.php';
136 $result = UF_match_get_example();
137 $expectedResult = UF_match_get_expectedresult();
138 $this->assertEquals($result, $expectedResult);
141 function testCreate() {
142 $result = civicrm_api('uf_match', 'create', $this->_params
);
143 $this->assertAPISuccess($result);
144 $this->getAndCheck($this->_params
, $result['id'], 'uf_match');
147 function testDelete() {
148 $result = civicrm_api('uf_match', 'create', $this->_params
);
149 $this->assertEquals(1, civicrm_api('uf_match', 'getcount', array(
150 'version' => $this->_apiversion
,
151 'id' => $result['id'],
153 civicrm_api('uf_match', 'delete', array(
154 'version' => $this->_apiversion
,
155 'id' => $result['id'],
157 $this->assertEquals(0, civicrm_api('uf_match', 'getcount', array(
158 'version' => $this->_apiversion
,
159 'id' => $result['id'],