AfformTestCase - Extract base for more tests
authorTim Otten <totten@civicrm.org>
Sat, 9 Feb 2019 21:26:34 +0000 (16:26 -0500)
committerCiviCRM <info@civicrm.org>
Wed, 16 Sep 2020 02:13:17 +0000 (19:13 -0700)
ext/afform/mock/tests/phpunit/api/v4/AfformTest.php
ext/afform/mock/tests/phpunit/api/v4/AfformTestCase.php [new file with mode: 0644]

index 97d7da937e94c4cc0e61565e09430813563f5581..dcf29cca611522b0dbba20bf9642f5f9fd926618 100644 (file)
@@ -8,34 +8,7 @@ use Civi\Test\TransactionalInterface;
  * This is a generic test class implemented with PHPUnit.
  * @group headless
  */
-class api_v4_AfformTest extends \PHPUnit_Framework_TestCase implements HeadlessInterface, TransactionalInterface {
-
-  /**
-   * Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile().
-   * See: https://github.com/civicrm/org.civicrm.testapalooza/blob/master/civi-test.md
-   */
-  public function setUpHeadless() {
-    return \Civi\Test::headless()
-      ->install(['org.civicrm.api4', 'org.civicrm.afform', 'org.civicrm.afform-mock'])
-      ->apply();
-  }
-
-  /**
-   * The setup() method is executed before the test is executed (optional).
-   */
-  public function setUp() {
-    parent::setUp();
-    CRM_Core_Config::singleton()->userPermissionTemp = new CRM_Core_Permission_Temp();
-    CRM_Core_Config::singleton()->userPermissionTemp->grant('administer CiviCRM');
-  }
-
-  /**
-   * The tearDown() method is executed after the test was executed (optional)
-   * This can be used for cleanup.
-   */
-  public function tearDown() {
-    parent::tearDown();
-  }
+class api_v4_AfformTest extends api_v4_AfformTestCase {
 
   public function getBasicDirectives() {
     return [
diff --git a/ext/afform/mock/tests/phpunit/api/v4/AfformTestCase.php b/ext/afform/mock/tests/phpunit/api/v4/AfformTestCase.php
new file mode 100644 (file)
index 0000000..94f16b8
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+
+use Civi\Test\HeadlessInterface;
+use Civi\Test\TransactionalInterface;
+
+/**
+ * Base class for Afform API tests.
+ */
+abstract class api_v4_AfformTestCase extends \PHPUnit_Framework_TestCase implements HeadlessInterface, TransactionalInterface {
+
+  /**
+   * Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile().
+   * See: https://github.com/civicrm/org.civicrm.testapalooza/blob/master/civi-test.md
+   */
+  public function setUpHeadless() {
+    return \Civi\Test::headless()
+      ->install(['org.civicrm.api4', 'org.civicrm.afform', 'org.civicrm.afform-mock'])
+      ->apply();
+  }
+
+  /**
+   * The setup() method is executed before the test is executed (optional).
+   */
+  public function setUp() {
+    parent::setUp();
+    CRM_Core_Config::singleton()->userPermissionTemp = new CRM_Core_Permission_Temp();
+    CRM_Core_Config::singleton()->userPermissionTemp->grant('administer CiviCRM');
+  }
+
+  /**
+   * The tearDown() method is executed after the test was executed (optional)
+   * This can be used for cleanup.
+   */
+  public function tearDown() {
+    parent::tearDown();
+  }
+
+}