From ab6a83ea9635ffed6305dccb28562a98f5b26f92 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 18 Jan 2023 23:49:25 -0800 Subject: [PATCH] (NFC) Mixin Tests - Add more typehints --- mixin/case-xml@1/example/tests/mixin/CaseTypeTest.php | 8 ++++---- .../example/tests/mixin/EntityTypesTest.php | 8 ++++---- mixin/menu-xml@1/example/tests/mixin/MenuXmlTest.php | 8 ++++---- .../mgd-php@1/example/tests/mixin/ManagedCaseTypeTest.php | 8 ++++---- mixin/mgd-php@1/example/tests/mixin/ManagedTest.php | 8 ++++---- .../example/tests/mixin/ScanClassesTest.php | 8 ++++---- mixin/setting-php@1/example/tests/mixin/SettingsTest.php | 8 ++++---- .../shimmy/tests/phpunit/E2E/Shimmy/LifecycleTest.php | 2 +- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/mixin/case-xml@1/example/tests/mixin/CaseTypeTest.php b/mixin/case-xml@1/example/tests/mixin/CaseTypeTest.php index 099a364d3b..1ea01841b5 100644 --- a/mixin/case-xml@1/example/tests/mixin/CaseTypeTest.php +++ b/mixin/case-xml@1/example/tests/mixin/CaseTypeTest.php @@ -12,11 +12,11 @@ namespace Civi\Shimmy\Mixins; */ class CaseTypeTest extends \PHPUnit\Framework\Assert { - public function testPreConditions($cv) { + public function testPreConditions($cv): void { $this->assertFileExists(static::getPath('/xml/case/DuckDance.xml'), 'The shimmy extension must have a Case XML file.'); } - public function testInstalled($cv) { + public function testInstalled($cv): void { $items = $cv->api4('CaseType', 'get', ['where' => [['name', '=', 'DuckDance']]]); $this->assertEquals('The mysterious case of the dancing duck', $items[0]['description']); $this->assertEquals('DuckDance', $items[0]['name']); @@ -35,7 +35,7 @@ class CaseTypeTest extends \PHPUnit\Framework\Assert { $this->assertEquals(TRUE, $actTypes[0]['is_active'], 'ActivityType "Quack" should be auto enabled. It\'s inactive.'); } - public function testDisabled($cv) { + public function testDisabled($cv): void { $items = $cv->api4('CaseType', 'get', ['where' => [['name', '=', 'DuckDance']]]); $this->assertEquals('The mysterious case of the dancing duck', $items[0]['description']); $this->assertEquals('DuckDance', $items[0]['name']); @@ -44,7 +44,7 @@ class CaseTypeTest extends \PHPUnit\Framework\Assert { $this->assertEquals(1, count($items)); } - public function testUninstalled($cv) { + public function testUninstalled($cv): void { $items = $cv->api4('CaseType', 'get', ['where' => [['name', '=', 'DuckDance']]]); $this->assertEquals(0, count($items)); diff --git a/mixin/entity-types-php@1/example/tests/mixin/EntityTypesTest.php b/mixin/entity-types-php@1/example/tests/mixin/EntityTypesTest.php index b8e3cc3595..a6013c8a9d 100644 --- a/mixin/entity-types-php@1/example/tests/mixin/EntityTypesTest.php +++ b/mixin/entity-types-php@1/example/tests/mixin/EntityTypesTest.php @@ -18,26 +18,26 @@ class EntityTypesTest extends \PHPUnit\Framework\Assert { const EXAMPLE_NAME = 'ShimThing'; - public function testPreConditions($cv) { + public function testPreConditions($cv): void { $this->assertFileExists(static::getPath('/xml/schema/CRM/Shimmy/ShimThing.xml'), 'The shimmy extension must have *.xml.'); $this->assertFileExists(static::getPath('/xml/schema/CRM/Shimmy/ShimThing.entityType.php'), 'The shimmy extension must have *.entityTYpe.php.'); $this->assertFileExists(static::getPath('/CRM/Shimmy/DAO/ShimThing.php'), 'The shimmy extension must have DAO.'); } - public function testInstalled($cv) { + public function testInstalled($cv): void { $this->assertEquals(self::EXAMPLE_NAME, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getBriefName', [self::EXAMPLE_DAO])); $this->assertEquals(self::EXAMPLE_TABLE, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getTableForClass', [self::EXAMPLE_DAO])); $this->assertEquals(self::EXAMPLE_NAME, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getEntityNameForTable', [self::EXAMPLE_TABLE])); $this->assertEquals('ShimThing ID', $cv->phpEval('return \CRM_Shimmy_DAO_ShimThing::fields()["id"]["title"];')); } - public function testDisabled($cv) { + public function testDisabled($cv): void { $this->assertEquals(NULL, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getBriefName', [self::EXAMPLE_DAO])); $this->assertEquals(NULL, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getTableForClass', [self::EXAMPLE_DAO])); $this->assertEquals(NULL, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getEntityNameForTable', [self::EXAMPLE_TABLE])); } - public function testUninstalled($cv) { + public function testUninstalled($cv): void { $this->assertEquals(NULL, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getBriefName', [self::EXAMPLE_DAO])); $this->assertEquals(NULL, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getTableForClass', [self::EXAMPLE_DAO])); $this->assertEquals(NULL, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getEntityNameForTable', [self::EXAMPLE_TABLE])); diff --git a/mixin/menu-xml@1/example/tests/mixin/MenuXmlTest.php b/mixin/menu-xml@1/example/tests/mixin/MenuXmlTest.php index fc56b83969..c3878c946b 100644 --- a/mixin/menu-xml@1/example/tests/mixin/MenuXmlTest.php +++ b/mixin/menu-xml@1/example/tests/mixin/MenuXmlTest.php @@ -18,11 +18,11 @@ class MenuXmlTest extends \PHPUnit\Framework\Assert { */ protected $url; - public function testPreConditions($cv) { + public function testPreConditions($cv): void { $this->assertFileExists(static::getPath('/xml/Menu/shimmy.xml'), 'The shimmy extension must have a Menu XML file.'); } - public function testInstalled($cv) { + public function testInstalled($cv): void { // The menu item is registered... $items = $cv->api4('Route', 'get', ['where' => [['path', '=', 'civicrm/shimmy/foobar']]]); $this->assertEquals('CRM_Shimmy_Page_FooBar', $items[0]['page_callback']); @@ -34,7 +34,7 @@ class MenuXmlTest extends \PHPUnit\Framework\Assert { $this->assertRegExp(';hello world;', $response); } - public function testDisabled($cv) { + public function testDisabled($cv): void { $items = $cv->api4('Route', 'get', ['where' => [['path', '=', 'civicrm/shimmy/foobar']]]); $this->assertEmpty($items); @@ -44,7 +44,7 @@ class MenuXmlTest extends \PHPUnit\Framework\Assert { $this->assertNotRegExp(';HTTP.*200.*;', $http_response_header[0]); } - public function testUninstalled($cv) { + public function testUninstalled($cv): void { // Same as disabled. $this->testDisabled($cv); } diff --git a/mixin/mgd-php@1/example/tests/mixin/ManagedCaseTypeTest.php b/mixin/mgd-php@1/example/tests/mixin/ManagedCaseTypeTest.php index 270a5faf7a..9137c5a272 100644 --- a/mixin/mgd-php@1/example/tests/mixin/ManagedCaseTypeTest.php +++ b/mixin/mgd-php@1/example/tests/mixin/ManagedCaseTypeTest.php @@ -12,11 +12,11 @@ namespace Civi\Shimmy\Mixins; */ class ManagedCaseTypeTest extends \PHPUnit\Framework\Assert { - public function testPreConditions($cv) { + public function testPreConditions($cv): void { $this->assertFileExists(static::getPath('/CRM/BunnyDance.mgd.php'), 'The shimmy extension must have a Case MGD file.'); } - public function testInstalled($cv) { + public function testInstalled($cv): void { $items = $cv->api4('CaseType', 'get', ['where' => [['name', '=', 'BunnyDance']]]); $this->assertEquals('The mysterious case of the dancing bunny', $items[0]['description']); $this->assertEquals('BunnyDance', $items[0]['name']); @@ -33,7 +33,7 @@ class ManagedCaseTypeTest extends \PHPUnit\Framework\Assert { // $this->assertEquals(TRUE, $actTypes[0]['is_active'], 'ActivityType "Nibble" should be auto enabled. It\'s inactive.'); } - public function testDisabled($cv) { + public function testDisabled($cv): void { $items = $cv->api4('CaseType', 'get', ['where' => [['name', '=', 'BunnyDance']]]); $this->assertEquals('The mysterious case of the dancing bunny', $items[0]['description']); $this->assertEquals('BunnyDance', $items[0]['name']); @@ -42,7 +42,7 @@ class ManagedCaseTypeTest extends \PHPUnit\Framework\Assert { $this->assertEquals(1, count($items)); } - public function testUninstalled($cv) { + public function testUninstalled($cv): void { $items = $cv->api4('CaseType', 'get', ['where' => [['name', '=', 'BunnyDance']]]); $this->assertEquals(0, count($items)); diff --git a/mixin/mgd-php@1/example/tests/mixin/ManagedTest.php b/mixin/mgd-php@1/example/tests/mixin/ManagedTest.php index 0ac5cc6579..39d3e06842 100644 --- a/mixin/mgd-php@1/example/tests/mixin/ManagedTest.php +++ b/mixin/mgd-php@1/example/tests/mixin/ManagedTest.php @@ -12,23 +12,23 @@ namespace Civi\Shimmy\Mixins; */ class ManagedTest extends \PHPUnit\Framework\Assert { - public function testPreConditions($cv) { + public function testPreConditions($cv): void { $this->assertFileExists(static::getPath('/CRM/ShimmyGroup.mgd.php'), 'The shimmy extension must have a Menu XML file.'); } - public function testInstalled($cv) { + public function testInstalled($cv): void { $items = $cv->api4('OptionGroup', 'get', ['where' => [['name', '=', 'shimmy_group']]]); $this->assertEquals('Shimmy Group', $items[0]['title']); $this->assertEquals(TRUE, $items[0]['is_active']); } - public function testDisabled($cv) { + public function testDisabled($cv): void { $items = $cv->api4('OptionGroup', 'get', ['where' => [['name', '=', 'shimmy_group']]]); $this->assertEquals('Shimmy Group', $items[0]['title']); $this->assertEquals(FALSE, $items[0]['is_active']); } - public function testUninstalled($cv) { + public function testUninstalled($cv): void { $items = $cv->api4('OptionGroup', 'get', ['where' => [['name', '=', 'shimmy_group']]]); $this->assertEmpty($items); } diff --git a/mixin/scan-classes@1/example/tests/mixin/ScanClassesTest.php b/mixin/scan-classes@1/example/tests/mixin/ScanClassesTest.php index c664c96d1d..47c5438572 100644 --- a/mixin/scan-classes@1/example/tests/mixin/ScanClassesTest.php +++ b/mixin/scan-classes@1/example/tests/mixin/ScanClassesTest.php @@ -12,11 +12,11 @@ namespace Civi\Shimmy\Mixins; */ class ScanClassesTest extends \PHPUnit\Framework\Assert { - public function testPreConditions($cv) { + public function testPreConditions($cv): void { $this->assertFileExists(static::getPath('/CRM/Shimmy/ShimmyMessage.php'), 'The shimmy extension must have example PHP files.'); } - public function testInstalled($cv) { + public function testInstalled($cv): void { // Assert that WorkflowMessageInterface's are registered. $items = $cv->api4('WorkflowMessage', 'get', ['where' => [['name', '=', 'shimmy_message_example']]]); $this->assertEquals('CRM_Shimmy_ShimmyMessage', $items[0]['class']); @@ -33,7 +33,7 @@ class ScanClassesTest extends \PHPUnit\Framework\Assert { $this->assertEquals($expectHookData, $hookData); } - public function testDisabled($cv) { + public function testDisabled($cv): void { // Assert that WorkflowMessageInterface's are removed. $items = $cv->api4('WorkflowMessage', 'get', ['where' => [['name', '=', 'shimmy_message_example']]]); $this->assertEmpty($items); @@ -43,7 +43,7 @@ class ScanClassesTest extends \PHPUnit\Framework\Assert { $this->assertEquals([], $hookData); } - public function testUninstalled($cv) { + public function testUninstalled($cv): void { // Assert that WorkflowMessageInterface's are removed. $items = $cv->api4('WorkflowMessage', 'get', ['where' => [['name', '=', 'shimmy_message_example']]]); $this->assertEmpty($items); diff --git a/mixin/setting-php@1/example/tests/mixin/SettingsTest.php b/mixin/setting-php@1/example/tests/mixin/SettingsTest.php index 2ea5e9981b..f62380fb98 100644 --- a/mixin/setting-php@1/example/tests/mixin/SettingsTest.php +++ b/mixin/setting-php@1/example/tests/mixin/SettingsTest.php @@ -12,11 +12,11 @@ namespace Civi\Shimmy\Mixins; */ class SettingsTest extends \PHPUnit\Framework\Assert { - public function testPreConditions($cv) { + public function testPreConditions($cv): void { $this->assertFileExists(static::getPath('/settings/Shimmy.setting.php'), 'The shimmy extension must have a Menu XML file.'); } - public function testInstalled($cv) { + public function testInstalled($cv): void { // The menu item is registered... $items = $cv->api4('Setting', 'getFields', ['where' => [['name', '=', 'shimmy_example']], 'loadOptions' => TRUE]); $this->assertEquals('shimmy_example', $items[0]['name']); @@ -34,7 +34,7 @@ class SettingsTest extends \PHPUnit\Framework\Assert { $this->assertEquals('second', $value); } - public function testDisabled($cv) { + public function testDisabled($cv): void { $items = $cv->api4('Setting', 'getFields', ['where' => [['name', '=', 'shimmy_example']], 'loadOptions' => TRUE]); $this->assertEmpty($items); @@ -42,7 +42,7 @@ class SettingsTest extends \PHPUnit\Framework\Assert { $this->assertEquals('second', $value); } - public function testUninstalled($cv) { + public function testUninstalled($cv): void { $items = $cv->api4('Setting', 'getFields', ['where' => [['name', '=', 'shimmy_example']], 'loadOptions' => TRUE]); $this->assertEmpty($items); diff --git a/tests/extensions/shimmy/tests/phpunit/E2E/Shimmy/LifecycleTest.php b/tests/extensions/shimmy/tests/phpunit/E2E/Shimmy/LifecycleTest.php index f80850e265..b4c3ebf027 100644 --- a/tests/extensions/shimmy/tests/phpunit/E2E/Shimmy/LifecycleTest.php +++ b/tests/extensions/shimmy/tests/phpunit/E2E/Shimmy/LifecycleTest.php @@ -88,7 +88,7 @@ class E2E_Shimmy_LifecycleTest extends \PHPUnit\Framework\TestCase implements \C return dirname(__DIR__, 4) . $suffix; } - protected function runMethods(string $method, ...$args) { + protected function runMethods(string $method, ...$args): void { if (empty($this->mixinTests)) { $this->fail('Cannot run methods. No mixin tests found.'); } -- 2.25.1