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