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

RobotRepositoryTest::willReturnARobot()   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\Persistence;
11
12
use PHPUnit\Framework\TestCase;
13
use Reith\ToyRobot\Domain\Space\Table;
14
use Reith\ToyRobot\Domain\Robot\Robot;
15
16
class RobotRepositoryTest extends TestCase
17
{
18
    /**
19
     * @test
20
     */
21
    public function willReturnARobot()
22
    {
23
        $robot = Table::create(5)->placeRobot();
24
25
        $mockStore = self::createMock(RobotStoreInterface::class);
26
        $mockStore->method('getRobot')
27
            ->willReturn($robot);
28
29
        $repository = new RobotRepository($mockStore);
0 ignored issues
show
Documentation introduced by
$mockStore is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Reith\ToyRobot\In...ce\RobotStoreInterface>.

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...
30
31
        self::assertInstanceOf(RobotRepository::class, $repository);
32
        self::assertSame($robot, $repository->load());
33
    }
34
}
35