TestCase::buildResourceFromFixture()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 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;
13
14
use GuzzleHttp\Psr7\Response;
15
use VDB\Spider\Resource;
16
use VDB\Spider\Uri\DiscoveredUri;
17
use VDB\Uri\Uri;
18
19
use PHPUnit\Framework\TestCase as PHPUnitTestCase;
20
21
/**
22
 *
23
 */
24
class TestCase extends PHPUnitTestCase
25
{
26
    /**
27
     * @param DiscoveredUri $uri
28
     * @param Response $response
29
     * @return Resource
30
     */
31
    protected function getResource(DiscoveredUri $uri, Response $response)
32
    {
33
        return new Resource($uri, $response);
34
    }
35
36
    protected function buildResourceFromFixture($fixturePath, $uriString)
37
    {
38
        return $this->getResource(
39
            new DiscoveredUri(new Uri($uriString)),
40
            new Response(200, [], $this->getFixtureContent($fixturePath))
41
        );
42
    }
43
44
    /**
45
     * @param $filePath /absolute/path/to/fixure
0 ignored issues
show
Documentation Bug introduced by
The doc comment /absolute/path/to/fixure at position 0 could not be parsed: Unknown type name '/absolute/path/to/fixure' at position 0 in /absolute/path/to/fixure.
Loading history...
46
     */
47
    protected function getFixtureContent($filePath)
48
    {
49
        return file_get_contents($filePath);
50
    }
51
}
52