Skip to content

Commit f08ed43

Browse files
committed
qa: provide tests for lazyListener function
Adds LazyListenerFunctionTest, to validate that the function does what it intends.
1 parent 340b3ff commit f08ed43

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/LazyListenerFunctionTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* @see https://github.com/phly/phly-event-dispatcher for the canonical source repository
4+
* @copyright Copyright (c) 2018 Matthew Weier O'Phinney (https:/mwop.net)
5+
* @license https://github.com/phly/phly-event-dispatcher/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace PhlyTest\EventDispatcher;
11+
12+
use Phly\EventDispatcher\LazyListener;
13+
use PHPUnit\Framework\TestCase;
14+
use Psr\Container\ContainerInterface;
15+
16+
use function Phly\EventDispatcher\lazyListener;
17+
18+
class LazyListenerFunctionTest extends TestCase
19+
{
20+
public function testFunctionReturnsALazyListenerUsingProvidedArguments()
21+
{
22+
$container = $this->prophesize(ContainerInterface::class)->reveal();
23+
$listener = lazyListener($container, TestAsset\Listener::class, 'onTest');
24+
25+
$this->assertInstanceOf(LazyListener::class, $listener);
26+
$this->assertAttributeSame($container, 'container', $listener);
27+
$this->assertAttributeSame(TestAsset\Listener::class, 'service', $listener);
28+
$this->assertAttributeSame('onTest', 'method', $listener);
29+
}
30+
}

0 commit comments

Comments
 (0)