Completed
Push — master ( 8878dc...665782 )
by Matthijs
03:00
created

TestCase::buildResourceFromFixture()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
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
/**
20
 *
21
 */
22
class TestCase extends \PHPUnit_Framework_TestCase
23
{
24
    /**
25
     * @param DiscoveredUri $uri
26
     * @param Response $response
27
     * @return Resource
28
     */
29
    protected function getResource(DiscoveredUri $uri, Response $response)
30
    {
31
        return new Resource($uri, $response);
32
    }
33
34
    protected function buildResourceFromFixture($fixturePath, $uriString)
35
    {
36
        return $this->getResource(
37
            new DiscoveredUri(new Uri($uriString)),
38
            new Response(200, [], $this->getFixtureContent($fixturePath))
39
        );
40
    }
41
42
    /**
43
     * @param $filePath /absolute/path/to/fixure
44
     */
45
    protected function getFixtureContent($filePath)
46
    {
47
        return file_get_contents($filePath);
48
    }
49
}
50