diff --git a/src/Tests/DiagnosticCheck/HookRequirementsTest.php b/src/Tests/DiagnosticCheck/HookRequirementsTest.php deleted file mode 100644 index 49965e4..0000000 --- a/src/Tests/DiagnosticCheck/HookRequirementsTest.php +++ /dev/null @@ -1,67 +0,0 @@ -loadInclude('purge', 'install'); - $r = $module_handler->invoke('purge', 'requirements', ['runtime']); - // Assert presence of all DiagnosticCheck plugins we're know off. - $this->assertTrue(isset($r['capacity'])); - $this->assertTrue(isset($r['processorsavailable'])); - $this->assertTrue(isset($r['queuersavailable'])); - $this->assertTrue(isset($r['purgersavailable'])); - $this->assertTrue(isset($r['memoryqueuewarning'])); - $this->assertTrue(isset($r['alwaysinfo'])); - $this->assertTrue(isset($r['alwaysok'])); - $this->assertTrue(isset($r['alwayserror'])); - $this->assertTrue(isset($r['alwayswarning'])); - // Assert a couple of titles. - $this->assertEqual('Purge - Always ok', (string)$r['alwaysok']['title']); - $this->assertEqual('Purge - Always a warning', (string)$r['alwayswarning']['title']); - $this->assertEqual('Purge - Always an error', (string)$r['alwayserror']['title']); - // Assert that the descriptions come through. - $this->assertEqual('This is an ok for testing.', (string)$r['alwaysok']['description']); - $this->assertEqual('This is a warning for testing.', (string)$r['alwayswarning']['description']); - $this->assertEqual('This is an error for testing.', (string)$r['alwayserror']['description']); - // Assert that the severities come through properly. - $this->assertEqual(0, $r['alwaysok']['severity']); - $this->assertEqual(1, $r['alwayswarning']['severity']); - $this->assertEqual(2, $r['alwayserror']['severity']); - // Assert that the values come through properly. - $this->assertTrue(is_string($r['capacity']['value'])); - $this->assertEqual("0", $r['capacity']['value']); - $this->assertEqual("", $r['alwaysinfo']['value']); - $this->assertEqual("", $r['alwaysok']['value']); - } - -} diff --git a/src/Tests/DiagnosticCheck/PluginManagerTest.php b/src/Tests/DiagnosticCheck/PluginManagerTest.php deleted file mode 100644 index adf646f..0000000 --- a/src/Tests/DiagnosticCheck/PluginManagerTest.php +++ /dev/null @@ -1,93 +0,0 @@ -assertTrue($this->service instanceof PluginManagerInterface); - $this->assertTrue($this->service instanceof DefaultPluginManager); - $this->assertTrue($this->service instanceof CachedDiscoveryInterface); - } - - /** - * Test the plugins we expect to be available. - */ - public function testDefinitions() { - $definitions = $this->service->getDefinitions(); - foreach ($this->plugins as $plugin_id) { - $this->assertTrue(isset($definitions[$plugin_id])); - } - foreach ($definitions as $plugin_id => $md) { - $this->assertTrue(in_array($plugin_id, $this->plugins)); - } - foreach ($definitions as $plugin_id => $md) { - foreach ($md as $field => $value) { - $this->assertTrue(in_array($field, $this->annotationFields)); - } - foreach ($this->annotationFields as $field) { - $this->assertTrue(isset($md[$field])); - } - } - } - -} diff --git a/src/Tests/DiagnosticCheck/ServiceSmokeAndFireTest.php b/src/Tests/DiagnosticCheck/ServiceSmokeAndFireTest.php deleted file mode 100644 index f582371..0000000 --- a/src/Tests/DiagnosticCheck/ServiceSmokeAndFireTest.php +++ /dev/null @@ -1,48 +0,0 @@ -installConfig(['purge_processor_test']); - } - - /** - * Tests: - * - \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService::isSystemOnFire() - * - \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService::isSystemShowingSmoke() - */ - public function testIsSystemOnFireOrShowingSmoke() { - $this->initializePurgersService(['ida' => 'a']); - $this->initializeService(); - $this->assertFalse(is_object($this->service->isSystemOnFire())); - if ($this->assertTrue(is_bool($this->service->isSystemOnFire()))) { - $this->assertFalse($this->service->isSystemOnFire()); - } - $this->assertTrue(is_object($this->service->isSystemShowingSmoke())); - } - -} diff --git a/tests/src/Unit/DiagnosticCheck/HookRequirementsTest.php b/tests/src/Unit/DiagnosticCheck/HookRequirementsTest.php new file mode 100644 index 0000000..add224f --- /dev/null +++ b/tests/src/Unit/DiagnosticCheck/HookRequirementsTest.php @@ -0,0 +1,62 @@ +loadInclude('purge', 'install'); + $r = $module_handler->invoke('purge', 'requirements', ['runtime']); + // Assert presence of all DiagnosticCheck plugins we're know off. + $this->assertTrue(isset($r['capacity'])); + $this->assertTrue(isset($r['processorsavailable'])); + $this->assertTrue(isset($r['queuersavailable'])); + $this->assertTrue(isset($r['purgersavailable'])); + $this->assertTrue(isset($r['memoryqueuewarning'])); + $this->assertTrue(isset($r['alwaysinfo'])); + $this->assertTrue(isset($r['alwaysok'])); + $this->assertTrue(isset($r['alwayserror'])); + $this->assertTrue(isset($r['alwayswarning'])); + // Assert a couple of titles. + $this->assertEquals('Purge - Always ok', (string) $r['alwaysok']['title']); + $this->assertEquals('Purge - Always a warning', (string) $r['alwayswarning']['title']); + $this->assertEquals('Purge - Always an error', (string) $r['alwayserror']['title']); + // Assert that the descriptions come through. + $this->assertEquals('This is an ok for testing.', (string) $r['alwaysok']['description']); + $this->assertEquals('This is a warning for testing.', (string) $r['alwayswarning']['description']); + $this->assertEquals('This is an error for testing.', (string) $r['alwayserror']['description']); + // Assert that the severities come through properly. + $this->assertEquals(0, $r['alwaysok']['severity']); + $this->assertEquals(1, $r['alwayswarning']['severity']); + $this->assertEquals(2, $r['alwayserror']['severity']); + // Assert that the values come through properly. + $this->assertTrue(is_string($r['capacity']['value'])); + $this->assertEquals("0", $r['capacity']['value']); + $this->assertEquals("", $r['alwaysinfo']['value']); + $this->assertEquals("", $r['alwaysok']['value']); + } + +} diff --git a/tests/src/Unit/DiagnosticCheck/PluginManagerTest.php b/tests/src/Unit/DiagnosticCheck/PluginManagerTest.php new file mode 100644 index 0000000..90e9dce --- /dev/null +++ b/tests/src/Unit/DiagnosticCheck/PluginManagerTest.php @@ -0,0 +1,88 @@ +assertTrue($this->service instanceof PluginManagerInterface); + $this->assertTrue($this->service instanceof DefaultPluginManager); + $this->assertTrue($this->service instanceof CachedDiscoveryInterface); + } + + /** + * Test the plugins we expect to be available. + */ + public function testDefinitions() { + $definitions = $this->service->getDefinitions(); + foreach ($this->plugins as $plugin_id) { + $this->assertTrue(isset($definitions[$plugin_id])); + } + foreach ($definitions as $plugin_id => $md) { + $this->assertTrue(in_array($plugin_id, $this->plugins)); + } + foreach ($definitions as $plugin_id => $md) { + foreach ($md as $field => $value) { + $this->assertTrue(in_array($field, $this->annotationFields)); + } + foreach ($this->annotationFields as $field) { + $this->assertTrue(isset($md[$field])); + } + } + } + +} diff --git a/tests/src/Unit/DiagnosticCheck/ServiceSmokeAndFireTest.php b/tests/src/Unit/DiagnosticCheck/ServiceSmokeAndFireTest.php new file mode 100644 index 0000000..d0b0c57 --- /dev/null +++ b/tests/src/Unit/DiagnosticCheck/ServiceSmokeAndFireTest.php @@ -0,0 +1,44 @@ +installConfig(['purge_processor_test']); + } + + /** + * Tests: + * - \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService::isSystemOnFire() + * - \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService::isSystemShowingSmoke() + */ + public function testIsSystemOnFireOrShowingSmoke() { + $this->initializePurgersService(['ida' => 'a']); + $this->initializeService(); + $this->assertFalse(is_object($this->service->isSystemOnFire())); + $this->assertTrue(is_bool($this->service->isSystemOnFire())); + if (is_bool($this->service->isSystemOnFire())) { + $this->assertFalse($this->service->isSystemOnFire()); + } + $this->assertTrue(is_object($this->service->isSystemShowingSmoke())); + } + +}