diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-08-13 18:41:01 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-08-13 18:41:01 -0400 |
commit | 010199e8f846f6c0b4f23336338bfda17ec04901 (patch) | |
tree | bce51661cd43034ed2d6bb6caf04574767a712ec /tests | |
parent | 2ebe8b32728c341ec16e1197fe2e12d32ddd5de5 (diff) |
Add the possibility to attach template hooks with a callback
Diffstat (limited to 'tests')
-rw-r--r-- | tests/units/Helper/HookHelperTest.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/units/Helper/HookHelperTest.php b/tests/units/Helper/HookHelperTest.php index 66d13381..a67eaed9 100644 --- a/tests/units/Helper/HookHelperTest.php +++ b/tests/units/Helper/HookHelperTest.php @@ -6,6 +6,57 @@ use Kanboard\Helper\HookHelper; class HookHelperTest extends Base { + public function testAttachCallable() + { + $this->container['template'] = $this + ->getMockBuilder('\Kanboard\Core\Template') + ->setConstructorArgs(array($this->container['helper'])) + ->setMethods(array('render')) + ->getMock(); + + $this->container['template'] + ->expects($this->once()) + ->method('render') + ->with( + $this->equalTo('tpl1'), + $this->equalTo(array('k0' => 'v0', 'k1' => 'v1')) + ) + ->will($this->returnValue('tpl1_content')); + + $hookHelper = new HookHelper($this->container); + $hookHelper->attachCallable('test', 'tpl1', function() { + return array( + 'k1' => 'v1', + ); + }); + + $this->assertEquals('tpl1_content', $hookHelper->render('test', array('k0' => 'v0'))); + } + + public function testAttachCallableWithNoResult() + { + $this->container['template'] = $this + ->getMockBuilder('\Kanboard\Core\Template') + ->setConstructorArgs(array($this->container['helper'])) + ->setMethods(array('render')) + ->getMock(); + + $this->container['template'] + ->expects($this->once()) + ->method('render') + ->with( + $this->equalTo('tpl1'), + $this->equalTo(array('k0' => 'v0')) + ) + ->will($this->returnValue('tpl1_content')); + + $hookHelper = new HookHelper($this->container); + $hookHelper->attachCallable('test', 'tpl1', function() { + }); + + $this->assertEquals('tpl1_content', $hookHelper->render('test', array('k0' => 'v0'))); + } + public function testAttachLocalVariables() { $this->container['template'] = $this |