Completed
Push — master ( dda887...1f2752 )
by George
32:55 queued 32:55
created

SiteCheckerTest::testParser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 20
rs 9.4285
cc 1
eloc 13
nc 1
nop 0
1
<?php
2
3
namespace SiteChecker\Test;
4
5
use SiteChecker\Asset;
6
use SiteChecker\SiteChecker;
7
8
class SiteCheckerTest extends \PHPUnit_Framework_TestCase
9
{
10
11
    /**
12
     * Use reflection to test protected methods.
13
     *
14
     * @param $obj
15
     * @param $name
16
     * @param array $args
17
     * @return mixed
18
     */
19
    protected static function callMethod($obj, $name, array $args)
20
    {
21
        $class = new \ReflectionClass($obj);
22
        $method = $class->getMethod($name);
23
        $method->setAccessible(true);
24
        return $method->invokeArgs($obj, $args);
25
    }
26
27
    /**
28
     * @test
29
     */
30
    public function testParser()
31
    {
32
        $siteChecker = SiteChecker::create();
33
        $html = '<a href="/xxx"></a><img src="/yyy">';
34
35
        /** @var Asset[] $assets */
36
        $assets = self::callMethod(
37
            $siteChecker,
38
            'getAllAssets',
39
            array($html, null)
40
        );
41
42
        $link = $assets[0];
43
        $this->assertEquals('/xxx', $link->getPath());
44
        $this->assertEquals('page', $link->getType());
45
46
        $image = $assets[1];
47
        $this->assertEquals('/yyy', $image->getPath());
48
        $this->assertEquals('image', $image->getType());
49
    }
50
}
51