From b1118708539767c5815a93fd302553de9fcc0fef Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Wed, 21 Jul 2021 16:44:20 +0000 Subject: [PATCH] [TESTS][EVENTS] Raise test coverage for Event class to 100% --- tests/Core/EventTest.php | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/Core/EventTest.php diff --git a/tests/Core/EventTest.php b/tests/Core/EventTest.php new file mode 100644 index 0000000000..fee5bad499 --- /dev/null +++ b/tests/Core/EventTest.php @@ -0,0 +1,42 @@ +. + +// }}} + +namespace App\Tests\Core; + +use App\Core\Event; +use App\Util\GNUsocialTestCase; + +class EventTest extends GNUsocialTestCase +{ + public function testEvent() + { + parent::bootKernel(); + Event::addHandler('foo-bar', function () { static::assertTrue(true); return Event::next; }); + static::assertSame(Event::next, Event::handle('foo-bar')); + Event::addHandler('foo-bar2', function () { static::assertTrue(true); return Event::stop; }); + static::assertSame(Event::stop, Event::handle('foo-bar2')); + + static::assertTrue(Event::hasHandler('foo-bar')); + static::assertTrue(Event::hasHandler('foo-bar', plugin: get_class())); + static::assertFalse(Event::hasHandler('foo-bar', plugin: 'Plugin\\SomePlugin')); + static::assertTrue(count(Event::getHandlers('foo-bar')) === 1); + } +}