| 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 | } |
| 31 | |
| 32 | /** |
| 33 | * Test civicrm_contact_create. |
| 34 | * |
| 35 | * Verify that attempt to create individual contact with only |
| 36 | * first and last names succeeds |
| 37 | */ |
| 38 | public function testCRM11793Organization() { |
| 39 | $this->_testCRM11793ContactType('Organization'); |
| 40 | } |
| 41 | |
| 42 | public function testCRM11793Household() { |
| 43 | $this->_testCRM11793ContactType('Household'); |
| 44 | } |
| 45 | |
| 46 | public function testCRM11793Individual() { |
| 47 | $this->_testCRM11793ContactType('Individual'); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * @param $contactType |
| 52 | */ |
| 53 | public function _testCRM11793ContactType($contactType) { |
| 54 | $result = $this->callAPISuccess( |
| 55 | 'contact', |
| 56 | 'get', |
| 57 | array( |
| 58 | 'contact_type' => $contactType, |
| 59 | ) |
| 60 | ); |
| 61 | |
| 62 | foreach ($result['values'] as $idx => $contact) { |
| 63 | $this->assertEquals($contact['contact_type'], $contactType, "In line " . __LINE__); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | } |