Add test case for route annotation with optional parameters

This commit is contained in:
Stefan Blanke 2019-10-23 14:30:23 +02:00
parent e2b34f1e7e
commit 9edff1852a
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,44 @@
<?php
namespace App\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Routing\Annotation\Route;
class WithRouteOptions
{
/**
* @Route("/{category}", name="report_overview", defaults={"category" = null}, requirements={"category" = "\d+"})
* @Template("PAPPReportBundle:Report:report_list.html.twig")
*/
public function index($category = null)
{
return [
'category' => $category,
];
}
}
?>
-----
<?php
namespace App\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Routing\Annotation\Route;
class WithRouteOptions
{
/**
* @Route("/{category}", name="report_overview", defaults={"category" = null}, requirements={"category" = "\d+"})
*/
public function index($category = null)
{
return $this->render('PAPPReportBundle:Report:report_list.html.twig', [
'category' => $category,
]);
}
}
?>

View File

@ -26,6 +26,7 @@ final class TemplateAnnotationVersion5RectorTest extends AbstractRectorTestCase
yield [__DIR__ . '/Fixture/Version5/fixture4.php.inc'];
yield [__DIR__ . '/Fixture/Version5/fixture5.php.inc'];
yield [__DIR__ . '/Fixture/Version5/with_route_too.php.inc'];
yield [__DIR__ . '/Fixture/Version5/with_route_options.php.inc'];
}
/**