X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fapi%2Fv3%2FContactTest.php;h=480cc9355a6b9862794df9da93f612c87693629b;hb=2e4ca4ffca1cdf6354cc5513b2c96969b5785c54;hp=1d677c149092feddd101550a1045c72695ddfcfc;hpb=0b06398c9ce6d8d518b4fe68e4bd5d9f4f67f398;p=civicrm-core.git diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index 1d677c1490..480cc9355a 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -199,6 +199,45 @@ class api_v3_ContactTest extends CiviUnitTestCase { $this->assertEquals(array('Student', 'Staff'), $contact['values'][$cid]['contact_sub_type']); } + /** + * Verify that we can retreive contacts of different sub types + */ + public function testGetMultipleContactSubTypes() { + + // This test presumes that there are no parents or students in the dataset + + // create a student + $student = $this->callAPISuccess('contact', 'create', array( + 'email' => 'student@example.com', + 'contact_type' => 'Individual', + 'contact_sub_type' => 'Student', + )); + + // create a parent + $parent = $this->callAPISuccess('contact', 'create', array( + 'email' => 'parent@example.com', + 'contact_type' => 'Individual', + 'contact_sub_type' => 'Parent', + )); + + // create a parent + $contact = $this->callAPISuccess('contact', 'create', array( + 'email' => 'parent@example.com', + 'contact_type' => 'Individual', + )); + + // get all students and parents + $getParams = array('contact_sub_type' => array('IN' => array('Parent', 'Student'))); + $result = civicrm_api3('contact', 'get', $getParams); + + // check that we retrieved the student and the parent + $this->assertArrayHasKey($student['id'], $result['values']); + $this->assertArrayHasKey($parent['id'], $result['values']); + $this->assertEquals(2, $result['count']); + + } + + /** * Verify that attempt to create contact with empty params fails. */ @@ -2249,6 +2288,24 @@ class api_v3_ContactTest extends CiviUnitTestCase { $this->callAPISuccess('contact', 'create', $params); } + /** + * Test that delete with skip undelete respects permissions. + */ + public function testContactDeletePermissions() { + $contactID = $this->individualCreate(); + CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM'); + $this->callAPIFailure('Contact', 'delete', array( + 'id' => $contactID, + 'check_permissions' => 1, + 'skip_undelete' => 1, + )); + $this->callAPISuccess('Contact', 'delete', array( + 'id' => $contactID, + 'check_permissions' => 0, + 'skip_undelete' => 1, + )); + } + /** * Test update with check permissions set. */