mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 23:59:26 +03:00
Fix a type hint issue in RouteDescriber
This commit is contained in:
parent
fd6d9ac7a7
commit
f6f91562d9
@ -48,7 +48,7 @@ final class RouteDescriber implements DescriberInterface
|
||||
|
||||
foreach ($this->routeCollection->all() as $route) {
|
||||
// if able to resolve the controller
|
||||
if ($method = $this->getReflectionMethod($route->getDefault('_controller'))) {
|
||||
if ($method = $this->getReflectionMethod($route->getDefault('_controller') ?? '')) {
|
||||
// Extract as many informations as possible about this route
|
||||
foreach ($this->routeDescribers as $describer) {
|
||||
$describer->describe($api, $route, $method);
|
||||
|
47
Tests/Describer/RouteDescriberTest.php
Normal file
47
Tests/Describer/RouteDescriberTest.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the ApiDocBundle package.
|
||||
*
|
||||
* (c) EXSyst
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace EXSyst\Bundle\ApiDocBundle\Tests\Describer;
|
||||
|
||||
use EXSyst\Bundle\ApiDocBundle\Describer\RouteDescriber;
|
||||
use EXSyst\Bundle\ApiDocBundle\RouteDescriber\RouteDescriberInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use EXSyst\Component\Swagger\Swagger;
|
||||
|
||||
class RouteDescriberTest extends AbstractDescriberTest
|
||||
{
|
||||
private $routes;
|
||||
private $routeDescriber;
|
||||
|
||||
public function testIgnoreWhenNoController()
|
||||
{
|
||||
$this->routes->add('foo', new Route('foo'));
|
||||
$this->routeDescriber->expects($this->never())
|
||||
->method('describe');
|
||||
|
||||
$this->assertEquals((new Swagger())->toArray(), $this->getSwaggerDoc()->toArray());
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->routeDescriber = $this->createMock(RouteDescriberInterface::class);
|
||||
$this->routes = new RouteCollection();
|
||||
$this->describer = new RouteDescriber(
|
||||
new Container(),
|
||||
$this->routes,
|
||||
$this->createMock(ControllerNameParser::class),
|
||||
[ $this->routeDescriber ]
|
||||
);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user