This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php
Fabien Potencier c4dc0034e7 Merge branch '2.3' into 2.5
* 2.3:
  Updated generateSql tool
  Fix the implementation of deprecated Locale classes
  Fix phpdoc and coding standards
  Replace usages of the deprecated TypeTestCase by the new one
  Remove usages of deprecated constants
  Update functional tests to use the PSR NullLogger
  Make fabbot happy
  Clean up testing
  [DomCrawler] fixed bug #12143

Conflicts:
	src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
	src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php
	src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php
	src/Symfony/Component/Console/Application.php
	src/Symfony/Component/DomCrawler/Crawler.php
	src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php
	src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php
	src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php
	src/Symfony/Component/Serializer/Encoder/EncoderInterface.php
	src/Symfony/Component/Serializer/Encoder/XmlEncoder.php
	src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php
2014-12-30 10:03:46 +01:00

117 lines
3.5 KiB
PHP

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating;
use Symfony\Bundle\FrameworkBundle\Templating\TimedPhpEngine;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
class TimedPhpEngineTest extends TestCase
{
public function testThatRenderLogsTime()
{
$container = $this->getContainer();
$templateNameParser = $this->getTemplateNameParser();
$globalVariables = $this->getGlobalVariables();
$loader = $this->getLoader($this->getStorage());
$stopwatch = $this->getStopwatch();
$stopwatchEvent = $this->getStopwatchEvent();
$stopwatch->expects($this->once())
->method('start')
->with('template.php (index.php)', 'template')
->will($this->returnValue($stopwatchEvent));
$stopwatchEvent->expects($this->once())->method('stop');
$engine = new TimedPhpEngine($templateNameParser, $container, $loader, $stopwatch, $globalVariables);
$engine->render('index.php');
}
/**
* @return Container
*/
private function getContainer()
{
return $this->getMock('Symfony\Component\DependencyInjection\Container');
}
/**
* @return \Symfony\Component\Templating\TemplateNameParserInterface
*/
private function getTemplateNameParser()
{
$templateReference = $this->getMock('Symfony\Component\Templating\TemplateReferenceInterface');
$templateNameParser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface');
$templateNameParser->expects($this->any())
->method('parse')
->will($this->returnValue($templateReference));
return $templateNameParser;
}
/**
* @return GlobalVariables
*/
private function getGlobalVariables()
{
return $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables')
->disableOriginalConstructor()
->getMock();
}
/**
* @return \Symfony\Component\Templating\Storage\StringStorage
*/
private function getStorage()
{
return $this->getMockBuilder('Symfony\Component\Templating\Storage\StringStorage')
->disableOriginalConstructor()
->getMockForAbstractClass();
}
/**
* @param \Symfony\Component\Templating\Storage\StringStorage $storage
*
* @return \Symfony\Component\Templating\Loader\Loader
*/
private function getLoader($storage)
{
$loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader');
$loader->expects($this->once())
->method('load')
->will($this->returnValue($storage));
return $loader;
}
/**
* @return \Symfony\Component\Stopwatch\StopwatchEvent
*/
private function getStopwatchEvent()
{
return $this->getMockBuilder('Symfony\Component\Stopwatch\StopwatchEvent')
->disableOriginalConstructor()
->getMock();
}
/**
* @return \Symfony\Component\Stopwatch\Stopwatch
*/
private function getStopwatch()
{
return $this->getMock('Symfony\Component\Stopwatch\Stopwatch');
}
}