FromCommandNamedResolverTests   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testResolve() 0 19 1
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
namespace Cubiche\Core\Cqrs\Tests\Units\Middlewares\Handler\Resolver\NameOfCommand;
11
12
use Cubiche\Core\Cqrs\Middlewares\Handler\Resolver\NameOfCommand\FromCommandNamedResolver;
13
use Cubiche\Core\Cqrs\Tests\Fixtures\Command\LoginUserCommand;
14
use Cubiche\Core\Cqrs\Tests\Fixtures\Command\LogoutUserCommand;
15
use Cubiche\Core\Cqrs\Tests\Units\TestCase;
16
17
/**
18
 * FromCommandNamedResolverTests class.
19
 *
20
 * @author Ivannis Suárez Jerez <[email protected]>
21
 */
22
class FromCommandNamedResolverTests extends TestCase
23
{
24
    /**
25
     * Test Resolve method.
26
     */
27
    public function testResolve()
28
    {
29
        $this
30
            ->given($resolver = new FromCommandNamedResolver())
31
            ->when($result = $resolver->resolve(new LogoutUserCommand('[email protected]')))
32
            ->then()
33
                ->string($result)
34
                    ->isEqualTo('logout_user')
35
        ;
36
37
        $this
38
            ->given($resolver = new FromCommandNamedResolver())
39
            ->then()
40
                ->exception(function () use ($resolver) {
41
                    $resolver->resolve(new LoginUserCommand('[email protected]', 'plainpassword'));
42
                })
43
                ->isInstanceOf(\InvalidArgumentException::class)
44
        ;
45
    }
46
}
47