|
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\UriWithHashFragmentFilter; |
|
15
|
|
|
use VDB\Spider\Tests\TestCase; |
|
16
|
|
|
use VDB\Uri\Uri; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* |
|
20
|
|
|
*/ |
|
21
|
|
|
class UriWithHashFragmentFilterTest extends TestCase |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @covers VDB\Spider\Filter\Prefetch\UriWithHashFragmentFilter |
|
25
|
|
|
*/ |
|
26
|
|
|
public function testMatch() |
|
27
|
|
|
{ |
|
28
|
|
|
$filter = new UriWithHashFragmentFilter(); |
|
29
|
|
|
|
|
30
|
|
|
$currentUri = 'http://php-spider.org'; |
|
31
|
|
|
$uri1 = new Uri('#', $currentUri); |
|
32
|
|
|
$uri2 = new Uri('#foo', $currentUri); |
|
33
|
|
|
$uri3 = new Uri('http://php-spider.org/foo#bar', $currentUri); |
|
34
|
|
|
$uri4 = new Uri('http://php-spider.org/foo/#bar', $currentUri); |
|
35
|
|
|
$uri5 = new Uri('http://php-spider.org#/foo/bar', $currentUri); |
|
36
|
|
|
|
|
37
|
|
|
$this->assertTrue($filter->match($uri1), '# filtered'); |
|
38
|
|
|
$this->assertTrue($filter->match($uri2), '#foo'); |
|
39
|
|
|
$this->assertTrue($filter->match($uri3), 'http://php-spider.org/foo#bar'); |
|
40
|
|
|
$this->assertTrue($filter->match($uri4), 'http://php-spider.org/foo/#bar'); |
|
41
|
|
|
$this->asserttrue($filter->match($uri5), 'http://php-spider.org#/foo/bar'); |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|