-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…on (edefimov) This PR was merged into the 3.0.x-dev branch. Discussion ---------- #4163 Allow to use arrays in routing controller configuration Fix for #4163 Commits ------- a6fd3bf #4163 Allow to use arrays in routing controller configuration
- Loading branch information
Showing
2 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace EasyCorp\Bundle\EasyAdminBundle\Tests\EventListener; | ||
|
||
use EasyCorp\Bundle\EasyAdminBundle\EventListener\AdminRouterSubscriber; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpKernel\Event\RequestEvent; | ||
use Symfony\Component\HttpKernel\HttpKernelInterface; | ||
|
||
/** | ||
* Class AdminRouterSubscriberTest. | ||
*/ | ||
final class AdminRouterSubscriberTest extends TestCase | ||
{ | ||
/** | ||
* @var AdminRouterSubscriber | ||
*/ | ||
private $subscriber; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->subscriber = (new \ReflectionClass(AdminRouterSubscriber::class))->newInstanceWithoutConstructor(); | ||
} | ||
|
||
/** | ||
* testFetchingControllerFromRequestAttributes. | ||
* | ||
* @param $controller | ||
* | ||
* @dataProvider controllerDataProvider | ||
* | ||
* @doesNotPerformAssertions | ||
*/ | ||
public function testFetchingControllerFromRequestAttributes($controller): void | ||
{ | ||
$request = Request::create('/'); | ||
$request->attributes->set('_controller', $controller); | ||
|
||
$this->subscriber->onKernelRequest( | ||
new RequestEvent( | ||
$this->getMockForAbstractClass(HttpKernelInterface::class), | ||
$request, | ||
HttpKernelInterface::MASTER_REQUEST | ||
) | ||
); | ||
} | ||
|
||
public static function controllerDataProvider(): iterable | ||
{ | ||
yield ['Some\\Class::method']; | ||
yield ['Some\\Class']; | ||
yield [['Some\\Class', 'method']]; | ||
yield [new class() { | ||
public function __invoke() | ||
{ | ||
} | ||
}]; | ||
} | ||
} |