Passed
Push — master ( e0b1d7...ca5e79 )
by Matthijs
07:20
created

DiscovererTestCase   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 8
Bugs 0 Features 3
Metric Value
wmc 1
c 8
b 0
f 3
lcom 1
cbo 5
dl 0
loc 37
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 22 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 DOMDocument;
15
use DOMElement;
16
use Guzzle\Http\Message\Response;
17
use VDB\Spider\Resource;
18
use VDB\Spider\Spider;
19
use VDB\Spider\Tests\TestCase;
20
use VDB\Spider\Uri\DiscoveredUri;
21
use VDB\Uri\Uri;
22
23
abstract class DiscovererTestCase extends TestCase
24
{
25
    /** @var DomDocument */
26
    protected $domDocument;
27
28
    /** @var DomElement */
29
    protected $domAnchor;
30
31
    /** @var Resource */
32
    protected $spiderResource;
33
34
    /** @var DiscoveredUri */
35
    protected $uri;
36
37
    protected function setUp()
38
    {
39
        // Setup DOM
40
        $this->domDocument = new \DOMDocument('1', 'UTF-8');
0 ignored issues
show
Documentation Bug introduced by
It seems like new \DOMDocument('1', 'UTF-8') of type object<DOMDocument> is incompatible with the declared type object<VDB\Spider\Tests\Discoverer\DomDocument> of property $domDocument.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
41
42
        $html = $this->domDocument->createElement('html');
43
        $this->domAnchor = $this->domDocument->createElement('a', 'fake');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->domDocument->createElement('a', 'fake') of type object<DOMElement> is incompatible with the declared type object<VDB\Spider\Tests\Discoverer\DomElement> of property $domAnchor.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
44
        $this->domAnchor->setAttribute('href', 'http://php-spider.org/contact/');
45
46
        $this->domDocument->appendChild($html);
47
        $html->appendChild($this->domAnchor);
48
49
        $this->uri = new DiscoveredUri(new Uri($this->domAnchor->getAttribute('href')));
50
51
        // Setup Spider\Resource
52
        $content = $this->domDocument->saveHTML();
53
54
        $this->spiderResource = new Resource(
55
            $this->uri,
56
            new Response(200, null, $content)
57
        );
58
    }
59
}
60