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

FileRobotStoreTest::canPersistAndRetrieveARobot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
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 org\bovigo\vfs\vfsStream;
14
use org\bovigo\vfs\vfsStreamDirectory;
15
use Reith\ToyRobot\Domain\Space\Table;
16
use Reith\ToyRobot\Domain\Robot\Robot;
17
18
class FileRobotStoreTest extends TestCase
19
{
20
    /**
21
     * @test
22
     */
23
    public static function canCreateAStore()
24
    {
25
        $basePath = vfsStream::setup('basePath');
26
27
        self::assertFalse($basePath->hasChild('robotstore'));
28
29
        $store = FileRobotStore::getStore(vfsStream::url('basePath'));
30
31
        self::assertTrue($basePath->hasChild('robotstore'));
32
33
        $version = '001';
34
        $fileName = $version . '-robot.txt';
35
36
        $robotStorePath = $basePath->getChild('robotstore');
37
        self::assertTrue($robotStorePath->hasChild($fileName));
38
39
        self::assertInstanceOf(FileRobotStore::class, $store);
40
    }
41
42
    /**
43
     * @test
44
     */
45
    public static function canPersistAndRetrieveARobot()
46
    {
47
        self::markTestSkipped('Issue with the vfsStream mock filesystem and SplFileObject');
48
49
        $basePath = vfsStream::setup('basePath');
0 ignored issues
show
Unused Code introduced by
$basePath is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
50
        $store = FileRobotStore::getStore(vfsStream::url('basePath'));
51
52
        $robot = Table::create(5)->placeRobot();
53
54
        $store->saveRobot($robot);
55
56
        $persistedRobot = $store->getRobot();
57
58
        self::assertInstanceOf(Robot::class, $persistedRobot);
59
    }
60
}
61