2020-12-20 14:52:29 +01:00
|
|
|
<?php
|
|
|
|
|
2023-02-03 20:41:59 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-12-20 14:52:29 +01:00
|
|
|
namespace Engelsystem\Test\Unit\Events;
|
|
|
|
|
|
|
|
use Engelsystem\Config\Config;
|
|
|
|
use Engelsystem\Events\EventDispatcher;
|
|
|
|
use Engelsystem\Events\EventsServiceProvider;
|
|
|
|
use Engelsystem\Test\Unit\ServiceProviderTest;
|
|
|
|
|
|
|
|
class EventsServiceProviderTest extends ServiceProviderTest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Events\EventsServiceProvider::register
|
|
|
|
* @covers \Engelsystem\Events\EventsServiceProvider::registerEvents
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testRegister(): void
|
2020-12-20 14:52:29 +01:00
|
|
|
{
|
|
|
|
$dispatcher = $this->createMock(EventDispatcher::class);
|
|
|
|
$this->app->instance(EventDispatcher::class, $dispatcher);
|
|
|
|
$dispatcher->expects($this->exactly(3))
|
|
|
|
->method('listen')
|
|
|
|
->withConsecutive(
|
|
|
|
['test.event', 'someFunction'],
|
|
|
|
['another.event', 'Foo\Bar@baz'],
|
2022-12-14 00:28:34 +01:00
|
|
|
['another.event', [$this, 'testRegister']]
|
2020-12-20 14:52:29 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$config = new Config([
|
|
|
|
'event-handlers' => [
|
|
|
|
'test.event' => 'someFunction',
|
2022-12-14 00:28:34 +01:00
|
|
|
'another.event' => ['Foo\Bar@baz', [$this, 'testRegister']]
|
2020-12-20 14:52:29 +01:00
|
|
|
]
|
|
|
|
]);
|
|
|
|
$this->app->instance('config', $config);
|
|
|
|
|
|
|
|
/** @var EventsServiceProvider $provider */
|
|
|
|
$provider = $this->app->make(EventsServiceProvider::class);
|
|
|
|
|
|
|
|
$provider->register();
|
|
|
|
}
|
|
|
|
}
|