Completed
Push — master ( 6f4e11...e12aed )
by Matthijs
11:15 queued 07:09
created

DiscovererSetTest::testConstructor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 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()
30
    {
31
        parent::setUp();
32
    }
33
34
    /**
35
     * @covers VDB\Spider\Discoverer\DiscovererSet
36
     */
37
    public function testConstructor()
0 ignored issues
show
Duplication introduced by Matthijs van den Bos
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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()
0 ignored issues
show
Duplication introduced by Matthijs van den Bos
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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()
0 ignored issues
show
Duplication introduced by Matthijs van den Bos
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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