Completed
Push — master ( 79027c...8f1f38 )
by Oleg
03:47
created

CompareUrlTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 44
rs 10
c 1
b 0
f 0
wmc 6
lcom 1
cbo 2
1
<?php
2
namespace Malezha\Menu\Tests;
3
4
use Illuminate\Routing\UrlGenerator;
5
use Malezha\Menu\Support\ComparativeUrl;
6
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
}