Completed
Push — master ( 7c00aa...d8aae5 )
by Ivannis Suárez
19:41
created

ChainResolverTests   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 6
dl 0
loc 32
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B testResolve() 0 26 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
11
namespace Cubiche\Core\Bus\Tests\Units\Middlewares\Handler\Resolver\NameOfMessage;
12
13
use Cubiche\Core\Bus\Exception\NotFoundException;
14
use Cubiche\Core\Bus\Middlewares\Handler\Resolver\NameOfMessage\ChainResolver;
15
use Cubiche\Core\Bus\Middlewares\Handler\Resolver\NameOfMessage\FromClassNameResolver;
16
use Cubiche\Core\Bus\Middlewares\Handler\Resolver\NameOfMessage\FromMessageNamedResolver;
17
use Cubiche\Core\Bus\Tests\Fixtures\Message\LoginUserMessage;
18
use Cubiche\Core\Bus\Tests\Fixtures\Message\LogoutUserMessage;
19
use Cubiche\Core\Bus\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 FromMessageNamedResolver())
35
            ->and($resolver2 = new FromClassNameResolver())
36
            ->and($resolver = new ChainResolver([$resolver1, $resolver2]))
37
            ->when($result = $resolver->resolve(new LoginUserMessage('[email protected]', 'plainpassword')))
0 ignored issues
show
Unused Code introduced by
The call to LoginUserMessage::__construct() has too many arguments starting with 'plainpassword'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
38
            ->then()
39
                ->string($result)
40
                    ->isEqualTo(LoginUserMessage::class)
41
            ->and()
42
            ->when($result = $resolver->resolve(new LogoutUserMessage('[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 LogoutUserMessage('[email protected]'));
53
                })
54
                ->isInstanceOf(NotFoundException::class)
55
        ;
56
    }
57
}
58