File tree Expand file tree Collapse file tree 4 files changed +146
-0
lines changed Expand file tree Collapse file tree 4 files changed +146
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Author: Nil Portugués Calderó <[email protected] >
4
+ * Date: 23/03/16
5
+ * Time: 22:43.
6
+ *
7
+ * For the full copyright and license information, please view the LICENSE
8
+ * file that was distributed with this source code.
9
+ */
10
+
11
+ namespace NilPortugues \Tests \MessageBus \CommandBus \Resolver ;
12
+
13
+ use InvalidArgumentException ;
14
+ use NilPortugues \MessageBus \CommandBus \Resolver \PsrContainerResolver ;
15
+ use NilPortugues \Tests \MessageBus \CommandBus \DummyCommandHandler ;
16
+ use NilPortugues \Tests \MessageBus \InMemoryPsrContainer ;
17
+
18
+ class PsrContainerResolverTest extends \PHPUnit_Framework_TestCase
19
+ {
20
+ public function testItCanResolve ()
21
+ {
22
+ $ handlers = [
23
+ 'NilPortugues\Tests\MessageBus\CommandBus\DummyCommandHandler ' => function () {
24
+ return new DummyCommandHandler ();
25
+ },
26
+ ];
27
+
28
+ $ resolver = new PsrContainerResolver (new InMemoryPsrContainer ($ handlers ));
29
+ $ instance = $ resolver ->instantiate (
30
+ 'NilPortugues\Tests\MessageBus\CommandBus\DummyCommandHandler '
31
+ );
32
+
33
+ $ this ->assertInstanceOf (DummyCommandHandler::class, $ instance );
34
+ }
35
+
36
+ public function testItThrowsExceptionIfCannotResolve ()
37
+ {
38
+ $ this ->expectException (InvalidArgumentException::class);
39
+ $ resolver = new PsrContainerResolver (new InMemoryPsrContainer ([]));
40
+ $ resolver ->instantiate ('Hello\World ' );
41
+ }
42
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Author: Nil Portugués Calderó <[email protected] >
4
+ * Date: 23/03/16
5
+ * Time: 22:43.
6
+ *
7
+ * For the full copyright and license information, please view the LICENSE
8
+ * file that was distributed with this source code.
9
+ */
10
+
11
+ namespace NilPortugues \Tests \MessageBus \EventBus \Resolver ;
12
+
13
+ use InvalidArgumentException ;
14
+ use NilPortugues \MessageBus \EventBus \Resolver \PsrContainerResolver ;
15
+ use NilPortugues \Tests \MessageBus \EventBus \DummyEventHandler ;
16
+ use NilPortugues \Tests \MessageBus \InMemoryPsrContainer ;
17
+
18
+ class PsrContainerResolverTest extends \PHPUnit_Framework_TestCase
19
+ {
20
+ public function testItCanResolve ()
21
+ {
22
+ $ handlers = [
23
+ 'NilPortugues\Tests\MessageBus\EventBus\DummyEventHandler ' => function () {
24
+ return new DummyEventHandler ();
25
+ },
26
+ ];
27
+
28
+ $ resolver = new PsrContainerResolver (new InMemoryPsrContainer ($ handlers ));
29
+ $ instance = $ resolver ->instantiate (
30
+ 'NilPortugues\Tests\MessageBus\EventBus\DummyEventHandler '
31
+ );
32
+
33
+ $ this ->assertInstanceOf (DummyEventHandler::class, $ instance );
34
+ }
35
+
36
+ public function testItThrowsExceptionIfCannotResolve ()
37
+ {
38
+ $ this ->expectException (InvalidArgumentException::class);
39
+ $ resolver = new PsrContainerResolver (new InMemoryPsrContainer ([]));
40
+ $ resolver ->instantiate ('Hello\World ' );
41
+ }
42
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Author: Nil Portugués Calderó <[email protected] >
4
+ * Date: 23/03/16
5
+ * Time: 22:45.
6
+ *
7
+ * For the full copyright and license information, please view the LICENSE
8
+ * file that was distributed with this source code.
9
+ */
10
+
11
+ namespace NilPortugues \Tests \MessageBus ;
12
+
13
+ use Psr \Container \ContainerInterface ;
14
+
15
+ /**
16
+ * Class InMemoryPsrContainer.
17
+ */
18
+ class InMemoryPsrContainer extends InMemoryInteropContainer implements ContainerInterface
19
+ {
20
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Author: Nil Portugués Calderó <[email protected] >
4
+ * Date: 23/03/16
5
+ * Time: 22:43.
6
+ *
7
+ * For the full copyright and license information, please view the LICENSE
8
+ * file that was distributed with this source code.
9
+ */
10
+
11
+ namespace NilPortugues \Tests \MessageBus \QueryBus \Resolver ;
12
+
13
+ use InvalidArgumentException ;
14
+ use NilPortugues \MessageBus \QueryBus \Resolver \PsrContainerResolver ;
15
+ use NilPortugues \Tests \MessageBus \InMemoryPsrContainer ;
16
+ use NilPortugues \Tests \MessageBus \QueryBus \DummyQueryHandler ;
17
+
18
+ class PsrContainerResolverTest extends \PHPUnit_Framework_TestCase
19
+ {
20
+ public function testItCanResolve ()
21
+ {
22
+ $ handlers = [
23
+ 'NilPortugues\Tests\MessageBus\QueryBus\DummyQueryHandler ' => function () {
24
+ return new DummyQueryHandler ();
25
+ },
26
+ ];
27
+
28
+ $ resolver = new PsrContainerResolver (new InMemoryPsrContainer ($ handlers ));
29
+ $ instance = $ resolver ->instantiate (
30
+ 'NilPortugues\Tests\MessageBus\QueryBus\DummyQueryHandler '
31
+ );
32
+
33
+ $ this ->assertInstanceOf (DummyQueryHandler::class, $ instance );
34
+ }
35
+
36
+ public function testItThrowsExceptionIfCannotResolve ()
37
+ {
38
+ $ this ->expectException (InvalidArgumentException::class);
39
+ $ resolver = new PsrContainerResolver (new InMemoryPsrContainer ([]));
40
+ $ resolver ->instantiate ('Hello\World ' );
41
+ }
42
+ }
You can’t perform that action at this time.
0 commit comments