From 3b20cbda83f35f48db0e06a1e3f3b231f12ba842 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Tue, 4 Jul 2023 10:11:43 -0400 Subject: [PATCH] update test --- tests/phpunit/CRM/Core/BAO/SchemaHandlerTest.php | 2 +- tests/phpunit/CiviTest/CiviUnitTestCase.php | 5 ++++- tests/phpunit/api/v3/RelationshipTest.php | 16 +++++----------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/tests/phpunit/CRM/Core/BAO/SchemaHandlerTest.php b/tests/phpunit/CRM/Core/BAO/SchemaHandlerTest.php index bef335ba8a..1e1e3e2869 100644 --- a/tests/phpunit/CRM/Core/BAO/SchemaHandlerTest.php +++ b/tests/phpunit/CRM/Core/BAO/SchemaHandlerTest.php @@ -145,7 +145,7 @@ class CRM_Core_BAO_SchemaHandlerTest extends CiviUnitTestCase { CRM_Core_DAO::singleValueQuery('ANALYZE TABLE civicrm_acl'); $this->assertEquals([ 'civicrm_worldregion' => 6, - 'civicrm_acl' => 0, + 'civicrm_acl' => 1, 'civicrm_domain' => 2, ], CRM_Core_BAO_SchemaHandler::getRowCountForTables(['civicrm_domain', 'civicrm_acl', 'random_name', 'civicrm_worldregion'])); $this->assertEquals(2, CRM_Core_BAO_SchemaHandler::getRowCountForTable('civicrm_domain')); diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index f5eff65ba1..a51328484a 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -321,6 +321,9 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { // 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); @@ -464,7 +467,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { CRM_Core_Transaction::forceRollbackIfEnabled(); Manager::singleton(TRUE); - $tablesToTruncate = ['civicrm_contact', 'civicrm_uf_match', 'civicrm_email', 'civicrm_address']; + $tablesToTruncate = ['civicrm_contact', 'civicrm_uf_match', 'civicrm_email', 'civicrm_address', 'civicrm_acl']; $this->quickCleanup($tablesToTruncate); $this->createDomainContacts(); } diff --git a/tests/phpunit/api/v3/RelationshipTest.php b/tests/phpunit/api/v3/RelationshipTest.php index 09b6d694a8..84618d5fdb 100644 --- a/tests/phpunit/api/v3/RelationshipTest.php +++ b/tests/phpunit/api/v3/RelationshipTest.php @@ -1457,8 +1457,12 @@ class api_v3_RelationshipTest extends CiviUnitTestCase { ])); } + /** + * 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, @@ -1468,16 +1472,6 @@ class api_v3_RelationshipTest extends CiviUnitTestCase { $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)"); } } -- 2.25.1