2016-11-30 16:08:49 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2016-12-29 12:09:26 +01:00
|
|
|
* This file is part of the NelmioApiDocBundle package.
|
2016-11-30 16:08:49 +01:00
|
|
|
*
|
2016-12-29 12:09:26 +01:00
|
|
|
* (c) Nelmio
|
2016-11-30 16:08:49 +01:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2016-12-29 12:09:26 +01:00
|
|
|
namespace Nelmio\ApiDocBundle\Tests\Describer;
|
2016-11-30 16:08:49 +01:00
|
|
|
|
2016-11-30 16:52:13 +01:00
|
|
|
use EXSyst\Component\Swagger\Swagger;
|
2016-12-29 12:09:26 +01:00
|
|
|
use Nelmio\ApiDocBundle\Describer\RouteDescriber;
|
|
|
|
use Nelmio\ApiDocBundle\RouteDescriber\RouteDescriberInterface;
|
2016-12-30 13:37:02 +01:00
|
|
|
use Nelmio\ApiDocBundle\Util\ControllerReflector;
|
2016-11-30 16:08:49 +01:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
|
|
|
|
use Symfony\Component\DependencyInjection\Container;
|
|
|
|
use Symfony\Component\Routing\Route;
|
|
|
|
use Symfony\Component\Routing\RouteCollection;
|
|
|
|
|
|
|
|
class RouteDescriberTest extends AbstractDescriberTest
|
|
|
|
{
|
|
|
|
private $routes;
|
2017-12-22 17:42:18 +00:00
|
|
|
|
2016-11-30 16:08:49 +01:00
|
|
|
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(
|
|
|
|
$this->routes,
|
2016-12-30 13:37:02 +01:00
|
|
|
new ControllerReflector(
|
|
|
|
new Container(),
|
|
|
|
$this->createMock(ControllerNameParser::class)
|
|
|
|
),
|
2016-12-01 17:25:53 +01:00
|
|
|
[$this->routeDescriber]
|
2016-11-30 16:08:49 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|