public function CleanerKernelTests::testEventSubscribers in Cleaner 8.2
Test that cleaner run event has all our subscribers.
File
- tests/
src/ Kernel/ CleanerKernelTests.php, line 52
Class
- CleanerKernelTests
- Class CleanerKernelTests.
Namespace
Drupal\Tests\cleaner\KernelCode
public function testEventSubscribers() {
try {
$dispatcher = $this->container
->get('event_dispatcher');
$this
->assertTrue($dispatcher
->hasListeners(CleanerRunEvent::CLEANER_RUN));
$classes = array_map(function ($subscriber) {
return get_class($subscriber[0]);
}, $dispatcher
->getListeners(CleanerRunEvent::CLEANER_RUN));
$this
->assertContains(CleanerCacheClearEventSubscriber::class, $classes);
$this
->assertContains(CleanerMysqlOptimizeEventSubscriber::class, $classes);
$this
->assertContains(CleanerSessionClearEventSubscriber::class, $classes);
$this
->assertContains(CleanerTablesClearEventSubscriber::class, $classes);
$this
->assertContains(CleanerWatchdogClearEventSubscriber::class, $classes);
} catch (\Exception $e) {
$this
->fail($e
->getMessage());
}
}