APIv4 - Reorganize test classes, don't use transactions for custom value tests
authorColeman Watts <coleman@civicrm.org>
Sat, 7 May 2022 17:35:56 +0000 (13:35 -0400)
committerColeman Watts <coleman@civicrm.org>
Sat, 7 May 2022 20:08:12 +0000 (16:08 -0400)
Transactions don't work for custom field tests because schema alterations can't be inside transactions.
This moves the "implements TransactionalInterface" declaration from the base class to the test classes
so each one can opt-in individually.

86 files changed:
tests/phpunit/api/v4/Action/AbstractActionFunctionTest.php
tests/phpunit/api/v4/Action/BasicActionsTest.php
tests/phpunit/api/v4/Action/ChainTest.php
tests/phpunit/api/v4/Action/ComplexQueryTest.php
tests/phpunit/api/v4/Action/ContactApiKeyTest.php
tests/phpunit/api/v4/Action/ContactChecksumTest.php
tests/phpunit/api/v4/Action/ContactGetTest.php
tests/phpunit/api/v4/Action/ContactIsDeletedTest.php
tests/phpunit/api/v4/Action/CurrentFilterTest.php
tests/phpunit/api/v4/Action/DateTest.php
tests/phpunit/api/v4/Action/EvaluateConditionTest.php
tests/phpunit/api/v4/Action/EventTest.php
tests/phpunit/api/v4/Action/FkJoinTest.php
tests/phpunit/api/v4/Action/GetExtraFieldsTest.php
tests/phpunit/api/v4/Action/GetFieldsTest.php
tests/phpunit/api/v4/Action/GetFromArrayTest.php
tests/phpunit/api/v4/Action/IndexTest.php
tests/phpunit/api/v4/Action/IsPrimaryTest.php
tests/phpunit/api/v4/Action/NullValueTest.php
tests/phpunit/api/v4/Action/RecentItemsTest.php
tests/phpunit/api/v4/Action/ReplaceTest.php
tests/phpunit/api/v4/Action/RequiredFieldTest.php
tests/phpunit/api/v4/Action/ResultTest.php
tests/phpunit/api/v4/Action/SaveTest.php
tests/phpunit/api/v4/Action/SqlExpressionTest.php
tests/phpunit/api/v4/Action/SqlFunctionTest.php
tests/phpunit/api/v4/Action/UpdateContactTest.php
tests/phpunit/api/v4/Api4TestBase.php [moved from tests/phpunit/api/v4/UnitTestCase.php with 98% similarity]
tests/phpunit/api/v4/Custom/BasicCustomFieldTest.php [moved from tests/phpunit/api/v4/Action/BasicCustomFieldTest.php with 99% similarity]
tests/phpunit/api/v4/Custom/ContactCustomJoinTest.php [moved from tests/phpunit/api/v4/Entity/ContactCustomJoinTest.php with 93% similarity]
tests/phpunit/api/v4/Custom/CoreUtilTest.php [moved from tests/phpunit/api/v4/Utils/CoreUtilTest.php with 96% similarity]
tests/phpunit/api/v4/Custom/CreateCustomValueTest.php [moved from tests/phpunit/api/v4/Action/CreateCustomValueTest.php with 97% similarity]
tests/phpunit/api/v4/Custom/CreateWithOptionGroupTest.php [moved from tests/phpunit/api/v4/Action/CreateWithOptionGroupTest.php with 98% similarity]
tests/phpunit/api/v4/Custom/CustomContactRefTest.php [moved from tests/phpunit/api/v4/Action/CustomContactRefTest.php with 98% similarity]
tests/phpunit/api/v4/Custom/CustomFieldAlterTest.php [moved from tests/phpunit/api/v4/Action/CustomFieldAlterTest.php with 98% similarity]
tests/phpunit/api/v4/Custom/CustomGroupACLTest.php [moved from tests/phpunit/api/v4/Action/CustomGroupACLTest.php with 99% similarity]
tests/phpunit/api/v4/Custom/CustomTestBase.php [moved from tests/phpunit/api/v4/Action/BaseCustomValueTest.php with 70% similarity]
tests/phpunit/api/v4/Custom/CustomValuePerformanceTest.php [moved from tests/phpunit/api/v4/Action/CustomValuePerformanceTest.php with 97% similarity]
tests/phpunit/api/v4/Custom/CustomValueTest.php [moved from tests/phpunit/api/v4/Action/CustomValueTest.php with 99% similarity]
tests/phpunit/api/v4/Custom/ExtendFromIndividualTest.php [moved from tests/phpunit/api/v4/Action/ExtendFromIndividualTest.php with 95% similarity]
tests/phpunit/api/v4/Custom/PseudoconstantTest.php [moved from tests/phpunit/api/v4/Action/PseudoconstantTest.php with 99% similarity]
tests/phpunit/api/v4/Custom/UpdateCustomValueTest.php [moved from tests/phpunit/api/v4/Action/UpdateCustomValueTest.php with 95% similarity]
tests/phpunit/api/v4/Entity/ActivityTest.php
tests/phpunit/api/v4/Entity/AddressTest.php
tests/phpunit/api/v4/Entity/CaseTest.php
tests/phpunit/api/v4/Entity/ConformanceTest.php
tests/phpunit/api/v4/Entity/ContactInterchangeTest.php
tests/phpunit/api/v4/Entity/ContactJoinTest.php
tests/phpunit/api/v4/Entity/ContactTypeTest.php
tests/phpunit/api/v4/Entity/DomainTest.php
tests/phpunit/api/v4/Entity/EntityTest.php
tests/phpunit/api/v4/Entity/ExampleDataTest.php
tests/phpunit/api/v4/Entity/ExtensionTest.php
tests/phpunit/api/v4/Entity/GroupContactTest.php
tests/phpunit/api/v4/Entity/ManagedEntityTest.php
tests/phpunit/api/v4/Entity/MembershipTest.php
tests/phpunit/api/v4/Entity/MessageTemplateTest.php
tests/phpunit/api/v4/Entity/NavigationTest.php
tests/phpunit/api/v4/Entity/NoteTest.php
tests/phpunit/api/v4/Entity/OptionValueTest.php
tests/phpunit/api/v4/Entity/ParticipantTest.php
tests/phpunit/api/v4/Entity/RecentItemTest.php
tests/phpunit/api/v4/Entity/RelationshipTest.php
tests/phpunit/api/v4/Entity/RouteTest.php
tests/phpunit/api/v4/Entity/SavedSearchTest.php
tests/phpunit/api/v4/Entity/SettingTest.php
tests/phpunit/api/v4/Entity/SystemRotateKeyTest.php
tests/phpunit/api/v4/Entity/SystemTest.php
tests/phpunit/api/v4/Entity/TagTest.php
tests/phpunit/api/v4/Entity/TranslationTest.php
tests/phpunit/api/v4/Entity/ValidateValuesTest.php
tests/phpunit/api/v4/Entity/WordReplacementTest.php
tests/phpunit/api/v4/Entity/WorkflowMessageTest.php
tests/phpunit/api/v4/Query/Api4SelectQueryTest.php
tests/phpunit/api/v4/Query/OneToOneJoinTest.php
tests/phpunit/api/v4/Query/OptionValueJoinTest.php
tests/phpunit/api/v4/Query/PermissionCheckTest.php
tests/phpunit/api/v4/Query/SelectQueryMultiJoinTest.php
tests/phpunit/api/v4/Query/SqlExpressionParserTest.php
tests/phpunit/api/v4/Service/Schema/SchemaMapperTest.php
tests/phpunit/api/v4/Spec/RequestSpecTest.php
tests/phpunit/api/v4/Spec/SpecFormatterTest.php
tests/phpunit/api/v4/Spec/SpecGathererTest.php
tests/phpunit/api/v4/Utils/ArrayInsertionServiceTest.php
tests/phpunit/api/v4/Utils/ReflectionUtilsTest.php
tests/phpunit/api/v4/Utils/SelectUtilTest.php

