Passed
Branch feature/cleanup (2bd333)
by Matthijs
06:03
created

DiscovererTestCase   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 6
Bugs 0 Features 3
Metric Value
wmc 1
c 6
b 0
f 3
lcom 1
cbo 4
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\Uri\Uri;
21
22
abstract class DiscovererTestCase extends TestCase
23
{
24
    /** @var DomDocument */
25
    protected $domDocument;
26
27
    /** @var DomElement */
28
    protected $domAnchor;
29
30
    /** @var Resource */
31
    protected $spiderResource;
32
33
    /** @var Uri */
34
    protected $uri;
35
36
    protected function setUp()
37
    {
38
        // Setup DOM
39
        $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...
40
41
        $html = $this->domDocument->createElement('html');
42
        $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...
43
        $this->domAnchor->setAttribute('href', 'http://php-spider.org/contact/');
44
45
        $this->domDocument->appendChild($html);
46
        $html->appendChild($this->domAnchor);
47
48
        $this->uri = new Uri($this->domAnchor->getAttribute('href'));
49
50
        // Setup Spider\Resource
51
        $content = $this->domDocument->saveHTML();
52
53
        $this->spiderResource = new Resource(
54
            $this->uri,
55
            new Response(200, null, $content)
56
        );
57
    }
58
}
59