AdminPageTest::testAdminHomepage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
crap 1
1
<?php
2
3
class AdminPageTest 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
	 * Make sure public can't access admin pages
7
	 *
8
	 * @dataProvider pubUsers
9
	 *
10
	 * @param callable $userCb
11
	 *
12
	 * @return void
13
	 */
14 2
	public function testMakeSurePublicCantAccess($userCb) {
15
		// Set current user
16 2
		$user = $userCb();
17 2
		$this->flushSession();
18 2
		Route::enableFilters();
19 2
		if ($user) {
20
			$this->be($user);
21
		}
22
23
		// get admin homepage
24 2
		$this->client->request('GET', '/admin');
25
26 2
		$this->assertTrue($this->client->getResponse()->isRedirection());
27
28 2
		Route::disableFilters();
29 2
	}
30
31
	/**
32
	 * Return public users to test with.
33
	 * Because this is ran before application is created it returns callbacks.
34
	 *
35
	 * @return array
36
	 */
37 1
	public function pubUsers() {
38
		return [
39
			[function () {
40 1
				return null;
41
			}], // Not logged in
42 1
			[function () {
43 1
				User::find(2);
44 1
			}], // Nonadmin user
45
		];
46
	}
47
48 1
	public function testAdminHomepage() {
49
		/** @type User $user */
50 1
		$user = User::find(1);
51 1
		$this->be($user);
52
53 1
		$this->client->request('GET', '/admin');
54
55 1
		$this->assertTrue($this->client->getResponse()->isOk());
56 1
	}
57
}
58