1 | <?php |
||
7 | class CompareUrlTest extends TestCase |
||
8 | { |
||
9 | protected function makeComparativeUrl($currentUrl) |
||
10 | { |
||
11 | $mock = $this->createMock(UrlGenerator::class); |
||
12 | $mock->method('current')->willReturn(url($currentUrl)); |
||
13 | $mock->method('to')->willReturnCallback('url'); |
||
14 | |||
15 | return new ComparativeUrl($mock, config('menu.skippedPaths')); |
||
16 | } |
||
17 | |||
18 | public function testSkipped() |
||
19 | { |
||
20 | $compare = $this->makeComparativeUrl(url('/')); |
||
21 | foreach (config('menu.skippedPaths') as $value) { |
||
22 | $this->assertFalse($compare->isEquals($value)); |
||
23 | } |
||
24 | } |
||
25 | |||
26 | public function testEquals() |
||
27 | { |
||
28 | $stub = [ |
||
29 | 'http://username:password@hostname/path?arg=value#anchor', |
||
30 | '//www.example.com/path?googleguy=googley', |
||
31 | 'http://usr:[email protected]:81/mypath/myfile.html?a=b&b[]=2&b[]=3#myfragment', |
||
32 | url('/'), |
||
33 | '/', |
||
34 | ]; |
||
35 | |||
36 | foreach ($stub as $value) { |
||
37 | $compare = $this->makeComparativeUrl($value); |
||
38 | $this->assertTrue($compare->isEquals($value)); |
||
39 | } |
||
40 | } |
||
41 | |||
42 | public function testPaths() |
||
43 | { |
||
44 | $index = $this->makeComparativeUrl(url('/')); |
||
45 | $this->assertFalse($index->isEquals(url('profile'))); |
||
46 | |||
47 | $profile = $this->makeComparativeUrl(url('profile')); |
||
48 | $this->assertFalse($profile->isEquals(url('/'))); |
||
49 | } |
||
50 | } |