3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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 +--------------------------------------------------------------------+
29 * Test class for UFGroup API - civicrm_uf_*
30 * @todo Split UFGroup and UFJoin tests
35 class api_v3_UFMatchTest
extends CiviUnitTestCase
{
36 // ids from the uf_group_test.xml fixture
37 protected $_ufGroupId = 11;
38 protected $_ufFieldId;
39 protected $_contactId;
40 protected $_apiversion;
41 protected $_params = array();
44 protected function setUp() {
46 $this->_apiversion
= 3;
56 $this->_contactId
= $this->individualCreate();
57 $op = new PHPUnit_Extensions_Database_Operation_Insert();
60 $this->createFlatXMLDataSet(dirname(__FILE__
) . '/dataset/uf_group_test.xml')
63 $this->_params
= array(
64 'contact_id' => $this->_contactId
,
66 'uf_name' => 'blahdyblah@gmail.com',
71 public function tearDown() {
72 // Truncate the tables
85 * Fetch contact id by uf id.
87 public function testGetUFMatchID() {
91 $result = $this->callAPISuccess('uf_match', 'get', $params);
92 $this->assertEquals($result['values'][$result['id']]['contact_id'], 69);
95 public function testGetUFMatchIDWrongParam() {
97 $result = $this->callAPIFailure('uf_match', 'get', $params);
101 * Fetch uf id by contact id.
103 public function testGetUFID() {
107 $result = $this->callAPIAndDocument('uf_match', 'get', $params, __FUNCTION__
, __FILE__
);
108 $this->assertEquals($result['values'][$result['id']]['uf_id'], 42);
111 public function testGetUFIDWrongParam() {
112 $params = 'a string';
113 $result = $this->callAPIFailure('uf_match', 'get', $params);
117 * Test civicrm_activity_create() using example code
119 public function testUFMatchGetExample() {
120 require_once 'api/v3/examples/UFMatch/Get.php';
121 $result = UF_match_get_example();
122 $expectedResult = UF_match_get_expectedresult();
123 $this->assertEquals($result, $expectedResult);
126 public function testCreate() {
127 $result = $this->callAPISuccess('uf_match', 'create', $this->_params
);
128 $this->getAndCheck($this->_params
, $result['id'], 'uf_match');
131 public function testDelete() {
132 $result = $this->callAPISuccess('uf_match', 'create', $this->_params
);
133 $this->assertEquals(1, $this->callAPISuccess('uf_match', 'getcount', array(
134 'id' => $result['id'],
136 $this->callAPISuccess('uf_match', 'delete', array(
137 'id' => $result['id'],
139 $this->assertEquals(0, $this->callAPISuccess('uf_match', 'getcount', array(
140 'id' => $result['id'],