-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from xp-forge/feature/inherit-partials
Add possibility to inherit partials
- Loading branch information
Showing
3 changed files
with
76 additions
and
5 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
48 changes: 48 additions & 0 deletions
48
src/test/php/com/handlebarsjs/unittest/NodesTest.class.php
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,48 @@ | ||
<?php namespace com\handlebarsjs\unittest; | ||
|
||
use com\github\mustache\VariableNode; | ||
use com\handlebarsjs\Nodes; | ||
use test\{Assert, Before, Test}; | ||
|
||
class NodesTest { | ||
private $partial; | ||
|
||
#[Before] | ||
public function partial() { | ||
$this->partial= new Nodes([new VariableNode('test')]); | ||
} | ||
|
||
#[Test] | ||
public function can_create() { | ||
new Nodes(); | ||
} | ||
|
||
#[Test] | ||
public function partial_null() { | ||
Assert::null((new Nodes())->partial('test')); | ||
} | ||
|
||
#[Test] | ||
public function partials_empty() { | ||
Assert::equals([], (new Nodes())->partials()); | ||
} | ||
|
||
#[Test] | ||
public function declare_partial() { | ||
$fixture= new Nodes(); | ||
$fixture->declare('test', $this->partial); | ||
|
||
Assert::equals($this->partial, $fixture->partial('test')); | ||
Assert::equals(['test' => $this->partial], $fixture->partials()); | ||
} | ||
|
||
#[Test] | ||
public function inheriting_partials() { | ||
$parent= new Nodes(); | ||
$parent->declare('test', $this->partial); | ||
$child= (new Nodes())->inheriting($parent); | ||
|
||
Assert::equals($this->partial, $child->partial('test')); | ||
Assert::equals(['test' => $this->partial], $child->partials()); | ||
} | ||
} |
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