Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Failed Conditions
Push — live ( 5fc72e...903a76 )
by Dan
07:31 queued 02:29
created

AbstractSmrLocationTest::test_isUG()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace SmrTest\lib\DefaultGame;
4
5
use AbstractSmrLocation;
6
use Exception;
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * @covers AbstractSmrLocation
11
 */
12
class AbstractSmrLocationTest extends TestCase {
13
14
	public function test_getLocation_and_basic_properties(): void {
15
		$typeID = LOCATION_TYPE_FEDERAL_HQ;
16
		$loc = AbstractSmrLocation::getLocation($typeID);
17
		self::assertSame($typeID, $loc->getTypeID());
18
		self::assertSame('Federal Headquarters', $loc->getName());
19
		self::assertSame('government.php', $loc->getAction());
20
		self::assertSame('images/government.png', $loc->getImage());
21
	}
22
23
	public function test_getLocation_throws_when_no_record_found(): void {
24
		$this->expectException(Exception::class);
25
		$this->expectExceptionMessage('Cannot find location: 999');
26
		AbstractSmrLocation::getLocation(999);
27
	}
28
29
	/**
30
	 * @dataProvider provider_isFed
31
	 */
32
	public function test_isFed(int $typeID, bool $expected): void {
33
		$loc = AbstractSmrLocation::getLocation($typeID);
34
		self::assertSame($expected, $loc->isFed());
35
	}
36
37
	/**
38
	 * @return array<array{int, bool}>
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<array{int, bool}> at position 4 could not be parsed: Expected ':' at position 4, but found 'int'.
Loading history...
39
	 */
40
	public function provider_isFed(): array {
41
		return [
42
			[UNDERGROUND, false],
43
			[LOCATION_TYPE_FEDERAL_BEACON, true],
44
			[LOCATION_TYPE_FEDERAL_HQ, false],
45
			[LOCATION_TYPE_FEDERAL_MINT, false],
46
		];
47
	}
48
49
	/**
50
	 * @dataProvider provider_isHQ
51
	 */
52
	public function test_isHQ(int $typeID, bool $expected): void {
53
		$loc = AbstractSmrLocation::getLocation($typeID);
54
		self::assertSame($expected, $loc->isHQ());
55
	}
56
57
	/**
58
	 * @return array<array{int, bool}>
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<array{int, bool}> at position 4 could not be parsed: Expected ':' at position 4, but found 'int'.
Loading history...
59
	 */
60
	public function provider_isHQ(): array {
61
		return [
62
			[UNDERGROUND, false],
63
			[LOCATION_TYPE_FEDERAL_BEACON, false],
64
			[LOCATION_TYPE_FEDERAL_HQ, true],
65
			[LOCATION_TYPE_FEDERAL_MINT, false],
66
		];
67
	}
68
69
	/**
70
	 * @dataProvider provider_isBank
71
	 */
72
	public function test_isBank(int $typeID, bool $expected): void {
73
		$loc = AbstractSmrLocation::getLocation($typeID);
74
		self::assertSame($expected, $loc->isBank());
75
	}
76
77
	/**
78
	 * @return array<array{int, bool}>
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<array{int, bool}> at position 4 could not be parsed: Expected ':' at position 4, but found 'int'.
Loading history...
79
	 */
80
	public function provider_isBank(): array {
81
		return [
82
			[UNDERGROUND, false],
83
			[LOCATION_TYPE_FEDERAL_BEACON, false],
84
			[LOCATION_TYPE_FEDERAL_HQ, false],
85
			[LOCATION_TYPE_FEDERAL_MINT, true],
86
		];
87
	}
88
89
	/**
90
	 * @dataProvider provider_isUG
91
	 */
92
	public function test_isUG(int $typeID, bool $expected): void {
93
		$loc = AbstractSmrLocation::getLocation($typeID);
94
		self::assertSame($expected, $loc->isUG());
95
	}
96
97
	/**
98
	 * @return array<array{int, bool}>
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<array{int, bool}> at position 4 could not be parsed: Expected ':' at position 4, but found 'int'.
Loading history...
99
	 */
100
	public function provider_isUG(): array {
101
		return [
102
			[UNDERGROUND, true],
103
			[LOCATION_TYPE_FEDERAL_BEACON, false],
104
			[LOCATION_TYPE_FEDERAL_HQ, false],
105
			[LOCATION_TYPE_FEDERAL_MINT, false],
106
		];
107
	}
108
109
	/**
110
	 * @dataProvider provider_hasAction
111
	 */
112
	public function test_hasAction(int $typeID, bool $expected): void {
113
		$loc = AbstractSmrLocation::getLocation($typeID);
114
		self::assertSame($expected, $loc->hasAction());
115
	}
116
117
	/**
118
	 * @return array<array{int, bool}>
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<array{int, bool}> at position 4 could not be parsed: Expected ':' at position 4, but found 'int'.
Loading history...
119
	 */
120
	public function provider_hasAction(): array {
121
		return [
122
			[UNDERGROUND, true],
123
			[LOCATION_TYPE_FEDERAL_BEACON, false],
124
			[LOCATION_TYPE_FEDERAL_HQ, true],
125
			[LOCATION_TYPE_FEDERAL_MINT, true],
126
		];
127
	}
128
129
	public function test_isShipSold(): void {
130
		$loc = AbstractSmrLocation::getLocation(RACE_WARS_SHIPS);
131
		self::assertTrue($loc->isShipSold());
132
		self::assertTrue($loc->isShipSold(SHIP_TYPE_GALACTIC_SEMI));
133
		self::assertFalse($loc->isShipSold(SHIP_TYPE_DEMONICA));
134
	}
135
136
	public function test_isWeaponSold(): void {
137
		$loc = AbstractSmrLocation::getLocation(RACE_WARS_WEAPONS);
138
		self::assertTrue($loc->isWeaponSold());
139
		self::assertTrue($loc->isWeaponSold(WEAPON_TYPE_LASER));
140
		self::assertFalse($loc->isWeaponSold(WEAPON_PLANET_TURRET));
141
	}
142
143
}
144