<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
-
-
-
+ */
require_once 'CiviTest/CiviUnitTestCase.php';
class api_v3_ContactTypeTest extends CiviUnitTestCase {
protected $_apiversion;
- function setUp() {
+ public function setUp() {
parent::setUp();
+ $this->useTransaction(TRUE);
$this->_apiversion = 3;
$params = array(
'label' => 'sub_individual',
);
$result = CRM_Contact_BAO_ContactType::add($params);
$this->subTypeIndividual = $params['name'];
- $this->_subTypeIndividualId = $result->id;
$params = array(
'label' => 'sub_organization',
);
$result = CRM_Contact_BAO_ContactType::add($params);
$this->subTypeOrganization = $params['name'];
- $this->_subTypeOrganizationId = $result->id;
$params = array(
'label' => 'sub_household',
);
$result = CRM_Contact_BAO_ContactType::add($params);
$this->subTypeHousehold = $params['name'];
- $this->_subTypeHouseholdId = $result->id;
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- *
- */
- function tearDown() {
- $contactTypeIds = array(
- $this->_subTypeIndividualId,
- $this->_subTypeOrganizationId,
- $this->_subTypeHouseholdId,
- );
- foreach ($contactTypeIds as $typeId) {
- $this->contactTypeDelete($typeId);
- }
}
/**
- * Test add methods with valid data
+ * Test add methods with valid data.
* success expected
*/
- function testContactCreate() {
+ public function testContactCreate() {
// check for Type:Individual Subtype:sub_individual
$contactParams = array(
/**
- * Test add with invalid data
+ * Test add with invalid data.
*/
- function testContactAddInvalidData() {
+ public function testContactAddInvalidData() {
// check for Type:Individual Subtype:sub_household
$contactParams = array(
/**
- * Test update with no subtype to valid subtype
+ * Test update with no subtype to valid subtype.
* success expected
*/
- function testContactUpdateNoSubtypeValid() {
+ public function testContactUpdateNoSubtypeValid() {
// check for Type:Individual
$contactParams = array(
/**
- * Test update with no subtype to invalid subtype
+ * Test update with no subtype to invalid subtype.
*/
- function testContactUpdateNoSubtypeInvalid() {
+ public function testContactUpdateNoSubtypeInvalid() {
// check for Type:Individual
$contactParams = array(
$updateContact = $this->callAPIFailure('contact', 'create', $updateParams);
$params = array(
'contact_id' => $contact['id'],
- );
+ );
$this->callAPISuccess('contact', 'delete', $params);
// check for Type:Organization
}
/**
- * Test update with no subtype to valid subtype
+ * Test update with no subtype to valid subtype.
* success expected
*/
- function testContactUpdateSubtypeValid() {
+ public function testContactUpdateSubtypeValid() {
$params = array(
'label' => 'sub2_individual',
$this->assertEquals(end($result['contact_sub_type']), $updateParams['contact_sub_type'], "In line " . __LINE__);
$this->callAPISuccess('contact', 'delete', $params);
-
$params = array(
'label' => 'sub2_organization',
'name' => 'sub2_organization',
}
/**
- * Test update with no subtype to invalid subtype
+ * Test update with no subtype to invalid subtype.
*/
- function testContactUpdateSubtypeInvalid() {
+ public function testContactUpdateSubtypeInvalid() {
// check for Type:Individual subtype:sub_individual
$contactParams = array(
);
$this->callAPISuccess('contact', 'delete', $params);
}
-}
+}