LeaguesPageTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 54
ccs 23
cts 23
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testLeaguesIndexPage() 0 6 1
A testShowAdminsLeagues() 0 5 1
A testShowPlayersLeagues() 0 5 1
A testShowNewUsersLeagues() 0 7 1
A getUsersLeagues() 0 6 1
1
<?php
2
3
class LeaguesPageTest extends \TestCase {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
5
	/**
6
	 * Test leagues index page and make sure at least one is found
7
	 */
8 1
	public function testLeaguesIndexPage() {
9 1
		$crawler = $this->client->request('GET', route('league.index'));
10
11 1
		$this->assertResponseOk();
12 1
		$this->assertEquals(0, $crawler->filter('.league-info')->count(), 'More than 1 league found');
13 1
	}
14
15
	/**
16
	 * Make sure admins see their leagues
17
	 */
18 1
	public function testShowAdminsLeagues() {
19 1
		$this->be(User::find(1));
20
21 1
		$this->getUsersLeagues(1);
22 1
	}
23
24
	/**
25
	 * Make sure players see their leagues
26
	 */
27 1
	public function testShowPlayersLeagues() {
28 1
		$this->be(User::find(2));
29
30 1
		$this->getUsersLeagues(1);
31 1
	}
32
33
	/**
34
	 * But not just anyone
35
	 */
36 1
	public function testShowNewUsersLeagues() {
37 1
		$new_user = User::create(['username' => 'test']);
38
39 1
		$this->be($new_user);
40
41 1
		$this->getUsersLeagues(0);
42 1
	}
43
44
	/**
45
	 * Check that the user has as many leagues as asked for
46
	 *
47
	 * @param int $expected
48
	 */
49 3
	protected function getUsersLeagues($expected = 0) {
50 3
		$crawler = $this->client->request('GET', route('league.mine'));
51
52 3
		$this->assertResponseOk();
53 3
		$this->assertEquals($expected, $crawler->filter('.league-info')->count(), 'Amount of leagues');
54 3
	}
55
56
}