Merge pull request #1199 from totten/master-premature-commit
[civicrm-core.git] / 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 * Constructor
17 *
18 * Initialize configuration
19 */
20 function __construct() {
21 parent::__construct();
22 }
23
24 /**
25 * Test setup for every test
26 *
27 * Connect to the database, truncate the tables that will be used
28 * and redirect stdin to a temporary file
29 */
30 public function setUp() {
31 // Connect to the database
32 parent::setUp();
33
34 require_once 'CiviTest/Contact.php';
35
36 // lets create one contact of each type
37 Contact::createIndividual();
38 Contact::createHousehold();
39 Contact::createOrganisation();
40 }
41
42 function tearDown() {
43 }
44
45 /**
46 * Test civicrm_contact_create
47 *
48 * Verify that attempt to create individual contact with only
49 * first and last names succeeds
50 */
51 function testCRM11793Organization() {
52 $this->_testCRM11793ContactType('Organization');
53 }
54
55 function testCRM11793Household() {
56 $this->_testCRM11793ContactType('Household');
57 }
58 function testCRM11793Individual() {
59 $this->_testCRM11793ContactType('Individual');
60 }
61
62 function _testCRM11793ContactType($contactType) {
63 $result = $this->callAPISuccess(
64 'contact',
65 'get',
66 array(
67 'contact_type' => $contactType
68 )
69 );
70
71 foreach ($result['values'] as $idx => $contact) {
72 $this->assertEquals($contact['contact_type'], $contactType, "In line " . __LINE__);
73 }
74 }
75 }