@@ 13-36 (lines=24) @@ | ||
10 | { |
|
11 | private $hateoas; |
|
12 | ||
13 | protected function setUp() |
|
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 | { |
@@ 16-39 (lines=24) @@ | ||
13 | { |
|
14 | private $hateoas; |
|
15 | ||
16 | protected function setUp() |
|
17 | { |
|
18 | $this->hateoas = HateoasBuilder::create() |
|
19 | ->setUrlGenerator(null, new CallableUrlGenerator(function ($name, $parameters, $absolute) { |
|
20 | if ($name === 'user_get') { |
|
21 | return sprintf( |
|
22 | '%s%s', |
|
23 | $absolute ? 'http://example.com' : '', |
|
24 | strtr('/users/id', $parameters) |
|
25 | ); |
|
26 | } |
|
27 | ||
28 | if ($name === 'post_get') { |
|
29 | return sprintf( |
|
30 | '%s%s', |
|
31 | $absolute ? 'http://example.com' : '', |
|
32 | strtr('/posts/id', $parameters) |
|
33 | ); |
|
34 | } |
|
35 | ||
36 | throw new \RuntimeException('Cannot generate URL'); |
|
37 | })) |
|
38 | ->build(); |
|
39 | } |
|
40 | ||
41 | public function testGetLinkHref() |
|
42 | { |