Commit 5972c776 authored by alexpott's avatar alexpott

Issue #2832083 by rbayliss, pounard, alexpott, dawehner:...

Issue #2832083 by rbayliss, pounard, alexpott, dawehner: ThemeRegistryLoader::findTemplate() breaks Twig_Loader_Filesystem signature
parent 4105b556
......@@ -36,8 +36,8 @@ public function __construct(Registry $theme_registry) {
* @param bool $throw
* Whether to throw an exception when an error occurs.
*
* @return string
* The path to the template.
* @return string|false
* The path to the template, or false if the template is not found.
*
* @throws \Twig_Error_Loader
* Thrown if a template matching $name cannot be found.
......@@ -63,6 +63,8 @@ protected function findTemplate($name, $throw = TRUE) {
if ($throw) {
throw new \Twig_Error_Loader(sprintf('Unable to find template "%s" in the Drupal theme registry.', $name));
}
return FALSE;
}
}
<?php
namespace Drupal\Tests\Core\Template\Loader;
use Drupal\Core\Template\Loader\ThemeRegistryLoader;
use Drupal\Tests\UnitTestCase;
/**
* @coversDefaultClass \Drupal\Core\Template\Loader\ThemeRegistryLoader
* @group Template
*/
class ThemeRegistryLoaderTest extends UnitTestCase {
/**
* @covers ::findTemplate
*/
public function testLoaderReturnsFalseForExistsOnNonexistent() {
$registry = $this->prophesize('Drupal\Core\Theme\Registry');
$runtime = $this->prophesize('Drupal\Core\Utility\ThemeRegistry');
$runtime->has('foo')
->shouldBeCalled()
->willReturn(FALSE);
$registry->getRuntime()->willReturn($runtime);
$loader = new ThemeRegistryLoader($registry->reveal());
$this->assertFalse($loader->exists('foo'));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment