DiscovererSetTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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\Discoverer;
13
14
use VDB\Spider\Discoverer\XPathExpressionDiscoverer;
15
use VDB\Spider\Discoverer\DiscovererSet;
16
use VDB\Spider\Filter\Prefetch\UriFilter;
17
18
/**
19
 *
20
 */
21
class DiscovererSetTest extends DiscovererTestCase
22
{
23
    /**
24
     * @var DiscovererSet
25
     */
26
    private $discovererSet;
27
28
29
    public function setUp(): void
30
    {
31
        parent::setUp();
32
    }
33
34
    /**
35
     * @covers VDB\Spider\Discoverer\DiscovererSet
36
     */
37
    public function testConstructor()
38
    {
39
        $this->discovererSet = new DiscovererSet([new XPathExpressionDiscoverer("//a")]);
40
41
        $uris = $this->discovererSet->discover($this->spiderResource);
42
        $this->assertCount(1, $uris);
43
    }
44
45
    /**
46
     * @covers VDB\Spider\Discoverer\DiscovererSet
47
     */
48
    public function testSetDiscoverer()
49
    {
50
        $this->discovererSet = new DiscovererSet();
51
        $this->discovererSet->set(new XPathExpressionDiscoverer("//a"));
52
53
        $uris = $this->discovererSet->discover($this->spiderResource);
54
        $this->assertCount(1, $uris);
55
    }
56
57
    /**
58
     * @covers VDB\Spider\Discoverer\DiscovererSet
59
     */
60
    public function testFilter()
61
    {
62
        $this->discovererSet = new DiscovererSet([new XPathExpressionDiscoverer("//a")]);
63
64
        $this->discovererSet->addFilter(new UriFilter(['/^.*contact.*$/']));
65
66
        $uris = $this->discovererSet->discover($this->spiderResource);
67
        $this->assertCount(0, $uris);
68
    }
69
}
70