From d86783ca918303785981587939931ff870d090d7 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 13 Apr 2012 15:18:54 +0200 Subject: [PATCH] Add test for event listener --- Tests/EventListener/RequestListenerTest.php | 28 ++++++++++++++++++++ Tests/Fixtures/Controller/TestController.php | 2 ++ 2 files changed, 30 insertions(+) create mode 100644 Tests/EventListener/RequestListenerTest.php diff --git a/Tests/EventListener/RequestListenerTest.php b/Tests/EventListener/RequestListenerTest.php new file mode 100644 index 0000000..7434efe --- /dev/null +++ b/Tests/EventListener/RequestListenerTest.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Nelmio\ApiDocBundle\Tests\EventListener; + +use Nelmio\ApiDocBundle\Tests\WebTestCase; + +class RequestListenerTest extends WebTestCase +{ + public function testDocQueryArg() + { + $client = $this->createClient(); + + $crawler = $client->request('GET', '/tests?_doc=1'); + $this->assertEquals('/tests', trim($crawler->filter(".operation .path:contains('/tests')")->text()), 'Event listener should capture ?_doc=1 requests'); + + $client->request('GET', '/tests'); + $this->assertEquals('tests', $client->getResponse()->getContent(), 'Event listener should let normal requests through'); + } +} diff --git a/Tests/Fixtures/Controller/TestController.php b/Tests/Fixtures/Controller/TestController.php index 3227bba..6f08397 100644 --- a/Tests/Fixtures/Controller/TestController.php +++ b/Tests/Fixtures/Controller/TestController.php @@ -12,6 +12,7 @@ namespace Nelmio\ApiDocBundle\Tests\Fixtures\Controller; use Nelmio\ApiDocBundle\Annotation\ApiDoc; +use Symfony\Component\HttpFoundation\Response; class TestController { @@ -27,6 +28,7 @@ class TestController */ public function indexAction() { + return new Response('tests'); } /**