Skip to content

Commit

Permalink
Add test case for tonik/gin/template/context filter hook for named te…
Browse files Browse the repository at this point in the history
…mplate
  • Loading branch information
jedrzejchalubek committed May 18, 2017
1 parent 13de93d commit 21c3bf3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/Gin/Template/TemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,18 @@ public function test_filter_on_template_filename_getter()
public function test_centext_filter_on_template_rendering()
{
$config = $this->getConfig();
$template = $this->getTemplate($config, 'sample_template');

Functions::expect('locate_template')->twice()->andReturn(true);
Functions::expect('set_query_var')->once()->with('key', 'changed')->andReturn(null);
Functions::expect('locate_template')->atLeast()->once()->andReturn(true);
Functions::expect('set_query_var')->atLeast()->once()->with('key', 'changed')->andReturn(null);

$template = $this->getTemplate($config, 'sample_template');
Actions::expectFired('get_template_part_sample_template')->once()->with('sample_template', null);
Filters::expectApplied('tonik/gin/template/context/sample_template.php')->once()->with(['key' => 'value'])->andReturn(['key' => 'changed']);
$template->render(['key' => 'value']);

$template = $this->getTemplate($config, ['sample_template', 'named']);
Actions::expectFired('get_template_part_sample_template')->once()->with('sample_template', 'named');
Filters::expectApplied('tonik/gin/template/context/sample_template-named.php')->once()->with(['key' => 'value'])->andReturn(['key' => 'changed']);
$template->render(['key' => 'value']);
}

Expand Down

0 comments on commit 21c3bf3

Please sign in to comment.