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

RobotPlacerTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A willHandlePlaceRobot() 0 14 1
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\CommandHandler;
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
17
class RobotPlacerTest extends TestCase
18
{
19
    /**
20
     * @test
21
     */
22
    public function willHandlePlaceRobot()
23
    {
24
        $table = Table::create(10);
25
        $mockRepo = self::createMock(RobotRepositoryInterface::class);
26
        $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...
27
28
        self::assertInstanceOf(RobotPlacer::class, $robotPlacer);
29
30
        $command = new PlaceRobot([0, 1], 'N');
31
32
        $mockRepo->expects($this->once())->method('save');
33
34
        $robotPlacer->handlePlaceRobot($command);
35
    }
36
}
37