fixed unit tests
This commit is contained in:
parent
fc444f1a55
commit
142cffbc4f
@ -12,72 +12,33 @@
|
|||||||
namespace Symfony\Bundle\TwigBundle\Tests\Controller;
|
namespace Symfony\Bundle\TwigBundle\Tests\Controller;
|
||||||
|
|
||||||
use Symfony\Bundle\TwigBundle\Tests\TestCase;
|
use Symfony\Bundle\TwigBundle\Tests\TestCase;
|
||||||
|
|
||||||
use Symfony\Bundle\TwigBundle\Controller\ExceptionController;
|
use Symfony\Bundle\TwigBundle\Controller\ExceptionController;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
||||||
use Symfony\Component\DependencyInjection\Scope;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
class ExceptionControllerTest extends TestCase
|
class ExceptionControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
protected $controller;
|
public function testOnlyClearOwnOutputBuffers()
|
||||||
protected $container;
|
|
||||||
protected $flatten;
|
|
||||||
protected $templating;
|
|
||||||
protected $kernel;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
{
|
||||||
parent::setUp();
|
$flatten = $this->getMock('Symfony\Component\HttpKernel\Exception\FlattenException');
|
||||||
|
$flatten
|
||||||
$this->flatten = $this->getMock('Symfony\Component\HttpKernel\Exception\FlattenException');
|
|
||||||
$this->flatten
|
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getStatusCode')
|
->method('getStatusCode')
|
||||||
->will($this->returnValue(404));
|
->will($this->returnValue(404));
|
||||||
$this->controller = new ExceptionController();
|
$twig = $this->getMockBuilder('\Twig_Environment')
|
||||||
$this->kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface');
|
|
||||||
$this->templating = $this->getMockBuilder('Symfony\\Bundle\\TwigBundle\\TwigEngine')
|
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$this->templating
|
$twig
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('renderResponse')
|
->method('render')
|
||||||
->will($this->returnValue($this->getMock('Symfony\Component\HttpFoundation\Response')));
|
->will($this->returnValue($this->getMock('Symfony\Component\HttpFoundation\Response')));
|
||||||
$this->request = Request::create('/');
|
$twig
|
||||||
$this->container = $this->getContainer();
|
->expects($this->any())
|
||||||
}
|
->method('getLoader')
|
||||||
|
->will($this->returnValue($this->getMock('\Twig_LoaderInterface')));
|
||||||
|
$request = Request::create('/');
|
||||||
|
$request->headers->set('X-Php-Ob-Level', 1);
|
||||||
|
|
||||||
protected function tearDown()
|
$controller = new ExceptionController($twig, false);
|
||||||
{
|
$controller->showAction($request, $flatten);
|
||||||
parent::tearDown();
|
|
||||||
|
|
||||||
$this->controller = null;
|
|
||||||
$this->container = null;
|
|
||||||
$this->flatten = null;
|
|
||||||
$this->templating = null;
|
|
||||||
$this->kernel = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testOnlyClearOwnOutputBuffers()
|
|
||||||
{
|
|
||||||
$this->request->headers->set('X-Php-Ob-Level', 1);
|
|
||||||
|
|
||||||
$this->controller->setContainer($this->container);
|
|
||||||
$this->controller->showAction($this->flatten);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getContainer()
|
|
||||||
{
|
|
||||||
$container = new ContainerBuilder();
|
|
||||||
$container->addScope(new Scope('request'));
|
|
||||||
$container->set('request', $this->request);
|
|
||||||
$container->set('templating', $this->templating);
|
|
||||||
$container->setParameter('kernel.bundles', array());
|
|
||||||
$container->setParameter('kernel.cache_dir', __DIR__);
|
|
||||||
$container->setParameter('kernel.root_dir', __DIR__);
|
|
||||||
$container->set('kernel', $this->kernel);
|
|
||||||
|
|
||||||
return $container;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,6 @@ class TemplateManagerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetTemplates()
|
public function testGetTemplates()
|
||||||
{
|
{
|
||||||
|
|
||||||
$profile = $this->mockProfile();
|
$profile = $this->mockProfile();
|
||||||
$profile->expects($this->any())
|
$profile->expects($this->any())
|
||||||
->method('hasCollector')
|
->method('hasCollector')
|
||||||
@ -145,6 +144,10 @@ class TemplateManagerTest extends TestCase
|
|||||||
->method('loadTemplate')
|
->method('loadTemplate')
|
||||||
->will($this->returnValue('loadedTemplate'));
|
->will($this->returnValue('loadedTemplate'));
|
||||||
|
|
||||||
|
$this->twigEnvironment->expects($this->any())
|
||||||
|
->method('getLoader')
|
||||||
|
->will($this->returnValue($this->getMock('\Twig_LoaderInterface')));
|
||||||
|
|
||||||
return $this->twigEnvironment;
|
return $this->twigEnvironment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user