|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace SmrTest\lib\DefaultGame; |
|
4
|
|
|
|
|
5
|
|
|
use Smr\Race; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* @covers Smr\Race |
|
9
|
|
|
*/ |
|
10
|
|
|
class RaceTest extends \PHPUnit\Framework\TestCase { |
|
11
|
|
|
|
|
12
|
|
|
public function test_getPlayableIDs() : void { |
|
13
|
|
|
$ids = Race::getPlayableIDs(); |
|
14
|
|
|
self::assertCount(8, $ids); |
|
15
|
|
|
self::assertNotContains(RACE_NEUTRAL, $ids); |
|
16
|
|
|
// Spot check the result |
|
17
|
|
|
self::assertContains(RACE_HUMAN, $ids); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
public function test_getPlayableNames() : void { |
|
21
|
|
|
$names = Race::getPlayableNames(); |
|
22
|
|
|
self::assertCount(8, $names); |
|
23
|
|
|
self::assertNotContains('Neutral', $names); |
|
24
|
|
|
// Spot check the result |
|
25
|
|
|
self::assertContains('Human', $names); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function test_getPlayableIDs_matches_getPlayableNames() : void { |
|
29
|
|
|
$ids = Race::getPlayableIDs(); |
|
30
|
|
|
$names = Race::getPlayableNames(); |
|
31
|
|
|
self::assertSame($ids, array_keys($names)); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function test_getAllIDs_matches_getAllNames() : void { |
|
35
|
|
|
$ids = Race::getAllIDs(); |
|
36
|
|
|
$names = Race::getAllNames(); |
|
37
|
|
|
self::assertSame($ids, array_keys($names)); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function test_getName() : void { |
|
41
|
|
|
// Spot check the result |
|
42
|
|
|
self::assertSame('WQ Human', Race::getName(RACE_WQHUMAN)); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function test_getName_against_getAllNames() : void { |
|
46
|
|
|
foreach (Race::getAllNames() as $raceID => $raceName) { |
|
47
|
|
|
self::assertSame($raceName, Race::getName($raceID)); |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function test_getName_against_getPlayableNames() : void { |
|
52
|
|
|
foreach (Race::getPlayableNames() as $raceID => $raceName) { |
|
53
|
|
|
self::assertSame($raceName, Race::getName($raceID)); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function test_getImage() : void { |
|
58
|
|
|
// Spot check the result |
|
59
|
|
|
$file = Race::getImage(RACE_ALSKANT); |
|
60
|
|
|
self::assertStringContainsString('race2', $file); |
|
61
|
|
|
// Check that all files exist |
|
62
|
|
|
foreach (Race::getPlayableIDs() as $raceID) { |
|
63
|
|
|
self::assertFileExists(WWW . Race::getImage($raceID)); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function test_getHeadImage() : void { |
|
68
|
|
|
// Spot check the result |
|
69
|
|
|
$file = Race::getHeadImage(RACE_ALSKANT); |
|
70
|
|
|
self::assertStringContainsString('race2', $file); |
|
71
|
|
|
// Check that all files exist |
|
72
|
|
|
foreach (Race::getPlayableIDs() as $raceID) { |
|
73
|
|
|
self::assertFileExists(WWW . Race::getImage($raceID)); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
|