Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
demeritcowboy committed Jul 4, 2023
1 parent 6e33ac4 commit f04b7f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
3 changes: 3 additions & 0 deletions tests/phpunit/CiviTest/CiviUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ protected function setUp(): void {
// clear permissions stub to not check permissions
$config->userPermissionClass->permissions = NULL;

// Normally a stock install has some acls in the table even if they aren't in use.
CRM_Core_DAO::executeQuery("INSERT INTO civicrm_acl (name, deny, entity_table, entity_id, operation, object_table, object_id, acl_table, acl_id, is_active) VALUES ('Edit All Contacts', 0, 'civicrm_acl_role', 1, 'Edit', 'civicrm_group', 0, NULL, NULL, 1)");

//flush component settings
CRM_Core_Component::getEnabledComponents(TRUE);

Expand Down
16 changes: 5 additions & 11 deletions tests/phpunit/api/v3/RelationshipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1457,8 +1457,12 @@ public function testDisableExpiredRelationships() {
]));
}

/**
* This is no longer guarding against the original issue, but is still a test
* of something. It's now mostly testing a different variation of
* relationship + the default in api3 being to not check permissions.
*/
public function testCreateWithLesserPermissions() {
$this->setUpACLByCheating();
CRM_Core_Config::singleton()->userPermissionClass->permissions = [];
$params = [
'contact_id_a' => $this->_cId_a,
Expand All @@ -1468,16 +1472,6 @@ public function testCreateWithLesserPermissions() {
$id = $this->callAPISuccess('Relationship', 'create', $params)['id'];
$relationship = $this->callAPISuccess('Relationship', 'getsingle', ['id' => $id]);
$this->assertEquals($params, array_intersect_key($relationship, $params));
CRM_Core_DAO::executeQuery("DELETE FROM civicrm_acl");
}

/**
* Normally a stock install has some acls in the table even if they aren't in
* use. I can't figure out how to set them up another way so I just lifted
* this from civicrm_generated.mysql
*/
private function setUpACLByCheating() {
CRM_Core_DAO::executeQuery("INSERT INTO civicrm_acl (name, deny, entity_table, entity_id, operation, object_table, object_id, acl_table, acl_id, is_active) VALUES ('Edit All Contacts', 0, 'civicrm_acl_role', 1, 'Edit', 'civicrm_group', 0, NULL, NULL, 1)");
}

}

0 comments on commit f04b7f9

Please sign in to comment.