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.
Completed
Push — master ( 3026de...146550 )
by William
14s
created

Tests/Expression/LinkExpressionFunctionTest.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Hateoas\Tests\Expression;
4
5
use Hateoas\Expression\ExpressionEvaluator;
6
use Hateoas\Expression\LinkExpressionFunction;
7
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
8
9
class LinkExpressionFunctionTest extends \PHPUnit_Framework_TestCase
10
{
11
    public function testEvaluate()
12
    {
13
        $object = new \StdClass();
14
15
        $linkHelperMock = $this->mockHelper('/foo', $object, 'self', false);
16
17
        $expressionEvaluator = new ExpressionEvaluator(new ExpressionLanguage());
18
        $expressionEvaluator->registerFunction(new LinkExpressionFunction($linkHelperMock));
19
20
        $this->assertEquals(
21
            '/foo',
22
            $expressionEvaluator->evaluate('expr(link(object, "self", false))', $object)
23
        );
24
    }
25
26
    public function testCompile()
27
    {
28
        $object = new \StdClass();
29
30
        $linkHelperMock = $this->mockHelper('/foo', $object, 'self', false);
31
32
        $expressionLanguage = new ExpressionLanguage();
33
        $expressionEvaluator = new ExpressionEvaluator($expressionLanguage);
34
        $expressionEvaluator->registerFunction(new LinkExpressionFunction($linkHelperMock));
35
36
        $compiledExpression = $expressionLanguage->compile('link(object, "self", false)', array('object', 'link_helper'));
37
38
        // setup variables for expression eval
39
        $object = $object;
40
        $link_helper = $linkHelperMock;
41
42
        $this->assertEquals('/foo', eval(sprintf('return %s;', $compiledExpression)));
43
    }
44
45
    /**
46
     * @param string $result
47
     * @param \stdClass $expectedObject
48
     * @param string $expectedRel
49
     * @param boolean $expectedAbsolute
50
     *
51
     * @return \Hateoas\Helper\LinkHelper
52
     */
53
    private function mockHelper($result, $expectedObject, $expectedRel, $expectedAbsolute)
0 ignored issues
show
The parameter $result is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
54
    {
55
        $linkHelperMock = $this
56
            ->getMockBuilder('Hateoas\Helper\LinkHelper')
57
            ->disableOriginalConstructor()
58
            ->getMock()
59
        ;
60
61
        $linkHelperMock
62
            ->expects($this->once())
63
            ->method('getLinkHref')
64
            ->will($this->returnValue('/foo'))
65
            ->with($expectedObject, $expectedRel, $expectedAbsolute)
66
        ;
67
68
        return $linkHelperMock;
69
    }
70
}
71