Completed
Push1978d2...e2f699
passed — Build
created

CallableUrlGeneratorTest::test()   A

↳ Parent: CallableUrlGeneratorTest

Complexity

Conditions 1
Paths 1

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 22
Code Lines 15

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 22
rs 9.2
cc 1
eloc 15
nc 1
nop 0
1
<?php
2
3
namespace Hateoas\Tests\UrlGenerator;
4
5
use Hateoas\Tests\TestCase;
6
use Hateoas\UrlGenerator\CallableUrlGenerator;
7
8
class CallableUrlGeneratorTest extends TestCase
9
{
10
    public function test()
11
    {
12
        $expectedName = 'user_get';
13
        $expectedParameters = array('id' => 42);
14
        $expectedAbsolute = true;
15
        $expectedResult = '/users/42';
16
17
        $test = $this;
18
        $callable = function ($name, $parameters, $absolute) use ($expectedName, $expectedParameters, $expectedResult, $expectedAbsolute, $test) {
19
            $test->assertSame($expectedName, $name);
20
            $test->assertSame($expectedParameters, $parameters);
21
            $test->assertSame($expectedAbsolute, $absolute);
22
23
            return $expectedResult;
24
        };
25
        $urlGenerator = new CallableUrlGenerator($callable);
26
27
        $this->assertSame(
28
            $expectedResult,
29
            $urlGenerator->generate($expectedName, $expectedParameters, $expectedAbsolute)
30
        );
31
    }
32
}
33