Completed
Push — master ( c54dd1...7d6afc )
by Douglas
03:28
created

HandlerWrapperTest::willFindAnnotatedMethods()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
/**
3
 * (c) 2018 Douglas Reith.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Reith\ToyRobot\Infrastructure\Bus;
11
12
use PHPUnit\Framework\TestCase;
13
use Reith\ToyRobot\Messaging\Command\PlaceRobot;
14
use Reith\ToyRobot\Domain\Space\Table;
15
use Reith\ToyRobot\Domain\Robot\RobotRepositoryInterface;
16
use Reith\ToyRobot\CommandHandler\RobotPlacer;
17
18
class HandlerWrapperTest extends TestCase
19
{
20
    /**
21
     * @test
22
     */
23
    public function willFindAnnotatedMethods()
24
    {
25
        $table = Table::create(10);
26
        $mockRepo = self::createMock(RobotRepositoryInterface::class);
27
        $robotPlacer = new RobotPlacer($table, $mockRepo);
0 ignored issues
show
Documentation introduced by
$mockRepo is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Reith\ToyRobot\Do...botRepositoryInterface>.

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...
28
29
        $wrapper = new HandlerWrapper($robotPlacer);
30
31
        $command = new PlaceRobot([0, 1], 'N');
32
        $callable = $wrapper->getCallable($command);
33
34
        self::assertTrue(is_callable($callable));
35
    }
36
37
    /**
38
     * @test
39
     * @expectedException \Assert\AssertionFailedException
40
     */
41
    public static function handlerMustHaveMethods()
42
    {
43
        $badHandler = new \stdClass();
44
        new HandlerWrapper($badHandler);
45
    }
46
}
47