forked from PhilGruber/coding-exercise
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameTest.php
More file actions
115 lines (110 loc) · 2.86 KB
/
GameTest.php
File metadata and controls
115 lines (110 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
require_once 'Sidekicker/Game.php';
require_once 'Sidekicker/Grid.php';
use PHPUnit\Framework\TestCase;
use Sidekicker\Game;
/**
* @covers Game
*/
final class GameTest extends TestCase
{
/**
* @expectedException Exception
*/
public function testInvalidFilePath()
{
$game = new Game("invalid.txt");
$game->start();
}
/**
* @expectedException Exception
*/
public function testInvalidFileRows()
{
$game = new Game("TestData/invalid_file.txt");
$game->start();
}
public function testValidFile()
{
$game = new Game("TestData/valid_file.txt");
$game->start();
$grid = $game->getGrid();
$this->assertEquals(8, $grid->getSizeX());
$this->assertEquals(6, $grid->getSizeY());
$expectedGrid = array (
0 =>
array (
0 => true,
1 => true,
2 => false,
3 => false,
4 => false,
5 => false,
),
1 =>
array (
0 => false,
1 => false,
2 => false,
3 => false,
4 => true,
5 => false,
),
2 =>
array (
0 => false,
1 => false,
2 => false,
3 => false,
4 => false,
5 => false,
),
3 =>
array (
0 => true,
1 => false,
2 => false,
3 => true,
4 => true,
5 => true,
),
4 =>
array (
0 => false,
1 => true,
2 => false,
3 => false,
4 => true,
5 => false,
),
5 =>
array (
0 => false,
1 => true,
2 => true,
3 => true,
4 => false,
5 => false,
),
6 =>
array (
0 => false,
1 => true,
2 => false,
3 => false,
4 => false,
5 => true,
),
7 =>
array (
0 => false,
1 => true,
2 => true,
3 => false,
4 => false,
5 => true,
),
);
$this->assertEquals($expectedGrid, $grid->getGridArray());
}
}