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

DiscovererSetTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 1
cbo 4
dl 0
loc 49
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testConstructor() 0 7 1
A testSetDiscoverer() 0 8 1
A testFilter() 0 9 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\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
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
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
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