-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Twig,Drupal) Refactor twig driver system to allow namespaces and alw…
- Loading branch information
Showing
14 changed files
with
457 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Mannequin. | ||
* | ||
* (c) 2017 Last Call Media, Rob Bayliss <rob@lastcallmedia.com> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace LastCall\Mannequin\Drupal\Tests\Driver; | ||
|
||
use LastCall\Mannequin\Drupal\Driver\DrupalTwigDriver; | ||
use LastCall\Mannequin\Drupal\Drupal\MannequinExtensionDiscovery; | ||
use LastCall\Mannequin\Drupal\Tests\UsesTestDrupalRoot; | ||
use LastCall\Mannequin\Twig\Driver\TwigDriverInterface; | ||
use LastCall\Mannequin\Twig\Tests\Driver\DriverTestCase; | ||
|
||
/** | ||
* This test is very slow because of the extension scanning. | ||
*/ | ||
class DrupalTwigDriverTest extends DriverTestCase | ||
{ | ||
use UsesTestDrupalRoot; | ||
|
||
public static function setUpBeforeClass() | ||
{ | ||
self::requireDrupalClasses(); | ||
} | ||
|
||
protected function getDriver(): TwigDriverInterface | ||
{ | ||
$discovery = new MannequinExtensionDiscovery($this->getDrupalRoot()); | ||
|
||
return new DrupalTwigDriver($this->getDrupalRoot(), $discovery, [], [ | ||
'foo' => ['core/misc'], | ||
]); | ||
} | ||
|
||
/** | ||
* @expectedException \InvalidArgumentException | ||
* @expectedExceptionMessage does not look like a Drupal installation | ||
*/ | ||
public function testCreationWithInvalidDrupalRootFails() | ||
{ | ||
$discovery = new MannequinExtensionDiscovery(__DIR__); | ||
new DrupalTwigDriver(__DIR__, $discovery); | ||
} | ||
|
||
public function testHasTemplateNameMapper() | ||
{ | ||
$mapper = parent::testHasTemplateNameMapper(); | ||
$details = new \SplFileInfo($this->getDrupalRoot().'/core/modules/system/templates/details.html.twig'); | ||
$this->assertEquals(['@system/details.html.twig'], $mapper($details)); | ||
|
||
return $mapper; | ||
} | ||
|
||
/** | ||
* @depends testHasTemplateNameMapper | ||
*/ | ||
public function testCanAddAdditionalNamespaces(callable $mapper) | ||
{ | ||
$bar = new \SplFileInfo($this->getDrupalRoot().'/core/misc/bar'); | ||
$this->assertEquals(['@foo/bar'], $mapper($bar)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.