-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adhoc parts. Flag is still treated as a special attribute (and append…
…ed to parent)
- Loading branch information
Showing
2 changed files
with
68 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
use figdice\View; | ||
use org\bovigo\vfs\vfsStream; | ||
use org\bovigo\vfs\vfsStreamWrapper; | ||
|
||
class CacheTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testAdhocAndFlagAreCachedAndRestored() | ||
{ | ||
vfsStream::setup('root'); | ||
|
||
$template = <<<ENDTEMPLATE | ||
<html> | ||
<div class="one {/one/more} three" id="mydiv"> | ||
<fig:m fig:macro="mymacro"> | ||
<title fig:text="param1"></title> | ||
</fig:m> | ||
<span fig:call="mymacro" param1="'abc'"/> | ||
</div> | ||
<input name="email" fig:void="true"> | ||
<fig:attr name="required" flag="1" /> | ||
</input> | ||
</html> | ||
ENDTEMPLATE; | ||
|
||
vfsStream::newFile('template.html')->withContent($template)->at(vfsStreamWrapper::getRoot()); | ||
$view = new View(); | ||
$view->setCachePath(vfsStream::url('root')); | ||
$view->mount('one', ['more' => 'two']); | ||
$view->loadFile(vfsStream::url('root/template.html')); | ||
$output = $view->render(); | ||
|
||
$expected = <<<EXPECTED | ||
<html> | ||
<div class="one two three" id="mydiv"> | ||
<title>abc</title> | ||
</div> | ||
<input name="email" required> | ||
</html> | ||
EXPECTED; | ||
|
||
$this->assertEquals($expected, $output); | ||
|
||
// Now remove the original file | ||
unlink(vfsStream::url('root/template.html')); | ||
$view = new View(); | ||
$view->setCachePath(vfsStream::url('root')); | ||
$view->mount('one', ['more' => 'two']); | ||
$view->loadFile(vfsStream::url('root/template.html')); | ||
$output = $view->render(); | ||
|
||
$this->assertEquals($expected, $output); | ||
} | ||
} |