2011-04-18 16:35:14 +01:00
|
|
|
<?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.
|
|
|
|
*/
|
|
|
|
|
2011-06-07 08:38:25 +01:00
|
|
|
namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer;
|
2011-04-18 16:35:14 +01:00
|
|
|
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
2012-07-03 13:05:19 +01:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Templating\TemplateFilenameParser;
|
2011-06-07 08:38:25 +01:00
|
|
|
use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinder;
|
2011-04-18 16:35:14 +01:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\BaseBundle\BaseBundle;
|
|
|
|
|
|
|
|
class TemplateFinderTest extends TestCase
|
|
|
|
{
|
|
|
|
public function testFindAllTemplates()
|
2011-06-08 11:12:55 +01:00
|
|
|
{
|
2011-04-18 16:35:14 +01:00
|
|
|
$kernel = $this
|
|
|
|
->getMockBuilder('Symfony\Component\HttpKernel\Kernel')
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock()
|
|
|
|
;
|
|
|
|
|
|
|
|
$kernel
|
|
|
|
->expects($this->any())
|
|
|
|
->method('getBundle')
|
|
|
|
;
|
|
|
|
|
|
|
|
$kernel
|
|
|
|
->expects($this->once())
|
|
|
|
->method('getBundles')
|
|
|
|
->will($this->returnValue(array('BaseBundle' => new BaseBundle())))
|
|
|
|
;
|
|
|
|
|
2014-02-11 07:51:18 +00:00
|
|
|
$parser = new TemplateFilenameParser();
|
2011-04-18 16:35:14 +01:00
|
|
|
|
2011-06-07 08:38:25 +01:00
|
|
|
$finder = new TemplateFinder($kernel, $parser, __DIR__.'/../Fixtures/Resources');
|
2011-04-18 16:35:14 +01:00
|
|
|
|
|
|
|
$templates = array_map(
|
|
|
|
function ($template) { return $template->getLogicalName(); },
|
|
|
|
$finder->findAllTemplates()
|
|
|
|
);
|
|
|
|
|
2015-09-20 21:05:20 +01:00
|
|
|
$this->assertCount(7, $templates, '->findAllTemplates() find all templates in the bundles and global folders');
|
2011-04-18 16:35:14 +01:00
|
|
|
$this->assertContains('BaseBundle::base.format.engine', $templates);
|
2011-07-04 21:38:34 +01:00
|
|
|
$this->assertContains('BaseBundle::this.is.a.template.format.engine', $templates);
|
2011-04-18 16:35:14 +01:00
|
|
|
$this->assertContains('BaseBundle:controller:base.format.engine', $templates);
|
2015-09-20 21:05:20 +01:00
|
|
|
$this->assertContains('BaseBundle:controller:custom.format.engine', $templates);
|
2011-07-04 21:38:34 +01:00
|
|
|
$this->assertContains('::this.is.a.template.format.engine', $templates);
|
2011-04-18 16:35:14 +01:00
|
|
|
$this->assertContains('::resource.format.engine', $templates);
|
|
|
|
}
|
|
|
|
}
|