|
@@ 325-344 (lines=20) @@
|
| 322 |
|
* @covers ::filterVariables |
| 323 |
|
* @covers \League\Uri\UriTemplate\Template |
| 324 |
|
*/ |
| 325 |
|
public function testExpandWithDefaultVariables(): void |
| 326 |
|
{ |
| 327 |
|
$template = 'http://example.com{+path}{/segments}{?query,more*,foo[]*}'; |
| 328 |
|
|
| 329 |
|
$defaultVariables = [ |
| 330 |
|
'path' => '/foo/bar', |
| 331 |
|
'segments' => ['one', 'two'], |
| 332 |
|
]; |
| 333 |
|
|
| 334 |
|
$variables = [ |
| 335 |
|
'query' => 'test', |
| 336 |
|
'more' => ['fun', 'ice cream'], |
| 337 |
|
'foo[]' => ['fizz', 'buzz'], |
| 338 |
|
]; |
| 339 |
|
|
| 340 |
|
self::assertSame( |
| 341 |
|
'http://example.com/foo/bar/one,two?query=test&more=fun&more=ice%20cream&foo%5B%5D=fizz&foo%5B%5D=buzz', |
| 342 |
|
(new UriTemplate($template, $defaultVariables))->expand($variables)->__toString() |
| 343 |
|
); |
| 344 |
|
} |
| 345 |
|
|
| 346 |
|
/** |
| 347 |
|
* @covers ::expand |
|
@@ 351-371 (lines=21) @@
|
| 348 |
|
* @covers ::filterVariables |
| 349 |
|
* @covers \League\Uri\UriTemplate\Template |
| 350 |
|
*/ |
| 351 |
|
public function testExpandWithDefaultVariablesWithOverride(): void |
| 352 |
|
{ |
| 353 |
|
$template = 'http://example.com{+path}{/segments}{?query,more*,foo[]*}'; |
| 354 |
|
|
| 355 |
|
$defaultVariables = [ |
| 356 |
|
'path' => '/foo/bar', |
| 357 |
|
'segments' => ['one', 'two'], |
| 358 |
|
]; |
| 359 |
|
|
| 360 |
|
$variables = [ |
| 361 |
|
'path' => '/bar/baz', |
| 362 |
|
'query' => 'test', |
| 363 |
|
'more' => ['fun', 'ice cream'], |
| 364 |
|
'foo[]' => ['fizz', 'buzz'], |
| 365 |
|
]; |
| 366 |
|
|
| 367 |
|
self::assertSame( |
| 368 |
|
'http://example.com/bar/baz/one,two?query=test&more=fun&more=ice%20cream&foo%5B%5D=fizz&foo%5B%5D=buzz', |
| 369 |
|
(new UriTemplate($template, $defaultVariables))->expand($variables)->__toString() |
| 370 |
|
); |
| 371 |
|
} |
| 372 |
|
|
| 373 |
|
/** |
| 374 |
|
* @covers \League\Uri\UriTemplate\Template |