Skip to content
Snippets Groups Projects
Unverified Commit 022aba3d authored by Seamus Lee's avatar Seamus Lee Committed by GitHub
Browse files

Merge pull request #20622 from eileenmcnaughton/act2

#1191 [TEST][NFC] Increase setting of return in tests
parents 114e9545 e5914f86
No related branches found
No related tags found
No related merge requests found
......@@ -75,23 +75,23 @@ class CRM_ACL_ListTest extends CiviUnitTestCase {
/**
* Test access related to the 'access deleted contact' permission
*
* @throws \CRM_Core_Exception
*/
public function testViewEditDeleted() {
public function testViewEditDeleted(): void {
// create test contacts
$contacts = $this->createScenarioPlain();
// delete one contact
$deleted_contact_id = $contacts[2];
$this->callAPISuccess('Contact', 'create', ['id' => $deleted_contact_id, 'contact_is_deleted' => 1]);
$deleted_contact = $this->callAPISuccess('Contact', 'getsingle', ['id' => $deleted_contact_id]);
$this->assertEquals($deleted_contact['contact_is_deleted'], 1, "Contact should've been deleted");
// test WITH explicit permission
CRM_Core_Config::singleton()->userPermissionClass->permissions = ['edit all contacts', 'view all contacts'];
$result = CRM_Contact_BAO_Contact_Permission::allowList($contacts, CRM_Core_Permission::EDIT);
sort($result);
$this->assertNotContains($deleted_contact_id, $result, "Deleted contacts should be excluded");
$this->assertEquals(count($result), count($contacts) - 1, "Only deleted contacts should be excluded");
$this->assertNotContains($deleted_contact_id, $result, 'Deleted contacts should be excluded');
$this->assertEquals(count($result), count($contacts) - 1, 'Only deleted contacts should be excluded');
}
/**
......@@ -100,7 +100,7 @@ class CRM_ACL_ListTest extends CiviUnitTestCase {
* There should be the following permission-relationship
* contact[0] -> contact[1] -> contact[2]
*/
public function testPermissionByRelation() {
public function testPermissionByRelation(): void {
// create test scenario
$contacts = $this->createScenarioRelations();
......
......@@ -1218,13 +1218,28 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase {
];
}
public function testSendEmailBasic() {
/**
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testSendEmailBasic(): void {
$contactId = $this->individualCreate();
// create a logged in USER since the code references it for sendEmail user.
$loggedInUser = $this->createLoggedInUser();
$contact = $this->civicrm_api('contact', 'getsingle', ['id' => $contactId, 'version' => $this->_apiversion]);
$contactDetailsIntersectKeys = [
'contact_id' => '',
'sort_name' => '',
'display_name' => '',
'do_not_email' => '',
'preferred_mail_format' => '',
'is_deceased' => '',
'email' => '',
'on_hold' => '',
];
$contact = $this->callAPISuccess('Contact', 'getsingle', ['id' => $contactId, 'return' => array_keys($contactDetailsIntersectKeys)]);
$contactDetailsIntersectKeys = [
'contact_id' => '',
'sort_name' => '',
......@@ -1244,7 +1259,7 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase {
$text = __FUNCTION__ . ' text';
$userID = $loggedInUser;
[$sent, $activity_ids] = $email_result = CRM_Activity_BAO_Activity::sendEmail(
[$sent, $activity_ids] = CRM_Activity_BAO_Activity::sendEmail(
$contactDetails,
$subject,
$text,
......@@ -1254,7 +1269,7 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase {
$from = __FUNCTION__ . '@example.com'
);
$activity = $this->civicrm_api('activity', 'getsingle', ['id' => $activity_ids[0], 'version' => $this->_apiversion]);
$activity = $this->callAPISuccessGetSingle('Activity', ['id' => $activity_ids[0], 'return' => ['details', 'subject']]);
$details = "-ALTERNATIVE ITEM 0-
$html
-ALTERNATIVE ITEM 1-
......
......@@ -604,7 +604,7 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase {
* @dataProvider versionThreeAndFour
* @throws \CRM_Core_Exception
*/
public function testGetActivityNoPermissions($version) {
public function testGetActivityNoPermissions(int $version): void {
$this->_apiversion = $version;
$this->setPermissions([]);
$this->callAPISuccess('Activity', 'get');
......@@ -620,7 +620,7 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase {
* @throws \CiviCRM_API3_Exception
* @dataProvider versionThreeAndFour
*/
public function testGetActivityViewAllActivitiesDoesntCutItAnymore($version) {
public function testGetActivityViewAllActivitiesDoesntCutItAnymore(int $version): void {
$this->_apiversion = $version;
$activity = $this->activityCreate();
$this->setPermissions(['view all activities', 'access CiviCRM']);
......
......@@ -1317,15 +1317,17 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
/**
* Test civicrm_activities_contact_get()
*
* @throws \CRM_Core_Exception
*/
public function testActivitiesContactGet() {
public function testActivitiesContactGet(): void {
$activity = $this->callAPISuccess('activity', 'create', $this->_params);
$activity2 = $this->callAPISuccess('activity', 'create', $this->_params2);
// Get activities associated with contact $this->_contactID.
$params = [
$result = $this->callAPISuccess('Activity', 'get', [
'contact_id' => $this->_contactID,
];
$result = $this->callAPISuccess('activity', 'get', $params);
'return' => ['activity_type_id', 'activity_name'],
]);
$this->assertEquals(2, $result['count']);
$this->assertEquals($this->test_activity_type_value, $result['values'][$activity['id']]['activity_type_id']);
......@@ -1335,11 +1337,13 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
/**
* Test chained Activity format.
*
* @throws \CRM_Core_Exception
*/
public function testChainedActivityGet() {
public function testChainedActivityGet(): void {
$activity = $this->callAPISuccess('Contact', 'Create', [
'display_name' => "bob brown",
'display_name' => 'bob brown',
'contact_type' => 'Individual',
'api.activity_type.create' => [
'weight' => '2',
......@@ -1355,7 +1359,7 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
],
]);
$result = $this->callAPISuccess('Activity', 'Get', [
$this->callAPISuccess('Activity', 'Get', [
'id' => $activity['id'],
'return.assignee_contact_id' => 1,
'api.contact.get' => ['api.pledge.get' => 1],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment