Commit | Line | Data |
---|---|---|
6a488035 TO |
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 | * | |
6c6e6187 | 12 | * @package CiviCRM |
6a488035 TO |
13 | */ |
14 | class api_v3_CRM11793Test extends CiviUnitTestCase { | |
6a488035 TO |
15 | |
16 | /** | |
eceb18cc | 17 | * Test setup for every test. |
6a488035 | 18 | * |
d177a2a6 EM |
19 | * Connect to the database, truncate the tables that will be used |
20 | * and redirect stdin to a temporary file | |
6a488035 TO |
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 | ||
00be9182 | 34 | public function tearDown() { |
6a488035 TO |
35 | } |
36 | ||
37 | /** | |
fe482240 | 38 | * Test civicrm_contact_create. |
6a488035 | 39 | * |
d177a2a6 EM |
40 | * Verify that attempt to create individual contact with only |
41 | * first and last names succeeds | |
6a488035 | 42 | */ |
00be9182 | 43 | public function testCRM11793Organization() { |
6a488035 TO |
44 | $this->_testCRM11793ContactType('Organization'); |
45 | } | |
46 | ||
00be9182 | 47 | public function testCRM11793Household() { |
6a488035 TO |
48 | $this->_testCRM11793ContactType('Household'); |
49 | } | |
92915c55 | 50 | |
00be9182 | 51 | public function testCRM11793Individual() { |
6a488035 TO |
52 | $this->_testCRM11793ContactType('Individual'); |
53 | } | |
54 | ||
4cbe18b8 EM |
55 | /** |
56 | * @param $contactType | |
57 | */ | |
00be9182 | 58 | public function _testCRM11793ContactType($contactType) { |
4e420887 | 59 | $result = $this->callAPISuccess( |
6a488035 TO |
60 | 'contact', |
61 | 'get', | |
62 | array( | |
21dfd5f5 | 63 | 'contact_type' => $contactType, |
6a488035 TO |
64 | ) |
65 | ); | |
66 | ||
6a488035 TO |
67 | foreach ($result['values'] as $idx => $contact) { |
68 | $this->assertEquals($contact['contact_type'], $contactType, "In line " . __LINE__); | |
69 | } | |
70 | } | |
96025800 | 71 | |
4cbe18b8 | 72 | } |