Passed
Branch develop (bae466)
by Paul
06:12
created

UrlTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 15
dl 0
loc 26
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_query() 0 6 1
A test_path() 0 9 1
A test_home() 0 5 1
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Tests;
4
5
use GeminiLabs\SiteReviews\Helpers\Url;
6
use WP_UnitTestCase;
0 ignored issues
show
Bug introduced by
The type WP_UnitTestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
/**
9
 * Test case for the Plugin.
10
 * @group plugin
11
 */
12
class UrlTest extends WP_UnitTestCase
13
{
14
    public function test_home()
15
    {
16
        $url = network_home_url();
17
        $this->assertEquals(Url::home(), $url.'/');
18
        $this->assertEquals(Url::home('test'), $url.'/test/');
19
    }
20
21
    public function test_path()
22
    {
23
        $url = 'https://test.com';
24
        $this->assertEquals(Url::path($url), '');
25
        $this->assertEquals(Url::path($url.'/'), '');
26
        $this->assertEquals(Url::path($url.'/test'), '/test');
27
        $this->assertEquals(Url::path($url.'/test/'), '/test');
28
        $this->assertEquals(Url::path($url.'/test/dir'), '/test/dir');
29
        $this->assertEquals(Url::path($url.'/test/dir/'), '/test/dir');
30
    }
31
32
    public function test_query()
33
    {
34
        $url = 'https://test.com?abc=xyz';
35
        $this->assertEquals(Url::query($url, 'abc'), 'xyz');
36
        $this->assertEquals(Url::query($url, 'ab', '123'), '123');
37
        $this->assertNull(Url::query($url, 'ab'));
38
    }
39
}
40