From 01542df42ec14b711b961922eff83eab2a99cca8 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sat, 9 Feb 2019 16:26:34 -0500 Subject: [PATCH] AfformTestCase - Extract base for more tests --- .../mock/tests/phpunit/api/v4/AfformTest.php | 29 +------------- .../tests/phpunit/api/v4/AfformTestCase.php | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 28 deletions(-) create mode 100644 ext/afform/mock/tests/phpunit/api/v4/AfformTestCase.php diff --git a/ext/afform/mock/tests/phpunit/api/v4/AfformTest.php b/ext/afform/mock/tests/phpunit/api/v4/AfformTest.php index 97d7da937e..dcf29cca61 100644 --- a/ext/afform/mock/tests/phpunit/api/v4/AfformTest.php +++ b/ext/afform/mock/tests/phpunit/api/v4/AfformTest.php @@ -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 index 0000000000..94f16b8f91 --- /dev/null +++ b/ext/afform/mock/tests/phpunit/api/v4/AfformTestCase.php @@ -0,0 +1,38 @@ +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(); + } + +} -- 2.25.1