3 require_once 'CRM/Utils/DeprecatedUtils.php';
6 * Class CRM_Utils_DeprecatedUtilsTest
9 class CRM_Utils_DeprecatedUtilsTest
extends CiviUnitTestCase
{
11 public function setUp() {
15 public function tearDown() {
16 // truncate a few tables
17 $tablesToTruncate = array(
20 'civicrm_contribution',
24 $this->quickCleanup($tablesToTruncate);
28 * Test civicrm_contact_check_params with no contact type.
30 public function testCheckParamsWithNoContactType() {
31 $params = array('foo' => 'bar');
32 $contact = _civicrm_api3_deprecated_contact_check_params($params, FALSE);
33 $this->assertEquals(1, $contact['is_error']);
37 * Test civicrm_contact_check_params with a duplicate.
38 * and request the error in array format
40 public function testCheckParamsWithDuplicateContact2() {
41 // Insert a row in civicrm_contact creating individual contact
42 $op = new PHPUnit_Extensions_Database_Operation_Insert();
43 $op->execute($this->_dbconn
,
44 $this->createXMLDataSet(
45 dirname(__FILE__
) . '/../../api/v3/dataset/contact_17.xml'
48 $op->execute($this->_dbconn
,
49 $this->createXMLDataSet(
50 dirname(__FILE__
) . '/../../api/v3/dataset/email_contact_17.xml'
55 'first_name' => 'Test',
56 'last_name' => 'Contact',
57 'email' => 'TestContact@example.com',
58 'contact_type' => 'Individual',
60 $contact = _civicrm_api3_deprecated_contact_check_params($params, TRUE);
61 $this->assertEquals(1, $contact['is_error']);
62 $this->assertRegexp("/matching contacts.*17/s",
63 $contact['error_message']['message']
68 * Test civicrm_contact_check_params with check for required
69 * params and no params
71 public function testCheckParamsWithNoParams() {
73 $contact = _civicrm_api3_deprecated_contact_check_params($params, FALSE);
74 $this->assertEquals(1, $contact['is_error']);