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
Pull Request — master (#1088)
by Dan
06:20
created

SmrShipTypeTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 40
dl 0
loc 57
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_getAll_matches_get() 0 5 1
A test_one_ship_properties() 0 29 2
A test_can_have_special_hardware() 0 16 1
1
<?php declare(strict_types=1);
2
3
namespace SmrTest\lib\DefaultGame;
4
5
use SmrShipType;
6
use Smr\ShipClass;
7
8
/**
9
 * @covers SmrShipType
10
 */
11
class SmrShipTypeTest extends \PHPUnit\Framework\TestCase {
12
13
	public function test_one_ship_properties() {
14
		// Test all properties of one particular ship (Fed Ult)
15
		$shipType = SmrShipType::get(SHIP_TYPE_FEDERAL_ULTIMATUM);
16
17
		$this->assertSame(SHIP_TYPE_FEDERAL_ULTIMATUM, $shipType->getTypeID());
18
		$this->assertSame(ShipClass::RAIDER, $shipType->getClassID());
19
		$this->assertSame('Federal Ultimatum', $shipType->getName());
20
		$this->assertSame(38675738, $shipType->getCost());
21
		$this->assertSame(BUYER_RESTRICTION_GOOD, $shipType->getRestriction());
22
		$this->assertSame(8, $shipType->getSpeed());
23
		$this->assertSame(7, $shipType->getHardpoints());
24
		$this->assertSame(24, $shipType->getMaxPower());
25
26
		$hardware = [
27
			HARDWARE_SHIELDS => 700,
28
			HARDWARE_ARMOUR => 600,
29
			HARDWARE_CARGO => 120,
30
			HARDWARE_COMBAT => 120,
31
			HARDWARE_SCOUT => 15,
32
			HARDWARE_MINE => 0,
33
			HARDWARE_SCANNER => 1,
34
			HARDWARE_CLOAK => 0,
35
			HARDWARE_ILLUSION => 0,
36
			HARDWARE_JUMP => 1,
37
			HARDWARE_DCS => 0,
38
		];
39
		$this->assertSame($hardware, $shipType->getAllMaxHardware());
40
		foreach ($hardware as $hardwareID => $amount) {
41
			$this->assertSame($amount, $shipType->getMaxHardware($hardwareID));
42
		}
43
	}
44
45
	public function test_getAll_matches_get() {
46
		// Check that we get the same ship type from get and getAll
47
		$shipType1 = SmrShipType::get(SHIP_TYPE_GALACTIC_SEMI);
48
		$shipType2 = SmrShipType::getAll()[SHIP_TYPE_GALACTIC_SEMI];
49
		$this->assertSame($shipType1, $shipType2);
50
	}
51
52
	public function test_can_have_special_hardware() {
53
		// Demonica has all special hardware
54
		$shipType = SmrShipType::get(SHIP_TYPE_DEMONICA);
55
		$this->assertTrue($shipType->canHaveJump());
56
		$this->assertTrue($shipType->canHaveDCS());
57
		$this->assertTrue($shipType->canHaveScanner());
58
		$this->assertTrue($shipType->canHaveCloak());
59
		$this->assertTrue($shipType->canHaveIllusion());
60
61
		// Galactic Semi has no special hardware
62
		$shipType = SmrShipType::get(SHIP_TYPE_GALACTIC_SEMI);
63
		$this->assertFalse($shipType->canHaveJump());
64
		$this->assertFalse($shipType->canHaveDCS());
65
		$this->assertFalse($shipType->canHaveScanner());
66
		$this->assertFalse($shipType->canHaveCloak());
67
		$this->assertFalse($shipType->canHaveIllusion());
68
	}
69
70
}
71