1
私は例外をスローするSymfony\Bundle\FrameworkBundle\Test\KernelTestCase
を拡張したテストケースで新しいルートを追加しようとしています。そのためにEventListenerをテストします。簡素化されたテストは、次のようになります:symfonyのテストクライアントに新しいルートを追加する
public function testHandlingException()
{
$kernel = $this->createKernel(['environment' => 'test', 'debug' => true]);
$kernel->boot();
$client = $kernel->getContainer()->get('test.client');
$controller = new class extends Controller {
public function testAction()
{
throw new \Exception();
}
};
$route = new Route(
'route_500',
['_controller' => get_class($controller).'::testAction']
);
$client
->getContainer()
->get('router')
->getRouteCollection()
->add('route_500', $route);
$this->expectException(\Exception::class);
$client->request('GET', '/route_500');
}
それはで失敗します。
Failed asserting that exception of type "Exception" is thrown.
私は、飛ぶ、それは動作しますので、呼び出しルートを追加できますか?