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 (#1082)
by Dan
05:43
created

UserRankingTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A test_getMinScoreForRank() 0 7 2
A test_getAllNames() 0 2 1
A test_score_limits() 0 7 1
A test_getName() 0 2 1
A test_rank_limits() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace SmrTest\lib\DefaultGame;
4
5
use Smr\UserRanking;
6
7
/**
8
 * @covers Smr\UserRanking
9
 */
10
class UserRankingTest extends \PHPUnit\Framework\TestCase {
11
12
	public function test_getName() {
13
		$this->assertSame('Expert', UserRanking::getName(6));
14
	}
15
16
	public function test_getAllNames() {
17
		$this->assertSame('Expert', UserRanking::getAllNames()[6]);
18
	}
19
20
	public function test_rank_limits() {
21
		$ranks = array_keys(UserRanking::getAllNames());
22
		$this->assertSame(UserRanking::MIN_RANK, min($ranks));
23
		$this->assertSame(UserRanking::MAX_RANK, max($ranks));
24
	}
25
26
	public function test_score_limits() {
27
		// test the lowest possible score
28
		$rank = UserRanking::getRankFromScore(0);
29
		$this->assertSame(UserRanking::MIN_RANK, $rank);
30
		// test an absurdly high score
31
		$rank = UserRanking::getRankFromScore(PHP_INT_MAX);
32
		$this->assertSame(UserRanking::MAX_RANK, $rank);
33
	}
34
35
	public function test_getMinScoreForRank() {
36
		// test all ranks
37
		foreach (UserRanking::getAllNames() as $rank => $name) {
38
			$minScore = UserRanking::getMinScoreForRank($rank);
39
			// make sure the given min score is still the same rank
40
			$rankFromScore = UserRanking::getRankFromScore($minScore);
41
			$this->assertSame($rank, $rankFromScore);
42
		}
43
	}
44
45
}
46