for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the KleijnWeb\SwaggerBundle package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace KleijnWeb\SwaggerBundle\Tests\EventListener;
use KleijnWeb\SwaggerBundle\EventListener\ViewListener;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* @author John Kleijn <[email protected]>
class ViewListenerTest extends \PHPUnit_Framework_TestCase
{
* @test
public function willSetResponseFromFactoryOnEvent()
$request = new Request();
$response = new Response();
$result = [uniqid()];
$eventMock = $this
->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent')
->disableOriginalConstructor()
->getMock();
$eventMock
->expects($this->once())
->method('getRequest')
->willReturn($request);
->method('getControllerResult')
->willReturn($result);
->method('setResponse')
->willReturn($response);
$factoryMock = $this
->getMockBuilder('KleijnWeb\SwaggerBundle\Response\ResponseFactory')
$factoryMock
->method('createResponse')
->with($request, $result)
$listener = new ViewListener($factoryMock);
$listener->onKernelView($eventMock);
}