1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Cubiche package. |
4
|
|
|
* |
5
|
|
|
* Copyright (c) Cubiche |
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 Cubiche\Core\Cqrs\Tests\Units\Middlewares\Handler\Resolver\NameOfCommand; |
12
|
|
|
|
13
|
|
|
use Cubiche\Core\Bus\Exception\NotFoundException; |
14
|
|
|
use Cubiche\Core\Cqrs\Middlewares\Handler\Resolver\NameOfCommand\ChainResolver; |
15
|
|
|
use Cubiche\Core\Cqrs\Middlewares\Handler\Resolver\NameOfCommand\FromClassNameResolver; |
16
|
|
|
use Cubiche\Core\Cqrs\Middlewares\Handler\Resolver\NameOfCommand\FromCommandNamedResolver; |
17
|
|
|
use Cubiche\Core\Cqrs\Tests\Fixtures\Command\LoginUserCommand; |
18
|
|
|
use Cubiche\Core\Cqrs\Tests\Fixtures\Command\LogoutUserCommand; |
19
|
|
|
use Cubiche\Core\Cqrs\Tests\Units\TestCase; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* ChainResolver class. |
23
|
|
|
* |
24
|
|
|
* Generated by TestGenerator on 2016-04-07 at 15:40:41. |
25
|
|
|
*/ |
26
|
|
|
class ChainResolverTests extends TestCase |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Test Resolve method. |
30
|
|
|
*/ |
31
|
|
|
public function testResolve() |
32
|
|
|
{ |
33
|
|
|
$this |
34
|
|
|
->given($resolver1 = new FromCommandNamedResolver()) |
35
|
|
|
->and($resolver2 = new FromClassNameResolver()) |
36
|
|
|
->and($resolver = new ChainResolver([$resolver1, $resolver2])) |
37
|
|
|
->when($result = $resolver->resolve(new LoginUserCommand('[email protected]', 'plainpassword'))) |
38
|
|
|
->then() |
39
|
|
|
->string($result) |
40
|
|
|
->isEqualTo(LoginUserCommand::class) |
41
|
|
|
->and() |
42
|
|
|
->when($result = $resolver->resolve(new LogoutUserCommand('[email protected]'))) |
43
|
|
|
->then() |
44
|
|
|
->string($result) |
45
|
|
|
->isEqualTo('logout_user') |
46
|
|
|
; |
47
|
|
|
|
48
|
|
|
$this |
49
|
|
|
->given($resolver = new ChainResolver([])) |
50
|
|
|
->then() |
51
|
|
|
->exception(function () use ($resolver) { |
52
|
|
|
$resolver->resolve(new LogoutUserCommand('[email protected]')); |
53
|
|
|
}) |
54
|
|
|
->isInstanceOf(NotFoundException::class) |
55
|
|
|
; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|