(NFC) Mixin Tests - Add more typehints
authorTim Otten <totten@civicrm.org>
Thu, 19 Jan 2023 07:49:25 +0000 (23:49 -0800)
committerTim Otten <totten@civicrm.org>
Thu, 19 Jan 2023 07:49:25 +0000 (23:49 -0800)
mixin/case-xml@1/example/tests/mixin/CaseTypeTest.php
mixin/entity-types-php@1/example/tests/mixin/EntityTypesTest.php
mixin/menu-xml@1/example/tests/mixin/MenuXmlTest.php
mixin/mgd-php@1/example/tests/mixin/ManagedCaseTypeTest.php
mixin/mgd-php@1/example/tests/mixin/ManagedTest.php
mixin/scan-classes@1/example/tests/mixin/ScanClassesTest.php
mixin/setting-php@1/example/tests/mixin/SettingsTest.php
tests/extensions/shimmy/tests/phpunit/E2E/Shimmy/LifecycleTest.php

index 099a364d3bc768e32bfe9431d181f229927a9d2c..1ea01841b5162ad1418a289d4e4b7f55b7b373e5 100644 (file)
@@ -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));
 
index b8e3cc35952c0e282646ecf980b9da4ad26b8ab3..a6013c8a9d283a7233d1fd9f6da30bd4c7e399dc 100644 (file)
@@ -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]));
index fc56b839691cf28dbdcea0533e6b333415450837..c3878c946b68063ab35e17534c1dbdec8a55f502 100644 (file)
@@ -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);
   }
index 270a5faf7ab805568aba67365c60cdc22dff236b..9137c5a2725a81cccb9538dd70810dea60c5af78 100644 (file)
@@ -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));
 
index 0ac5cc657923f53efd81b05a9b2111c3c523b710..39d3e06842925fb7ee43d70205ce51eb21325bbd 100644 (file)
@@ -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);
   }
index c664c96d1deb9122c2bb8495851b5d2a5327ed0b..47c5438572c8352552f40186a58cb8c1b483e8aa 100644 (file)
@@ -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);
index 2ea5e9981bc0cfcf190cc29ef62d2443f1641d82..f62380fb98df9b0fa8f7c5dea14197b809000cb0 100644 (file)
@@ -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);
 
index f80850e2654b4d1bc3e1646d738cfb38cce3b21f..b4c3ebf0271335b46d0d72c091bad76efdc1fed1 100644 (file)
@@ -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.');
     }