4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.3 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2013 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
32 require_once 'CiviTest/CiviUnitTestCase.php';
35 * Test class for UFGroup API - civicrm_uf_*
36 * @todo Split UFGroup and UFJoin tests
40 class api_v3_UFMatchTest
extends CiviUnitTestCase
{
41 // ids from the uf_group_test.xml fixture
42 protected $_ufGroupId = 11;
43 protected $_ufFieldId;
44 protected $_contactId;
45 protected $_apiversion;
46 protected $_params = array();
48 public $_eNoticeCompliant = TRUE;
50 protected function setUp() {
52 $this->_apiversion
= 3;
62 $this->_contactId
= $this->individualCreate();
63 $op = new PHPUnit_Extensions_Database_Operation_Insert
;
66 new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet(dirname(__FILE__
) . '/dataset/uf_group_test.xml')
69 $this->_params
= array(
70 'contact_id' => $this->_contactId
,
72 'uf_name' => 'blahdyblah@gmail.com',
79 // Truncate the tables
92 * fetch contact id by uf id
94 public function testGetUFMatchID() {
97 'version' => $this->_apiversion
,
99 $result = civicrm_api('uf_match', 'get', $params);
100 $this->assertEquals($result['values'][$result['id']]['contact_id'], 69);
101 $this->assertAPISuccess($result);
104 function testGetUFMatchIDWrongParam() {
105 $params = 'a string';
106 $result = $this->callAPIFailure('uf_match', 'get', $params);
110 * fetch uf id by contact id
112 public function testGetUFID() {
115 'version' => $this->_apiversion
,
117 $result = civicrm_api('uf_match', 'get', $params);
118 $this->documentMe($params, $result, __FUNCTION__
, __FILE__
);
119 $this->assertEquals($result['values'][$result['id']]['uf_id'], 42);
120 $this->assertAPISuccess($result);
123 function testGetUFIDWrongParam() {
124 $params = 'a string';
125 $result = $this->callAPIFailure('uf_match', 'get', $params);
129 * Test civicrm_activity_create() using example code
131 function testUFMatchGetExample() {
132 require_once 'api/v3/examples/UFMatchGet.php';
133 $result = UF_match_get_example();
134 $expectedResult = UF_match_get_expectedresult();
135 $this->assertEquals($result, $expectedResult);
138 function testCreate() {
139 $result = civicrm_api('uf_match', 'create', $this->_params
);
140 $this->assertAPISuccess($result);
141 $this->getAndCheck($this->_params
, $result['id'], 'uf_match');
144 function testDelete() {
145 $result = civicrm_api('uf_match', 'create', $this->_params
);
146 $this->assertEquals(1, civicrm_api('uf_match', 'getcount', array(
147 'version' => $this->_apiversion
,
148 'id' => $result['id'],
150 civicrm_api('uf_match', 'delete', array(
151 'version' => $this->_apiversion
,
152 'id' => $result['id'],
154 $this->assertEquals(0, civicrm_api('uf_match', 'getcount', array(
155 'version' => $this->_apiversion
,
156 'id' => $result['id'],