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

ChainResolverTests::testCreate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Cubiche\Core\Bus\Tests\Units\Middlewares\Handler\Resolver\HandlerMethodName;
13
14
use Cubiche\Core\Bus\Exception\NotFoundException;
15
use Cubiche\Core\Bus\Middlewares\Handler\Resolver\HandlerMethodName\ChainResolver;
16
use Cubiche\Core\Bus\Middlewares\Handler\Resolver\HandlerMethodName\DefaultResolver;
17
use Cubiche\Core\Bus\Middlewares\Handler\Resolver\HandlerMethodName\MethodWithShortObjectNameResolver;
18
use Cubiche\Core\Bus\Tests\Fixtures\Message\LoginUserMessage;
19
use Cubiche\Core\Bus\Tests\Fixtures\Message\LogoutUserMessage;
20
use Cubiche\Core\Bus\Tests\Fixtures\InvalidHandlerMethodNameResolver;
21
use Cubiche\Core\Bus\Tests\Units\TestCase;
22
23
/**
24
 * ChainResolver class.
25
 *
26
 * Generated by TestGenerator on 2016-04-07 at 15:40:41.
27
 */
28
class ChainResolverTests extends TestCase
29
{
30
    /**
31
     * Test Resolve method.
32
     */
33
    public function testResolve()
34
    {
35
        $this
36
            ->given($resolver1 = new InvalidHandlerMethodNameResolver())
37
            ->given($resolver2 = new MethodWithShortObjectNameResolver('Message'))
38
            ->and($resolver3 = new DefaultResolver())
39
            ->and($resolver = new ChainResolver([$resolver1, $resolver2, $resolver3]))
40
            ->when($result = $resolver->resolve(LoginUserMessage::class))
41
            ->then()
42
                ->string($result)
43
                    ->isEqualTo('loginUser')
44
        ;
45
46
        $this
47
            ->given($resolver = new ChainResolver([]))
48
            ->then()
49
                ->exception(function () use ($resolver) {
50
                    $resolver->resolve(new LogoutUserMessage('[email protected]'));
0 ignored issues
show
Documentation introduced by
new \Cubiche\Core\Bus\Te...age('[email protected]') is of type object<Cubiche\Core\Bus\...sage\LogoutUserMessage>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
51
                })
52
                ->isInstanceOf(NotFoundException::class)
53
        ;
54
    }
55
}
56