Completed
Push — master ( 8184b0...a4b4a5 )
by Douglas
02:13
created

RobotReporterTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A willHandlePlaceRobot() 0 20 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\QueryHandler;
11
12
use PHPUnit\Framework\TestCase;
13
use Psr\Log\LoggerInterface;
14
use Reith\ToyRobot\Messaging\Query\RobotReport;
15
use Reith\ToyRobot\Domain\Space\Table;
16
use Reith\ToyRobot\Domain\Robot\RobotRepositoryInterface;
17
18
class RobotReporterTest extends TestCase
19
{
20
    /**
21
     * @test
22
     */
23
    public function willHandlePlaceRobot()
24
    {
25
        $mockRepo = self::createMock(RobotRepositoryInterface::class);
26
        $mockLogger = self::createMock(LoggerInterface::class);
27
        $robotReporter = new RobotReporter($mockRepo, $mockLogger);
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...
Documentation introduced by
$mockLogger is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Psr\Log\LoggerInterface>.

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
        self::assertInstanceOf(RobotReporter::class, $robotReporter);
30
31
        $query = new RobotReport();
32
33
        $robot = Table::create(3)->placeRobot();
34
35
        $mockRepo->expects($this->once())
36
            ->method('load')
37
            ->willReturn($robot);
38
39
        $result = $robotReporter->handleReport($query);
40
41
        self::assertSame('0,0,E', $result);
42
    }
43
}
44