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 — main (#1508)
by Dan
04:48
created

PlayerLevelTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 38
rs 10
c 1
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A test_next() 0 3 1
A test_get() 0 10 1
A test_getMax() 0 2 1
A test_get_invalid_exp() 0 5 1
A setUpBeforeClass() 0 3 1
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