|
15 | 15 | use PHPUnit\Framework\TestCase;
|
16 | 16 | use Psr\Log\LoggerInterface;
|
17 | 17 | use Symfony\Cmf\Component\Routing\ChainRouter;
|
| 18 | +use Symfony\Cmf\Component\Routing\RouteObjectInterface; |
18 | 19 | use Symfony\Cmf\Component\Routing\VersatileGeneratorInterface;
|
19 | 20 | use Symfony\Component\HttpFoundation\Request;
|
20 | 21 | use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
|
@@ -717,6 +718,54 @@ public function testGenerateObjectName()
|
717 | 718 | $this->assertEquals($name, $result);
|
718 | 719 | }
|
719 | 720 |
|
| 721 | + public function testGenerateWithObjectNameInParametersNotFoundVersatile() |
| 722 | + { |
| 723 | + $name = RouteObjectInterface::OBJECT_BASED_ROUTE_NAME; |
| 724 | + $parameters = ['test' => 'value', '_route_object' => new \stdClass()]; |
| 725 | + |
| 726 | + $chainedRouter = $this->createMock(VersatileRouter::class); |
| 727 | + $chainedRouter |
| 728 | + ->expects($this->once()) |
| 729 | + ->method('supports') |
| 730 | + ->willReturn(true) |
| 731 | + ; |
| 732 | + $chainedRouter->expects($this->once()) |
| 733 | + ->method('generate') |
| 734 | + ->with($name, $parameters, UrlGeneratorInterface::ABSOLUTE_PATH) |
| 735 | + ->will($this->throwException(new RouteNotFoundException())) |
| 736 | + ; |
| 737 | + $chainedRouter->expects($this->once()) |
| 738 | + ->method('getRouteDebugMessage') |
| 739 | + ->with($name, $parameters) |
| 740 | + ->willReturn('message') |
| 741 | + ; |
| 742 | + |
| 743 | + $this->router->add($chainedRouter, 10); |
| 744 | + |
| 745 | + $this->expectException(RouteNotFoundException::class); |
| 746 | + $this->router->generate($name, $parameters); |
| 747 | + } |
| 748 | + |
| 749 | + public function testGenerateWithObjectNameInParameters() |
| 750 | + { |
| 751 | + $name = RouteObjectInterface::OBJECT_BASED_ROUTE_NAME; |
| 752 | + $parameters = ['test' => 'value', '_route_object' => new \stdClass()]; |
| 753 | + |
| 754 | + $defaultRouter = $this->createMock(RouterInterface::class); |
| 755 | + |
| 756 | + $defaultRouter |
| 757 | + ->expects($this->once()) |
| 758 | + ->method('generate') |
| 759 | + ->with($name, $parameters, UrlGeneratorInterface::ABSOLUTE_PATH) |
| 760 | + ->willReturn($name) |
| 761 | + ; |
| 762 | + |
| 763 | + $this->router->add($defaultRouter, 200); |
| 764 | + |
| 765 | + $result = $this->router->generate($name, $parameters); |
| 766 | + $this->assertEquals($name, $result); |
| 767 | + } |
| 768 | + |
720 | 769 | public function testWarmup()
|
721 | 770 | {
|
722 | 771 | $dir = 'test_dir';
|
|
0 commit comments