mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-26 08:51:13 -06:00
Added AsyncEventListenerTest
This commit is contained in:
parent
af4ee8f7ec
commit
7e8126a421
@ -21,7 +21,7 @@ class TaskRunnerTest extends TestCase
|
||||
private $logger;
|
||||
/** @var ObjectProphecy */
|
||||
private $container;
|
||||
/** @var ObjectProphecy */
|
||||
/** @var HttpServer */
|
||||
private $server;
|
||||
/** @var ObjectProphecy */
|
||||
private $task;
|
||||
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioTest\Shlink\EventDispatcher\Listener;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shlinkio\Shlink\EventDispatcher\Listener\AsyncEventListener;
|
||||
use Shlinkio\Shlink\EventDispatcher\Listener\EventListenerTask;
|
||||
use stdClass;
|
||||
use Swoole\Http\Server as HttpServer;
|
||||
|
||||
class AsyncEventListenerTest extends TestCase
|
||||
{
|
||||
/** @var AsyncEventListener */
|
||||
private $eventListener;
|
||||
/** @var HttpServer */
|
||||
private $server;
|
||||
/** @var string */
|
||||
private $regularListenerName;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->regularListenerName = 'the_regular_listener';
|
||||
$this->server = $this->createMock(HttpServer::class);
|
||||
|
||||
$this->eventListener = new AsyncEventListener($this->server, $this->regularListenerName);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function enqueuesTaskWhenInvoked(): void
|
||||
{
|
||||
$event = new stdClass();
|
||||
|
||||
$this->server
|
||||
->expects($this->once())
|
||||
->method('task')
|
||||
->with(new EventListenerTask($this->regularListenerName, $event));
|
||||
|
||||
($this->eventListener)($event);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user