commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / tests / phpunit / api / v3 / CRM11793Test.php
1 <?php
2 /**
3 * File for the CRM11793 issue
4 * Include class definitions
5 */
6 require_once 'CiviTest/CiviUnitTestCase.php';
7
8
9 /**
10 * Test APIv3 civicrm_activity_* functions
11 *
12 * @package CiviCRM
13 */
14 class api_v3_CRM11793Test extends CiviUnitTestCase {
15
16 /**
17 * Test setup for every test.
18 *
19 * Connect to the database, truncate the tables that will be used
20 * and redirect stdin to a temporary file
21 */
22 public function setUp() {
23 // Connect to the database
24 parent::setUp();
25
26 require_once 'CiviTest/Contact.php';
27
28 // lets create one contact of each type
29 Contact::createIndividual();
30 Contact::createHousehold();
31 Contact::createOrganisation();
32 }
33
34 public function tearDown() {
35 }
36
37 /**
38 * Test civicrm_contact_create.
39 *
40 * Verify that attempt to create individual contact with only
41 * first and last names succeeds
42 */
43 public function testCRM11793Organization() {
44 $this->_testCRM11793ContactType('Organization');
45 }
46
47 public function testCRM11793Household() {
48 $this->_testCRM11793ContactType('Household');
49 }
50
51 public function testCRM11793Individual() {
52 $this->_testCRM11793ContactType('Individual');
53 }
54
55 /**
56 * @param $contactType
57 */
58 public function _testCRM11793ContactType($contactType) {
59 $result = $this->callAPISuccess(
60 'contact',
61 'get',
62 array(
63 'contact_type' => $contactType,
64 )
65 );
66
67 foreach ($result['values'] as $idx => $contact) {
68 $this->assertEquals($contact['contact_type'], $contactType, "In line " . __LINE__);
69 }
70 }
71
72 }