AllowedSchemeFilterTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testMatch() 0 14 1
1
<?php
2
3
/*
4
 * This file is part of the Spider package.
5
 *
6
 * (c) Matthijs van den Bos <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace VDB\Spider\Tests\Filter\Prefetch;
13
14
use VDB\Spider\Filter\Prefetch\AllowedSchemeFilter;
15
use VDB\Spider\Tests\TestCase;
16
use VDB\Uri\Uri;
17
18
/**
19
 *
20
 */
21
class AllowedSchemeFilterTest extends TestCase
22
{
23
    /**
24
     * @covers VDB\Spider\Filter\Prefetch\AllowedSchemeFilter
25
     */
26
    public function testMatch()
27
    {
28
        $filter = new AllowedSchemeFilter(array('http'));
29
30
        $currentUri = 'http://php-spider.org';
31
        $uri =  new Uri('http://php-spider.org');
32
        $uri2 = new Uri('https://php-spider.org');
33
        $uri3 = new Uri('#', $currentUri);
34
        $uri4 = new Uri('mailto:[email protected]');
35
36
        $this->assertFalse($filter->match($uri), 'HTTP scheme filtered');
37
        $this->assertTrue($filter->match($uri2), 'HTTPS scheme filtered');
38
        $this->assertFalse($filter->match($uri3), 'empty/no scheme filtered');
39
        $this->assertTrue($filter->match($uri4), 'MAILTO scheme filtered');
40
    }
41
}
42