Add test for event listener

This commit is contained in:
Jordi Boggiano 2012-04-13 15:18:54 +02:00
parent ff2e1b23dd
commit d86783ca91
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,28 @@
<?php
/*
* This file is part of the NelmioApiDocBundle.
*
* (c) Nelmio <hello@nelm.io>
*
* 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');
}
}

View File

@ -12,6 +12,7 @@
namespace Nelmio\ApiDocBundle\Tests\Fixtures\Controller; namespace Nelmio\ApiDocBundle\Tests\Fixtures\Controller;
use Nelmio\ApiDocBundle\Annotation\ApiDoc; use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\HttpFoundation\Response;
class TestController class TestController
{ {
@ -27,6 +28,7 @@ class TestController
*/ */
public function indexAction() public function indexAction()
{ {
return new Response('tests');
} }
/** /**