update test
authordemeritcowboy <demeritcowboy@hotmail.com>
Tue, 4 Jul 2023 14:11:43 +0000 (10:11 -0400)
committerdemeritcowboy <demeritcowboy@hotmail.com>
Tue, 4 Jul 2023 15:09:03 +0000 (11:09 -0400)
tests/phpunit/CRM/Core/BAO/SchemaHandlerTest.php
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/api/v3/RelationshipTest.php

index bef335ba8ae8b57ed667a8832f80d0c6aeedd51a..1e1e3e286963c190c14a66f28e6792d71a6c8024 100644 (file)
@@ -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'));
index f5eff65ba163fa7192f8cb99207548d203a2c4bf..a51328484a26e98d6cc593547e91c5751ff15f29 100644 (file)
@@ -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();
     }
index 09b6d694a8a5aea85ecf0c51b11737e11e8eb629..84618d5fdbdbea07b63ed40a2837a43ce254b487 100644 (file)
@@ -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)");
   }
 
 }