Completed
Push — master ( e0b1d7...ca5e79 )
by Matthijs
10:30 queued 07:23
created

DiscovererTestCase::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 0 Features 2
Metric Value
c 5
b 0
f 2
dl 0
loc 22
rs 9.2
cc 1
eloc 12
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 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