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