Merge pull request #14840 from MegaphoneJon/core-1130
[civicrm-core.git] / tests / phpunit / api / v3 / CRM11793Test.php
1 <?php
2 /**
3 * File for the CRM11793 issue
4 * Include class definitions
5 */
6
7 /**
8 * Test APIv3 civicrm_activity_* functions
9 *
10 * @package CiviCRM
11 * @group headless
12 */
13 class api_v3_CRM11793Test extends CiviUnitTestCase {
14
15 /**
16 * Test setup for every test.
17 *
18 * Connect to the database, truncate the tables that will be used
19 * and redirect stdin to a temporary file
20 */
21 public function setUp() {
22 parent::setUp();
23
24 $this->individualCreate();
25 $this->householdCreate();
26 $this->organizationCreate();
27 }
28
29 public function tearDown() {
30 parent::tearDown();
31 }
32
33 /**
34 * Test civicrm_contact_create.
35 *
36 * Verify that attempt to create individual contact with only
37 * first and last names succeeds
38 */
39 public function testCRM11793Organization() {
40 $this->_testCRM11793ContactType('Organization');
41 }
42
43 public function testCRM11793Household() {
44 $this->_testCRM11793ContactType('Household');
45 }
46
47 public function testCRM11793Individual() {
48 $this->_testCRM11793ContactType('Individual');
49 }
50
51 /**
52 * @param $contactType
53 */
54 public function _testCRM11793ContactType($contactType) {
55 $result = $this->callAPISuccess(
56 'contact',
57 'get',
58 [
59 'contact_type' => $contactType,
60 ]
61 );
62
63 foreach ($result['values'] as $idx => $contact) {
64 $this->assertEquals($contact['contact_type'], $contactType, "In line " . __LINE__);
65 }
66 }
67
68 }