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 — main ( d9cfb9...10f5c7 )
by Dan
32s queued 21s
created

PlayerLevelTest::test_get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 10
rs 10
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace SmrTest\lib\DefaultGame;
4
5
use Exception;
6
use PHPUnit\Framework\TestCase;
7
use Smr\PlayerLevel;
8
9
/**
10
 * @covers Smr\PlayerLevel
11
 */
12
class PlayerLevelTest extends TestCase {
13
14
	public static function setUpBeforeClass(): void {
15
		// Make sure cache is clear so we can cover the cache population code
16
		PlayerLevel::clearCache();
17
	}
18
19
	public function test_get(): void {
20
		// Test that we calculate level from exp properly
21
		$exp = 49240;
22
		$level = PlayerLevel::get($exp);
23
		$expected = new PlayerLevel(22, 'Lieutenant 2nd Class', 44765);
24
		self::assertEquals($expected, $level);
25
		self::assertGreaterThanOrEqual($level->expRequired, $exp); // B >= A
26
27
		// Make sure the next level has more exp
28
		self::assertLessThan($level->next()->expRequired, $exp); // B < A
29
	}
30
31
	public function test_get_invalid_exp(): void {
32
		// If we pass an invalid amount of exp, we throw
33
		$this->expectException(Exception::class);
34
		$this->expectExceptionMessage('Failed to properly determine level from exp: -1');
35
		PlayerLevel::get(-1);
36
	}
37
38
	public function test_getMax(): void {
39
		self::assertSame(50, PlayerLevel::getMax());
40
	}
41
42
	/**
43
	 * @testWith [1, 2]
44
	 *           [49, 50]
45
	 *           [50, 50]
46
	 */
47
	public function test_next(int $levelID, int $nextLevelID): void {
48
		$level = new PlayerLevel($levelID, '', 0);
49
		self::assertSame($nextLevelID, $level->next()->id);
50
	}
51
52
}
53