NelmioApiDocBundle/Tests/Util/ControllerReflectorTest.php
Alexey Alshenetsky 7de49bb4a8
Add missing null check to ControllerReflector::getReflectionMethod (#1918)
* add null check

https://github.com/nelmio/NelmioApiDocBundle/issues/1909

* less code is better

* add tests for ControllerReflection::getReflectionMethod()

* lint fix

* style_ci fixes

Co-authored-by: Alexey <alshenestky@icloud.com>
2021-12-12 01:32:51 +01:00

30 lines
1.0 KiB
PHP

<?php
namespace Nelmio\ApiDocBundle\Tests\Util;
use Nelmio\ApiDocBundle\Tests\Functional\Controller\BazingaController;
use Nelmio\ApiDocBundle\Util\ControllerReflector;
use PHPUnit\Framework\TestCase;
use ReflectionMethod;
use Symfony\Component\DependencyInjection\Container;
class ControllerReflectorTest extends TestCase
{
public function testGetReflectionMethod(): void
{
$controllerReflector = new ControllerReflector(new Container());
$this->assertEquals(
ReflectionMethod::class,
get_class($controllerReflector->getReflectionMethod([BazingaController::class, 'userAction']))
);
$this->assertEquals(
ReflectionMethod::class,
get_class($controllerReflector->getReflectionMethod(BazingaController::class.'::userAction'))
);
$this->assertNull(
$controllerReflector->getReflectionMethod('UnknownController::userAction')
);
$this->assertNull($controllerReflector->getReflectionMethod(null));
}
}