LeaguesPageTest::getUsersLeagues()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 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
}