GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

HateoasTest::setUp()   B
last analyzed

Complexity

Conditions 5
Paths 1

Size

Total Lines 24
Code Lines 15

Duplication

Lines 24
Ratio 100 %

Importance

Changes 0
Metric Value
dl 24
loc 24
rs 8.5125
c 0
b 0
f 0
cc 5
eloc 15
nc 1
nop 0
1
<?php
2
3
namespace Hateoas\Tests;
4
5
use Hateoas\HateoasBuilder;
6
use Hateoas\UrlGenerator\CallableUrlGenerator;
7
use Hateoas\Tests\Fixtures\Will;
8
9
class HateoasTest extends \PHPUnit_Framework_TestCase
10
{
11
    private $hateoas;
12
13 View Code Duplication
    protected function setUp()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
    {
15
        $this->hateoas = HateoasBuilder::create()
16
            ->setUrlGenerator(null, new CallableUrlGenerator(function ($name, $parameters, $absolute) {
17
                if ($name === 'user_get') {
18
                    return sprintf(
19
                        '%s%s',
20
                        $absolute ? 'http://example.com' : '',
21
                        strtr('/users/id', $parameters)
22
                    );
23
                }
24
25
                if ($name === 'post_get') {
26
                    return sprintf(
27
                        '%s%s',
28
                        $absolute ? 'http://example.com' : '',
29
                        strtr('/posts/id', $parameters)
30
                    );
31
                }
32
33
                throw new \RuntimeException('Cannot generate URL');
34
            }))
35
            ->build();
36
    }
37
38
    public function testGetLinkHrefUrlWithUnknownRelShouldReturnNull()
39
    {
40
        $this->assertNull($this->hateoas->getLinkHelper()->getLinkHref(new Will(123), 'unknown-rel'));
41
        $this->assertNull($this->hateoas->getLinkHelper()->getLinkHref(new Will(123), 'unknown-rel', true));
42
    }
43
44
    public function testGetLinkHrefUrl()
45
    {
46
        $this->assertEquals('/users/123', $this->hateoas->getLinkHelper()->getLinkHref(new Will(123), 'self'));
47
        $this->assertEquals('/users/123', $this->hateoas->getLinkHelper()->getLinkHref(new Will(123), 'self', false));
48
    }
49
50
    public function testGetLinkHrefUrlWithAbsoluteTrue()
51
    {
52
        $this->assertEquals('http://example.com/users/123', $this->hateoas->getLinkHelper()->getLinkHref(new Will(123), 'self', true));
53
    }
54
}
55