index 3eaae0130fc702fba032fccbca0f5c94780dd636..84fd299c73d4982561d16bed57f1b4ee84e3d3b9 100644 (file)
 
 namespace api\v4\Action;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class AbstractActionFunctionTest extends UnitTestCase {
+class AbstractActionFunctionTest extends Api4TestBase implements TransactionalInterface {
 
   public function testUndefinedParamException(): void {
     $this->expectException('API_Exception');
index 13390bee458a5b4ee934266ee4ac00a6182c6d04..b7bc554e79f9477cb23789869790df2efaf2d98a 100644 (file)
 
 namespace api\v4\Action;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\MockBasicEntity;
 use Civi\Api4\Utils\CoreUtil;
 use Civi\Core\Event\GenericHookEvent;
 use Civi\Test\HookInterface;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class BasicActionsTest extends UnitTestCase implements HookInterface {
+class BasicActionsTest extends Api4TestBase implements HookInterface, TransactionalInterface {
 
   /**
    * Listens for civi.api4.entityTypes event to manually add this nonstandard entity
index 47a1cbe86d07650cf9504d7d50b3a87489ccbd8c..7e2bb75962b99d3d8629aac4d3a56318fa20f2ae 100644 (file)
 
 namespace api\v4\Action;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Activity;
 use Civi\Api4\Contact;
 use Civi\Api4\CustomField;
 use Civi\Api4\CustomGroup;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class ChainTest extends UnitTestCase {
+class ChainTest extends Api4TestBase implements TransactionalInterface {
 
   public function tearDown(): void {
     CustomField::delete()
index 7f957f7b1a786e4b6e1dacf4d88c202dc04cdd64..955377382f61678b3179da313ad6ef1128397837 100644 (file)
 
 namespace api\v4\Action;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Activity;
 use Civi\Api4\Contact;
 use Civi\Test\CiviEnvBuilder;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
@@ -30,7 +31,7 @@ use Civi\Test\CiviEnvBuilder;
  * This class tests a series of complex query situations described in the
  * initial APIv4 specification
  */
-class ComplexQueryTest extends UnitTestCase {
+class ComplexQueryTest extends Api4TestBase implements TransactionalInterface {
 
   public function setUpHeadless(): CiviEnvBuilder {
     $this->loadDataSet('DefaultDataSet');
index de323c8c544ff730bd90c15384d10a17ede62beb..edfdb6447449e294d4927f65c8747a0164a50f41 100644 (file)
 
 namespace api\v4\Action;
 
+use api\v4\Api4TestBase;
 use Civi\Api4\Contact;
 use Civi\Api4\Email;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class ContactApiKeyTest extends \api\v4\UnitTestCase {
+class ContactApiKeyTest extends Api4TestBase implements TransactionalInterface {
 
   public function testGetApiKey() {
     \CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM', 'add contacts', 'edit api keys', 'view all contacts', 'edit all contacts'];
index 60d5b64c000a7e03563609785821f019311197e4..66954ca3226b53f6e04e714872fb501afe84ea89 100644 (file)
 
 namespace api\v4\Action;
 
+use api\v4\Api4TestBase;
 use Civi\Api4\Contact;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class ContactChecksumTest extends \api\v4\UnitTestCase {
+class ContactChecksumTest extends Api4TestBase implements TransactionalInterface {
 
   public function testGetChecksum() {
     $contact = Contact::create(FALSE)
index c85c96229fb8ee82fa042f82e0bada2201e5ef10..e02827bf50f0baa039f827dc570139144a5e5a7b 100644 (file)
 
 namespace api\v4\Action;
 
+use api\v4\Api4TestBase;
 use Civi\Api4\Contact;
 use Civi\Api4\Relationship;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class ContactGetTest extends \api\v4\UnitTestCase {
+class ContactGetTest extends Api4TestBase implements TransactionalInterface {
 
   public function testGetDeletedContacts() {
     $last_name = uniqid('deleteContactTest');
index 7892f43c4262e76165ec53e7709e45297e7aa4ea..e8aea8f0173491483c56a833e9b22192e302c97f 100644 (file)
 
 namespace api\v4\Action;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class ContactIsDeletedTest extends UnitTestCase {
+class ContactIsDeletedTest extends Api4TestBase implements TransactionalInterface {
 
   public function setUpHeadless() {
     $relatedTables = [
index aa214029a058bbcf59a83dd19a6396b49bd4724e..a2126fd80fbae1e1ee0443049f4885a428bde273 100644 (file)
 namespace api\v4\Action;
 
 use Civi\Api4\Relationship;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Contact;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class CurrentFilterTest extends UnitTestCase {
+class CurrentFilterTest extends Api4TestBase implements TransactionalInterface {
 
   public function testCurrentRelationship() {
     $cid1 = Contact::create()->addValue('first_name', 'Bob1')->execute()->first()['id'];
index 1e58c5e772392b61c45b34a85f89a1ecdd82281a..b58a59ad06d3a96eb7fa5705138df6ee378aed76 100644 (file)
@@ -23,12 +23,13 @@ use Civi\Api4\Activity;
 use Civi\Api4\Contact;
 use Civi\Api4\Contribution;
 use Civi\Api4\Relationship;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class DateTest extends UnitTestCase {
+class DateTest extends Api4TestBase implements TransactionalInterface {
 
   public function testRelationshipDate() {
     $c1 = Contact::create()
index 3733d87fdb3557a83ebe79f70c03973ebcb46043..551bcb41d2c9bf09d4646b0abf8f4737f7ea45e1 100644 (file)
 namespace api\v4\Action;
 
 use Civi\Api4\MockBasicEntity;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class EvaluateConditionTest extends UnitTestCase {
+class EvaluateConditionTest extends Api4TestBase implements TransactionalInterface {
 
   public function testEvaluateCondition() {
     $action = MockBasicEntity::get();
index e61c0b70b38397fee55553f19e23149f79cb41f4..ba0e0ee05dac3796e5636910eb2fa153cbe2e465 100644 (file)
  * @copyright CiviCRM LLC https://civicrm.org/licensing
  */
 
+use api\v4\Api4TestBase;
 use Civi\Api4\Event;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class EventTest extends \api\v4\UnitTestCase {
+class EventTest extends Api4TestBase implements TransactionalInterface {
 
   /**
    * Test that the event api filters out templates by default.
index a9ae5664a6641c1b2601b1691ae3562e0e94e66f..bde62072da6cdccb14997e13846368af1c9fa029 100644 (file)
@@ -19,7 +19,7 @@
 
 namespace api\v4\Action;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Activity;
 use Civi\Api4\CiviCase;
 use Civi\Api4\Contact;
@@ -28,11 +28,12 @@ use Civi\Api4\EntityTag;
 use Civi\Api4\Phone;
 use Civi\Api4\Relationship;
 use Civi\Api4\Tag;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class FkJoinTest extends UnitTestCase {
+class FkJoinTest extends Api4TestBase implements TransactionalInterface {
 
   public function setUpHeadless() {
     $this->loadDataSet('DefaultDataSet');
index 4efbc606063bfe26a7ea1fb0d6642244c08737dc..192cf0f88f81f6ee94cc6dc308ca5ecaf3813349 100644 (file)
 
 namespace api\v4\Action;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Activity;
 use Civi\Api4\Address;
 use Civi\Api4\Contact;
 use Civi\Api4\Tag;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class GetExtraFieldsTest extends UnitTestCase {
+class GetExtraFieldsTest extends Api4TestBase implements TransactionalInterface {
 
   public function testGetFieldsByContactType() {
     $getFields = Contact::getFields(FALSE)->addSelect('name')->addWhere('type', '=', 'Field');
index b6646e5e2212d56d1f184d0760f92cbdd64c82ca..981780fa963ba1e877ff26cb219ffcf8d09a1318 100644 (file)
 
 namespace api\v4\Action;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Activity;
 use Civi\Api4\Campaign;
 use Civi\Api4\Contact;
 use Civi\Api4\Contribution;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class GetFieldsTest extends UnitTestCase {
+class GetFieldsTest extends Api4TestBase implements TransactionalInterface {
 
   public function testOptionsAreReturned() {
     $fields = Contact::getFields(FALSE)
index 7b6f802a253f55d28c473815e626b6c4efc78cfb..85e20bda0255f9eb1371b67852e06b41acb5e4cc 100644 (file)
 
 namespace api\v4\Action;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\MockArrayEntity;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class GetFromArrayTest extends UnitTestCase {
+class GetFromArrayTest extends Api4TestBase implements TransactionalInterface {
 
   public function testArrayGetWithLimit() {
     $result = MockArrayEntity::get()
index 41f535a95ce81b142e1b1359841c82f606e1c2ec..26fcd90ce4cdcc5272336e16a9612f36a3d3b6dd 100644 (file)
 
 namespace api\v4\Action;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class IndexTest extends UnitTestCase {
+class IndexTest extends Api4TestBase implements TransactionalInterface {
 
   public function testIndex() {
     // Results indexed by name
index b99afd0d53d645dea96e074fce01e83f98a0e6c2..a2dae2075d997010ec88dcadeef788acab39b569 100644 (file)
@@ -24,12 +24,13 @@ use Civi\Api4\IM;
 use Civi\Api4\Phone;
 use Civi\Api4\Address;
 use Civi\Api4\OpenID;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class IsPrimaryTest extends UnitTestCase {
+class IsPrimaryTest extends Api4TestBase implements TransactionalInterface {
 
   /**
    * Test that creating a location entity or deleting one re-assigns is_primary correctly.
index 3a36451d996aa5169289e626fdb30bffc5ad2060..04ea355c47bea2d4b1d3884ca52d8925f770a25c 100644 (file)
@@ -21,12 +21,13 @@ namespace api\v4\Action;
 
 use Civi\Api4\Activity;
 use Civi\Api4\Contact;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class NullValueTest extends UnitTestCase {
+class NullValueTest extends Api4TestBase implements TransactionalInterface {
 
   public function setUpHeadless() {
     $format = '{contact.first_name}{ }{contact.last_name}';
index 259e186d586b2505a0a39426aba329b261e4f113..f08e96583037ac5b724e88072d7271a36cadbed1 100644 (file)
 
 namespace api\v4\Action;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Activity;
 use Civi\Api4\RecentItem;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class RecentItemsTest extends UnitTestCase {
+class RecentItemsTest extends Api4TestBase implements TransactionalInterface {
 
   public function testAddDeleteActivity(): void {
     $cid = $this->createLoggedInUser();
index 87821656ea9d0013bb2e35685ce5aec0302c43a6..11784c43efa567231dc0849fe8524cbb8aed495f 100644 (file)
@@ -24,13 +24,14 @@ use Civi\Api4\CustomGroup;
 use Civi\Api4\CustomValue;
 use Civi\Api4\Email;
 use api\v4\Traits\TableDropperTrait;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Contact;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class ReplaceTest extends UnitTestCase {
+class ReplaceTest extends Api4TestBase implements TransactionalInterface {
   use TableDropperTrait;
 
   /**
index f3590c814c1d9a46fde7f8f0d4176737189551aa..f50623c33bde093276ff29017b19430875535333 100644 (file)
 namespace api\v4\Action;
 
 use Civi\Api4\Event;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class RequiredFieldTest extends UnitTestCase {
+class RequiredFieldTest extends Api4TestBase implements TransactionalInterface {
 
   public function testRequired() {
     $msg = '';
index 2a462f9f93aa459aa8ed528b72302c426c076917..6f107c49983eb354893a9fc885234ea0e2ea6178 100644 (file)
 namespace api\v4\Action;
 
 use Civi\Api4\Contact;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class ResultTest extends UnitTestCase {
+class ResultTest extends Api4TestBase implements TransactionalInterface {
 
   public function testJsonSerialize() {
     $result = Contact::getFields(FALSE)->addWhere('type', '=', 'Field')->execute();
index ccbc11841d0bbe98a2a502723b698318cd5dec0d..1f7297bcb5db1887ddde3036d6fa02ae855a9db6 100644 (file)
 
 namespace api\v4\Action;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Contact;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class SaveTest extends UnitTestCase {
+class SaveTest extends Api4TestBase implements TransactionalInterface {
 
   /**
    * @dataProvider getMatchingCriteriaDataProvider
index 402bb53ab3c89488d216f8e616b025a2507dd703..745000d392278e5289ac646fc312b2da34e57c8b 100644 (file)
 
 namespace api\v4\Action;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Contact;
 use Civi\Api4\Email;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class SqlExpressionTest extends UnitTestCase {
+class SqlExpressionTest extends Api4TestBase implements TransactionalInterface {
 
   public function testSelectNull() {
     Contact::create()->addValue('first_name', 'bob')->setCheckPermissions(FALSE)->execute();
index 3641a51a80c1359981e5f5ac2c21c18fe234033b..3fb5d18dc2d2b3a9a9bf6f24457294d9111de6e8 100644 (file)
 
 namespace api\v4\Action;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Activity;
 use Civi\Api4\Contact;
 use Civi\Api4\Contribution;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class SqlFunctionTest extends UnitTestCase {
+class SqlFunctionTest extends Api4TestBase implements TransactionalInterface {
 
   public function testGetFunctions() {
     $functions = array_column(\CRM_Api4_Page_Api4Explorer::getSqlFunctions(), NULL, 'name');
index d248e8ca9beb69a0b9e045b5c26d6d8b6cd4a7b6..651c23ea87cc32239cefda80fae5dbbbdb788c08 100644 (file)
 namespace api\v4\Action;
 
 use Civi\Api4\Contact;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * Class UpdateContactTest
  * @package api\v4\Action
  * @group headless
  */
-class UpdateContactTest extends UnitTestCase {
+class UpdateContactTest extends Api4TestBase implements TransactionalInterface {
 
   public function testUpdateWithIdInWhere() {
     $contactId = Contact::create(FALSE)
similarity index 98%
rename from tests/phpunit/api/v4/UnitTestCase.php
rename to tests/phpunit/api/v4/Api4TestBase.php
index 992550b1b4dff786221ceba66791f705f239a7e0..707889513359754b56554c2a60d6a338dd5e0d1b 100644 (file)
@@ -22,14 +22,13 @@ namespace api\v4;
 use api\v4\Traits\TestDataLoaderTrait;
 use Civi\Api4\UFMatch;
 use Civi\Test\HeadlessInterface;
-use Civi\Test\TransactionalInterface;
 
 require_once 'api/Exception.php';
 
 /**
  * @group headless
  */
-class UnitTestCase extends \PHPUnit\Framework\TestCase implements HeadlessInterface, TransactionalInterface {
+class Api4TestBase extends \PHPUnit\Framework\TestCase implements HeadlessInterface {
 
   use TestDataLoaderTrait;
 
similarity index 99%
rename from tests/phpunit/api/v4/Action/BasicCustomFieldTest.php
rename to tests/phpunit/api/v4/Custom/BasicCustomFieldTest.php
index 9285117d0d42358487682193481a825182f10fc2..33c53e9a5de523d2b67b7a001ada3fa9567c38ad 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 
-namespace api\v4\Action;
+namespace api\v4\Custom;
 
 use Civi\Api4\Contact;
 use Civi\Api4\CustomField;
@@ -31,7 +31,7 @@ use Civi\Api4\RelationshipCache;
 /**
  * @group headless
  */
-class BasicCustomFieldTest extends BaseCustomValueTest {
+class BasicCustomFieldTest extends CustomTestBase {
 
   public function tearDown(): void {
     FinancialType::delete(FALSE)
similarity index 93%
rename from tests/phpunit/api/v4/Entity/ContactCustomJoinTest.php
rename to tests/phpunit/api/v4/Custom/ContactCustomJoinTest.php
index 2a92ec0d3af04abd5bb2924fc2997a1145265d51..ccdc048b2a364ca44be647ecbe1cc8e732e4632d 100644 (file)
  */
 
 
-namespace api\v4\Entity;
+namespace api\v4\Custom;
 
 use Civi\Api4\Contact;
 use Civi\Api4\CustomGroup;
 use Civi\Api4\CustomField;
-use api\v4\Action\BaseCustomValueTest;
 
 /**
  * @group headless
  */
-class ContactCustomJoinTest extends BaseCustomValueTest {
+class ContactCustomJoinTest extends CustomTestBase {
 
   /**
    * Add test to ensure that in the very unusual and not really supported situation where there is a space in the
similarity index 96%
rename from tests/phpunit/api/v4/Utils/CoreUtilTest.php
rename to tests/phpunit/api/v4/Custom/CoreUtilTest.php
index 77c7b8412345065d98ed7ed3c4fd40be8380b1f0..93d4abfdd704130337ea648073b0260d9316cfc3 100644 (file)
@@ -17,9 +17,8 @@
  */
 
 
-namespace api\v4\Utils;
+namespace api\v4\Custom;
 
-use api\v4\UnitTestCase;
 use Civi\Api4\CustomField;
 use Civi\Api4\CustomGroup;
 use Civi\Api4\Utils\CoreUtil;
@@ -27,7 +26,7 @@ use Civi\Api4\Utils\CoreUtil;
 /**
  * @group headless
  */
-class CoreUtilTest extends UnitTestCase {
+class CoreUtilTest extends CustomTestBase {
 
   /**
    */
similarity index 97%
rename from tests/phpunit/api/v4/Action/CreateCustomValueTest.php
rename to tests/phpunit/api/v4/Custom/CreateCustomValueTest.php
index 2419625f0901030185a7a5f391f4ad28229a1909..4407e8ca1433a6d96c49edb49dc787b31baf21a5 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 
-namespace api\v4\Action;
+namespace api\v4\Custom;
 
 use Civi\Api4\CustomField;
 use Civi\Api4\CustomGroup;
@@ -28,7 +28,7 @@ use Civi\Api4\OptionValue;
 /**
  * @group headless
  */
-class CreateCustomValueTest extends BaseCustomValueTest {
+class CreateCustomValueTest extends CustomTestBase {
 
   public function testGetWithCustomData() {
     $optionValues = ['r' => 'Red', 'g' => 'Green', 'b' => 'Blue'];
similarity index 98%
rename from tests/phpunit/api/v4/Action/CreateWithOptionGroupTest.php
rename to tests/phpunit/api/v4/Custom/CreateWithOptionGroupTest.php
index 2f6d8f78e087680c5c99906023b18c856118a921..cee1b375a551c853ec89c651ddf2c1ec58faa9a2 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 
-namespace api\v4\Action;
+namespace api\v4\Custom;
 
 use Civi\Api4\CustomField;
 use Civi\Api4\CustomGroup;
@@ -26,7 +26,7 @@ use Civi\Api4\Contact;
 /**
  * @group headless
  */
-class CreateWithOptionGroupTest extends BaseCustomValueTest {
+class CreateWithOptionGroupTest extends CustomTestBase {
 
   public function testGetWithCustomData() {
     $group = uniqid('fava');
similarity index 98%
rename from tests/phpunit/api/v4/Action/CustomContactRefTest.php
rename to tests/phpunit/api/v4/Custom/CustomContactRefTest.php
index 5ca38ff0c6bfc9d7f0641363adb491aedde62ad3..4b42a84c004d8b8bfa8961ddc83345d5d5ee1b03 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 
-namespace api\v4\Action;
+namespace api\v4\Custom;
 
 use Civi\Api4\Contact;
 use Civi\Api4\CustomField;
@@ -26,7 +26,7 @@ use Civi\Api4\CustomGroup;
 /**
  * @group headless
  */
-class CustomContactRefTest extends BaseCustomValueTest {
+class CustomContactRefTest extends CustomTestBase {
 
   public function testGetWithJoin() {
     $firstName = uniqid('fav');
similarity index 98%
rename from tests/phpunit/api/v4/Action/CustomFieldAlterTest.php
rename to tests/phpunit/api/v4/Custom/CustomFieldAlterTest.php
index 76741ebf584bf4386f80ccc4b2a2fb0ea0ab140a..1faabe10be6873295f4cf954096af4fe1885a952 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 
-namespace api\v4\Action;
+namespace api\v4\Custom;
 
 use Civi\Api4\Activity;
 use Civi\Api4\CustomField;
@@ -26,7 +26,7 @@ use Civi\Api4\CustomGroup;
 /**
  * @group headless
  */
-class CustomFieldAlterTest extends BaseCustomValueTest {
+class CustomFieldAlterTest extends CustomTestBase {
 
   public function testChangeSerialize() {
     $contact = $this->createEntity(['type' => 'Individual']);
similarity index 99%
rename from tests/phpunit/api/v4/Action/CustomGroupACLTest.php
rename to tests/phpunit/api/v4/Custom/CustomGroupACLTest.php
index 6dec3a742bdce1ee1221abfdc6ff0fd779466f1f..2a74f408abdcda0e37f76f29ea7b34a1eccd33ad 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 
-namespace api\v4\Action;
+namespace api\v4\Custom;
 
 use Civi\Api4\ACL;
 use Civi\Api4\Contact;
@@ -28,7 +28,7 @@ use Civi\Api4\CustomValue;
 /**
  * @group headless
  */
-class CustomGroupACLTest extends BaseCustomValueTest {
+class CustomGroupACLTest extends CustomTestBase {
 
   public function tearDown(): void {
     parent::tearDown();
similarity index 70%
rename from tests/phpunit/api/v4/Action/BaseCustomValueTest.php
rename to tests/phpunit/api/v4/Custom/CustomTestBase.php
index 44c2fa51104d8cab5894f0151a291b199dda35ae..98bae9adc915f443ca4906e4e556b89831aa5330 100644 (file)
  */
 
 
-namespace api\v4\Action;
+namespace api\v4\Custom;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\CustomGroup;
 use Civi\Api4\CustomField;
 
-abstract class BaseCustomValueTest extends UnitTestCase {
+/**
+ * Use this base class for any APIv4 tests which create custom groups/fields,
+ * to ensure they get cleaned up properly.
+ *
+ * Note: The TransactionalInterface won't work with custom fields because of adding/dropping tables.
+ * So these tests have to do their own cleanup of any contacts or other entities created.
+ * The recommended way is to override the `tearDown` function and calling `parent::tearDown()`.
+ */
+abstract class CustomTestBase extends Api4TestBase {
 
   /**
    * Delete all created options groups.
similarity index 97%
rename from tests/phpunit/api/v4/Action/CustomValuePerformanceTest.php
rename to tests/phpunit/api/v4/Custom/CustomValuePerformanceTest.php
index b82c386d93910991356b2f3f886aba5d036398a4..18420db03805c9fa8fdea33c71a4218da272486c 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 
-namespace api\v4\Action;
+namespace api\v4\Custom;
 
 use Civi\Api4\Contact;
 use Civi\Api4\CustomField;
@@ -27,7 +27,7 @@ use api\v4\Traits\QueryCounterTrait;
 /**
  * @group headless
  */
-class CustomValuePerformanceTest extends BaseCustomValueTest {
+class CustomValuePerformanceTest extends CustomTestBase {
 
   use QueryCounterTrait;
 
similarity index 99%
rename from tests/phpunit/api/v4/Action/CustomValueTest.php
rename to tests/phpunit/api/v4/Custom/CustomValueTest.php
index f774d3acce8efd2e7fdc86e280ebdf1f3044e68c..a0931cce9438040804c1c80d5ed0a9f8f8170960 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 
-namespace api\v4\Action;
+namespace api\v4\Custom;
 
 use Civi\Api4\CustomField;
 use Civi\Api4\CustomGroup;
@@ -28,7 +28,7 @@ use Civi\Api4\Entity;
 /**
  * @group headless
  */
-class CustomValueTest extends BaseCustomValueTest {
+class CustomValueTest extends CustomTestBase {
 
   protected $contactID;
 
similarity index 95%
rename from tests/phpunit/api/v4/Action/ExtendFromIndividualTest.php
rename to tests/phpunit/api/v4/Custom/ExtendFromIndividualTest.php
index 9b573b13b5170e808feb3ef05955c55a52fb029f..2f7440cce6c9acb10c71165c688abef8b279fe04 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 
-namespace api\v4\Action;
+namespace api\v4\Custom;
 
 use Civi\Api4\Contact;
 use Civi\Api4\CustomField;
@@ -26,7 +26,7 @@ use Civi\Api4\CustomGroup;
 /**
  * @group headless
  */
-class ExtendFromIndividualTest extends BaseCustomValueTest {
+class ExtendFromIndividualTest extends CustomTestBase {
 
   public function testGetWithNonStandardExtends() {
 
similarity index 99%
rename from tests/phpunit/api/v4/Action/PseudoconstantTest.php
rename to tests/phpunit/api/v4/Custom/PseudoconstantTest.php
index a6c7960534100775293a479ca1fadb9437c7e6a5..8f006dfe66bb2fb9e94e1b7e55b167b301a91ff4 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 
-namespace api\v4\Action;
+namespace api\v4\Custom;
 
 use Civi\Api4\Address;
 use Civi\Api4\Campaign;
@@ -35,7 +35,7 @@ use Civi\Api4\Tag;
 /**
  * @group headless
  */
-class PseudoconstantTest extends BaseCustomValueTest {
+class PseudoconstantTest extends CustomTestBase {
 
   public function testOptionValue() {
     $cid = Contact::create(FALSE)->addValue('first_name', 'bill')->execute()->first()['id'];
similarity index 95%
rename from tests/phpunit/api/v4/Action/UpdateCustomValueTest.php
rename to tests/phpunit/api/v4/Custom/UpdateCustomValueTest.php
index 81fd5a7a7c24ccf8f005c940502905d8ff3fbccf..34c5b3dcdc7ec922aaac7be0973b9a98a7c5cd0c 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 
-namespace api\v4\Action;
+namespace api\v4\Custom;
 
 use Civi\Api4\Contact;
 use Civi\Api4\CustomField;
@@ -27,7 +27,7 @@ use CRM_Core_BAO_CustomValueTable as CustomValueTable;
 /**
  * @group headless
  */
-class UpdateCustomValueTest extends BaseCustomValueTest {
+class UpdateCustomValueTest extends CustomTestBase {
 
   public function testGetWithCustomData() {
 
index cf09b4e109c9bd217a85e49dc034f5ddfc11e717..c0a952ba3ddda5f8b7e22a425a78201caec6ff73 100644 (file)
@@ -19,7 +19,7 @@
 namespace api\v4\Entity;
 
 use Civi\Api4\Contact;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Activity;
 use Civi\Api4\ActivityContact;
 use Civi\Test\TransactionalInterface;
@@ -32,7 +32,7 @@ use Civi\Test\TransactionalInterface;
  *
  * @group headless
  */
-class ActivityTest extends UnitTestCase implements TransactionalInterface {
+class ActivityTest extends Api4TestBase implements TransactionalInterface {
 
   public function testActivityUpdate() {
 
index c3d8f839479b11467c40054a59204f5f278f64a7..19c21e40447249d5b06d20afc5fc72fada0d3c6b 100644 (file)
@@ -18,7 +18,7 @@
 
 namespace api\v4\Entity;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Address;
 use Civi\Api4\Contact;
 use Civi\Test\TransactionalInterface;
@@ -28,7 +28,7 @@ use Civi\Test\TransactionalInterface;
  *
  * @group headless
  */
-class AddressTest extends UnitTestCase implements TransactionalInterface {
+class AddressTest extends Api4TestBase implements TransactionalInterface {
 
   /**
    * Check that 2 addresses for the same contact can't both be primary
index b38f519c67380dc515e0a7f2c6d6e3d66f612def..ac92b4c3d022c9c1e83a0ffb2bc99475fb68cc4d 100644 (file)
 namespace api\v4\Entity;
 
 use Civi\Api4\CiviCase;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Relationship;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class CaseTest extends UnitTestCase {
+class CaseTest extends Api4TestBase implements TransactionalInterface {
 
   public function setUp(): void {
     parent::setUp();
index ae58ea64a1ccaa23dff0d11bfab75afe97061610..0525e01174b72355fefc68a983bcf8230b862c98 100644 (file)
@@ -26,7 +26,7 @@ use Civi\API\Exception\UnauthorizedException;
 use Civi\Api4\CustomField;
 use Civi\Api4\CustomGroup;
 use Civi\Api4\Entity;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Event\ValidateValuesEvent;
 use Civi\Api4\Service\Spec\CustomFieldSpec;
 use Civi\Api4\Service\Spec\FieldSpec;
@@ -35,11 +35,12 @@ use Civi\Api4\Utils\CoreUtil;
 use Civi\Core\Event\PostEvent;
 use Civi\Core\Event\PreEvent;
 use Civi\Test\HookInterface;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class ConformanceTest extends UnitTestCase implements HookInterface {
+class ConformanceTest extends Api4TestBase implements HookInterface, TransactionalInterface {
 
   use CheckAccessTrait;
   use TableDropperTrait;
index ca10c63603d90165054ff431c69afdd1c5fbc7fe..a54ba17a33d5f1a3cb27a52ef8baab7148c0248f 100644 (file)
@@ -20,7 +20,7 @@ namespace api\v4\Entity;
 
 use Civi\Api4\ActivityContact;
 use Civi\Api4\Contact;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Test\TransactionalInterface;
 
 /**
@@ -29,7 +29,7 @@ use Civi\Test\TransactionalInterface;
  *
  * @group headless
  */
-class ContactInterchangeTest extends UnitTestCase implements TransactionalInterface {
+class ContactInterchangeTest extends Api4TestBase implements TransactionalInterface {
 
   public function getExamples() {
     $apiWriters = [
index e185e7f4fdbae3a94ad202f872c9605dffd0e359..a2adafbb0d5141553bef19758fb8a2e684dbaee1 100644 (file)
@@ -21,12 +21,13 @@ namespace api\v4\Entity;
 
 use Civi\Api4\Contact;
 use Civi\Api4\OptionValue;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class ContactJoinTest extends UnitTestCase {
+class ContactJoinTest extends Api4TestBase implements TransactionalInterface {
 
   public function setUpHeadless() {
     $relatedTables = [
index 0abe38daba81c9839ec1896a62affac50888e787..a339b25b05a9a12174b985d2cbf1a568b587d779 100644 (file)
@@ -20,7 +20,7 @@
 namespace api\v4\Entity;
 
 use Civi\Api4\Contact;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\ContactType;
 use Civi\Api4\Email;
 use Civi\Api4\Navigation;
@@ -29,7 +29,7 @@ use Civi\Test\TransactionalInterface;
 /**
  * @group headless
  */
-class ContactTypeTest extends UnitTestCase implements TransactionalInterface {
+class ContactTypeTest extends Api4TestBase implements TransactionalInterface {
 
   public function testMenuItemWillBeCreatedAndDeleted() {
     ContactType::create(FALSE)
index 46ee3cc7515381da3af8e2325fc3b8ecebf3c83d..09acf2d066fb7c3729814a3efe99473f7fcd6085 100644 (file)
 
 namespace api\v4\Entity;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Domain;
 use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class DomainTest extends UnitTestCase implements TransactionalInterface {
+class DomainTest extends Api4TestBase implements TransactionalInterface {
 
   public function testActiveDomain() {
     Domain::create(FALSE)
index 06139637f2e60a48bf9903d196870f1ad8d226d9..fa93ddbeba16b8ab3f0d29b0f97e8d8c538c59ba 100644 (file)
@@ -21,12 +21,13 @@ namespace api\v4\Entity;
 
 use Civi\API\Exception\NotImplementedException;
 use Civi\Api4\Entity;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class EntityTest extends UnitTestCase {
+class EntityTest extends Api4TestBase implements TransactionalInterface {
 
   public function testEntityGet() {
     \CRM_Core_BAO_ConfigSetting::enableComponent('CiviEvent');
index 8f71f57240fec7b7457cbe49e8352cf35c17ff2f..682a25352b02b4a9ec83c40772b19e3ebfc17936 100644 (file)
 
 namespace api\v4\Entity;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class ExampleDataTest extends UnitTestCase {
+class ExampleDataTest extends Api4TestBase implements TransactionalInterface {
 
   /**
    * Basic canary test fetching a specific example.
index bfd626acc1956ce81d6420bec661cc5a505348e5..1619e544a6a8f0a39d54c54b8a186ee725083684 100644 (file)
 
 namespace api\v4\Entity;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Extension;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class ExtensionTest extends UnitTestCase {
+class ExtensionTest extends Api4TestBase implements TransactionalInterface {
 
   public function testGet() {
     $moduleTest = Extension::get(FALSE)
index 0824e249574e8809b27ae4360d939e80fd7e9523..1b97a61ce0c3fe03856f646a71ed3e702ea0b8ea 100644 (file)
 
 namespace api\v4\Entity;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\GroupContact;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class GroupContactTest extends UnitTestCase {
+class GroupContactTest extends Api4TestBase implements TransactionalInterface {
 
   public function testCreate() {
     $contact = $this->createEntity(['type' => 'Individual']);
index 5154cfd0f44acea1248ce923260641d1464009a1..eeb3e687efc634b2b43a4cd697c882a399d548b8 100644 (file)
@@ -18,7 +18,7 @@
 
 namespace api\v4\Entity;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Domain;
 use Civi\Api4\Group;
 use Civi\Api4\Managed;
@@ -32,7 +32,7 @@ use Civi\Test\TransactionalInterface;
 /**
  * @group headless
  */
-class ManagedEntityTest extends UnitTestCase implements TransactionalInterface, HookInterface {
+class ManagedEntityTest extends Api4TestBase implements TransactionalInterface, HookInterface {
   /**
    * @var array[]
    */
index 5355d55ad53ab64bfb44b8d86274b79b73f4e941..b353e1ecbf07d9958ea8d9f6cac4db62365df0c3 100644 (file)
@@ -18,7 +18,7 @@
 
 namespace api\v4\Entity;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Contact;
 use Civi\Api4\Domain;
 use Civi\Api4\MembershipType;
@@ -27,7 +27,7 @@ use Civi\Test\TransactionalInterface;
 /**
  * @group headless
  */
-class MembershipTest extends UnitTestCase implements TransactionalInterface {
+class MembershipTest extends Api4TestBase implements TransactionalInterface {
 
   public function testUpdateWeights() {
     $getValues = function($domain) {
index 485865b2a4e71bc3024ba6455a2ac5ef7aa84931..5e399a991b31e1a997bd76a6b5e73d0b0822ec15 100644 (file)
@@ -18,7 +18,7 @@
 
 namespace api\v4\Entity;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Test\DbTestTrait;
 use Civi\Test\GenericAssertionsTrait;
 use Civi\Test\TransactionalInterface;
@@ -26,7 +26,7 @@ use Civi\Test\TransactionalInterface;
 /**
  * @group headless
  */
-class MessageTemplateTest extends UnitTestCase implements TransactionalInterface {
+class MessageTemplateTest extends Api4TestBase implements TransactionalInterface {
 
   use GenericAssertionsTrait;
   use DbTestTrait;
index a3a502f17558d1f6912a329a2b0f89d990bd0949..390276f836af6573f46d06602d5327eb69b3ff88 100644 (file)
 
 namespace api\v4\Entity;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Navigation;
 use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class NavigationTest extends UnitTestCase implements TransactionalInterface {
+class NavigationTest extends Api4TestBase implements TransactionalInterface {
 
   public function testCreate() {
     $created = Navigation::create(FALSE)
index 89eef7b83592de868557341e508c0ae37379899d..212a481f50fba1ad14100f49938889f59a2c6f64 100644 (file)
 
 namespace api\v4\Entity;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Note;
 use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class NoteTest extends UnitTestCase implements TransactionalInterface {
+class NoteTest extends Api4TestBase implements TransactionalInterface {
 
   public function testDeleteWithChildren() {
     $c1 = $this->createEntity(['type' => 'Individual']);
index b8761ee2a784e1274e041c1905d23cdcfb4e5ed4..3bc4001886220cd6db1780a3e869972c1f1abf47 100644 (file)
@@ -18,7 +18,7 @@
 
 namespace api\v4\Entity;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\OptionGroup;
 use Civi\Api4\OptionValue;
 use Civi\Test\TransactionalInterface;
@@ -26,7 +26,7 @@ use Civi\Test\TransactionalInterface;
 /**
  * @group headless
  */
-class OptionValueTest extends UnitTestCase implements TransactionalInterface {
+class OptionValueTest extends Api4TestBase implements TransactionalInterface {
 
   public function testNullDefault() {
     OptionGroup::create(FALSE)
index 3de8b5bb4016f0876ca8d48b596d9837e05a1c7e..7ff67408429ec7239f9b2efcb88210c4c101baaf 100644 (file)
 namespace api\v4\Entity;
 
 use Civi\Api4\Participant;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class ParticipantTest extends UnitTestCase {
+class ParticipantTest extends Api4TestBase implements TransactionalInterface {
 
   public function setUp(): void {
     parent::setUp();
index fd146a15f964feb7f9f9269ea1e8edfb62979fbd..66856dbdb5b366cc92218c121a71133440c68acd 100644 (file)
@@ -18,7 +18,7 @@
 
 namespace api\v4\Entity;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\RecentItem;
 use Civi\Api4\Contact;
 use Civi\Test\TransactionalInterface;
@@ -28,7 +28,7 @@ use Civi\Test\TransactionalInterface;
  *
  * @group headless
  */
-class RecentItemTest extends UnitTestCase implements TransactionalInterface {
+class RecentItemTest extends Api4TestBase implements TransactionalInterface {
 
   /**
    *
index ef42074f665e825a31892660657b6b53cc55694c..635dc0e468c3870ae314cdb02b8397238c24e7b4 100644 (file)
@@ -19,7 +19,7 @@
 namespace api\v4\Entity;
 
 use Civi\Api4\Contact;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Relationship;
 use Civi\Api4\RelationshipCache;
 use Civi\Test\TransactionalInterface;
@@ -30,7 +30,7 @@ use Civi\Test\TransactionalInterface;
  *
  * @group headless
  */
-class RelationshipTest extends UnitTestCase implements TransactionalInterface {
+class RelationshipTest extends Api4TestBase implements TransactionalInterface {
 
   public function testRelCacheCount() {
     $c1 = Contact::create(FALSE)->addValue('first_name', '1')->execute()->first()['id'];
index 1ef73990508da803edadefb8e6237af190f725fb..1f2d2c121d553d8618e333f4852a851d00ddb041 100644 (file)
 namespace api\v4\Entity;
 
 use Civi\Api4\Route;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 
 /**
  * @group headless
  */
-class RouteTest extends UnitTestCase {
+class RouteTest extends Api4TestBase {
 
   public function testGet() {
     $result = Route::get()->addWhere('path', '=', 'civicrm/admin')->execute();
index 072c5a0fac31459df90a98582cba8ada645e1f4c..e682900bbb66336fed388a3b713aa58dd67a4532 100644 (file)
 
 namespace api\v4\Entity;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Contact;
 use Civi\Api4\Email;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class SavedSearchTest extends UnitTestCase {
+class SavedSearchTest extends Api4TestBase implements TransactionalInterface {
 
   /**
    * @throws \API_Exception
index e0daa11f1d4e3220ae05cba8e814b5c6a00633de..ab804645fd9ed59a2fd91b50de87b424ea420903 100644 (file)
 namespace api\v4\Entity;
 
 use Civi\Api4\Setting;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class SettingTest extends UnitTestCase {
+class SettingTest extends Api4TestBase implements TransactionalInterface {
 
   public function testSettingASetting() {
     $setting = Setting::set()->addValue('menubar_position', 'above-crm-container')->setCheckPermissions(FALSE)->execute()->first();
index 95785071a5728cda7875b2d95332a3e5b91899e6..0c62c720a9d7e075022f964c1ce0356b41b7e8f5 100644 (file)
 
 namespace api\v4\Entity;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Crypto\CryptoTestTrait;
+use Civi\Test\TransactionalInterface;
 use Psr\Log\LoggerInterface;
 
 /**
  * @group headless
  */
-class RotateKeyTest extends UnitTestCase {
+class RotateKeyTest extends Api4TestBase implements TransactionalInterface {
 
   use CryptoTestTrait;
 
index 435c7cb98f37c088ff4f9c9bc964cd9074553ec7..3333a78e52905f2da1103c81d4354de6fa48206e 100644 (file)
@@ -22,12 +22,13 @@ namespace api\v4\Entity;
 use Civi\Api4\Setting;
 use Civi\Api4\StatusPreference;
 use Civi\Api4\System;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class SystemTest extends UnitTestCase {
+class SystemTest extends Api4TestBase implements TransactionalInterface {
 
   public function testSystemCheck() {
     $origEnv = \CRM_Core_Config::environment();
index ac2f7bce2e03bf15fa2263bb3724a7f6e3f9e999..7aed01ce713ab1c1d1d75ca241d86c94db10efe3 100644 (file)
@@ -19,7 +19,7 @@
 namespace api\v4\Entity;
 
 use Civi\Api4\Contact;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\EntityTag;
 use Civi\Api4\Tag;
 use Civi\Test\TransactionalInterface;
@@ -27,7 +27,7 @@ use Civi\Test\TransactionalInterface;
 /**
  * @group headless
  */
-class TagTest extends UnitTestCase implements TransactionalInterface {
+class TagTest extends Api4TestBase implements TransactionalInterface {
 
   public function testTagFilter() {
     $conTag = Tag::create(FALSE)
index 730d00d3d5c296d7bf75773409c7164957d97492..6fc707e9615f6cf2d78ed4a256b5d3bd0dacd1ca 100644 (file)
 
 namespace api\v4\Entity;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class TranslationTest extends UnitTestCase {
+class TranslationTest extends Api4TestBase implements TransactionalInterface {
 
   protected $ids = [];
 
index 3cc1a835010f9e5fa9189cd1e7c3330dc1740647..ab1aab3db2df31b971c7d38adddb8deab25f57e7 100644 (file)
@@ -19,7 +19,7 @@
 namespace api\v4\Entity;
 
 use Civi\Api4\Contact;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Event\ValidateValuesEvent;
 use Civi\Test\TransactionalInterface;
 
@@ -28,7 +28,7 @@ use Civi\Test\TransactionalInterface;
  *
  * @group headless
  */
-class ValidateValuesTest extends UnitTestCase implements TransactionalInterface {
+class ValidateValuesTest extends Api4TestBase implements TransactionalInterface {
 
   private $lastValidator;
 
index 5f493c9f4f0c118e2918c6cd2d81f067da5ed53a..5bffeeaa77f9ebfce89a42b95e13d4ec65e3288d 100644 (file)
 
 namespace api\v4\Entity;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class WordReplacementTest extends UnitTestCase {
+class WordReplacementTest extends Api4TestBase implements TransactionalInterface {
 
   public function testDefaults() {
     $create = \Civi\Api4\WordReplacement::create(FALSE)
index 4560aea934285b219b92371b073ab250d93926bc..a8b7377b01a7ea13f0a15be0dfe01f2c6fb4828c 100644 (file)
 
 namespace api\v4\Entity;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\WorkflowMessage;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class WorkflowMessageTest extends UnitTestCase {
+class WorkflowMessageTest extends Api4TestBase implements TransactionalInterface {
 
   public function testGet() {
     $result = \Civi\Api4\WorkflowMessage::get(0)
index a27eaf57afc19feafaf5632dea26888a318aa404..a47b022ff50eb736b53a115852b90db423fc7dc4 100644 (file)
@@ -21,12 +21,13 @@ namespace api\v4\Query;
 
 use Civi\API\Request;
 use Civi\Api4\Query\Api4SelectQuery;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class Api4SelectQueryTest extends UnitTestCase {
+class Api4SelectQueryTest extends Api4TestBase implements TransactionalInterface {
 
   public function setUpHeadless() {
     $relatedTables = [
index 154ac0faa6b4dc405b1e3ff049977ab4b83e885a..a1601e7d713b0fbaba74bdea11dfabff5b4304ab 100644 (file)
 namespace api\v4\Query;
 
 use Civi\Api4\Contact;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * Class OneToOneJoinTest
  * @package api\v4\Query
  * @group headless
  */
-class OneToOneJoinTest extends UnitTestCase {
+class OneToOneJoinTest extends Api4TestBase implements TransactionalInterface {
 
   public function testOneToOneJoin() {
     $armenianContact = Contact::create()
index f7bc096353a79521128139aa7895eae509bb6933..0c8161617da73a32f684e1935f5528869621aa81 100644 (file)
 namespace api\v4\Query;
 
 use Civi\Api4\Query\Api4SelectQuery;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class OptionValueJoinTest extends UnitTestCase {
+class OptionValueJoinTest extends Api4TestBase implements TransactionalInterface {
 
   public function setUpHeadless() {
     $relatedTables = [
index 872113b008c2955df4570212bb66daaf11cf281d..3935f4c0d57bb0e1847ed783aee1f26838ab1822 100644 (file)
 
 namespace api\v4\Query;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\API\Exception\UnauthorizedException;
 use Civi\Api4\Contact;
 use Civi\Api4\Event;
 use Civi\Api4\Participant;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class PermissionCheckTest extends UnitTestCase {
+class PermissionCheckTest extends Api4TestBase implements TransactionalInterface {
 
   /**
    * Clean up after test.
index ee604db363315fe185c0534af34cb9179ccc9140..73fdb03ccfb73d99df02d4a1f26daf412cc73941 100644 (file)
 namespace api\v4\Query;
 
 use Civi\Api4\Email;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * Class SelectQueryMultiJoinTest
  * @package api\v4\Query
  * @group headless
  */
-class SelectQueryMultiJoinTest extends UnitTestCase {
+class SelectQueryMultiJoinTest extends Api4TestBase implements TransactionalInterface {
 
   public function setUpHeadless() {
     $this->cleanup(['tablesToTruncate' => ['civicrm_contact', 'civicrm_email']]);
index 7bc8c59e4bc5017ad103ce9c3d563b009fda4f15..afdefcbace8a893c6a08e83a405d3314f43bc456 100644 (file)
 
 namespace api\v4\Query;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Query\SqlExpression;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class SqlExpressionParserTest extends UnitTestCase {
+class SqlExpressionParserTest extends Api4TestBase implements TransactionalInterface {
 
   public function aggregateFunctions() {
     return [
index 8082d5901860e913b2164e47d10f08a367e7b2be..84406ebe2d0cd7c58883de44101e36011c446cf1 100644 (file)
@@ -22,12 +22,13 @@ namespace api\v4\Service\Schema;
 use Civi\Api4\Service\Schema\Joinable\Joinable;
 use Civi\Api4\Service\Schema\SchemaMap;
 use Civi\Api4\Service\Schema\Table;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
+use Civi\Test\TransactionalInterface;
 
 /**
  * @group headless
  */
-class SchemaMapperTest extends UnitTestCase {
+class SchemaMapperTest extends Api4TestBase implements TransactionalInterface {
 
   public function testWillHaveNoPathWithNoTables() {
     $map = new SchemaMap();
index 78fa3d4502f47f99a238461331e235d1e0ca9ab9..0f8e940ce4389744eea809923d37a7ca2df3135b 100644 (file)
@@ -21,12 +21,12 @@ namespace api\v4\Spec;
 
 use Civi\Api4\Service\Spec\FieldSpec;
 use Civi\Api4\Service\Spec\RequestSpec;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 
 /**
  * @group headless
  */
-class RequestSpecTest extends UnitTestCase {
+class RequestSpecTest extends Api4TestBase {
 
   public function testRequiredFieldFetching() {
     $spec = new RequestSpec('Contact', 'get');
index b6557571cbe8ac8972f618bb6b62df03408ca394..d5d46f65947530903fbbacd212a132e0b7b813c9 100644 (file)
@@ -21,12 +21,12 @@ namespace api\v4\Spec;
 
 use Civi\Api4\Service\Spec\CustomFieldSpec;
 use Civi\Api4\Service\Spec\SpecFormatter;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 
 /**
  * @group headless
  */
-class SpecFormatterTest extends UnitTestCase {
+class SpecFormatterTest extends Api4TestBase {
 
   /**
    * @dataProvider arrayFieldSpecProvider
index 5fa6a7e71ccb1edd1b3fce402309c002d4f55891..9544b081c09bb38a8993bf70d9e4893cfd2f2a00 100644 (file)
@@ -23,7 +23,7 @@ use Civi\Api4\Service\Spec\FieldSpec;
 use Civi\Api4\Service\Spec\Provider\Generic\SpecProviderInterface;
 use Civi\Api4\Service\Spec\SpecGatherer;
 use api\v4\Traits\OptionCleanupTrait;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\CustomField;
 use Civi\Api4\CustomGroup;
 use api\v4\Traits\TableDropperTrait;
@@ -32,7 +32,7 @@ use Prophecy\Argument;
 /**
  * @group headless
  */
-class SpecGathererTest extends UnitTestCase {
+class SpecGathererTest extends Api4TestBase {
 
   use TableDropperTrait;
   use OptionCleanupTrait;
index 60631babc4fa4d6818f323612b64fc73b35d877e..ee9c86aa0aabd06af25c9012eb039de1838d228b 100644 (file)
 namespace api\v4\Utils;
 
 use Civi\Api4\Utils\ArrayInsertionUtil;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 
 /**
  * @group headless
  */
-class ArrayInsertionServiceTest extends UnitTestCase {
+class ArrayInsertionServiceTest extends Api4TestBase {
 
   public function testInsertWillWork() {
     $arr = [];
index bd6d218a6d784c074ee52b24649b2a4d4e796961..0f87b964f64d93bf999c1855ce10dbec292830c9 100644 (file)
@@ -21,12 +21,12 @@ namespace api\v4\Utils;
 
 use Civi\Api4\Utils\ReflectionUtils;
 use api\v4\Mock\MockV4ReflectionGrandchild;
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 
 /**
  * @group headless
  */
-class ReflectionUtilsTest extends UnitTestCase {
+class ReflectionUtilsTest extends Api4TestBase {
 
   /**
    * Test that class annotations are returned across @inheritDoc
index a5f173ed3a13d2bc7722886b7aca6a1ddb1fd526..3f955b7f1aa1bae2429acb7bd90596e528554d09 100644 (file)
 
 namespace api\v4\Utils;
 
-use api\v4\UnitTestCase;
+use api\v4\Api4TestBase;
 use Civi\Api4\Utils\SelectUtil;
 
 /**
  * @group headless
  */
-class SelectUtilTest extends UnitTestCase {
+class SelectUtilTest extends Api4TestBase {
 
   private $emailFieldNames = [
     'id',