summaryrefslogtreecommitdiff
path: root/tests/units/Helper
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-08-13 18:08:46 -0400
committerFrederic Guillot <fred@kanboard.net>2016-08-13 18:08:46 -0400
commit2ebe8b32728c341ec16e1197fe2e12d32ddd5de5 (patch)
tree164455e08b993d958a7466abbb00c439b0edacbb /tests/units/Helper
parentffe61abc6910670c5c2c243eb82d9f5851f06c6b (diff)
Add the possibility to attach template hooks with local variables
Diffstat (limited to 'tests/units/Helper')
-rw-r--r--tests/units/Helper/HookHelperTest.php40
1 files changed, 31 insertions, 9 deletions
diff --git a/tests/units/Helper/HookHelperTest.php b/tests/units/Helper/HookHelperTest.php
index 6e03acd1..66d13381 100644
--- a/tests/units/Helper/HookHelperTest.php
+++ b/tests/units/Helper/HookHelperTest.php
@@ -6,6 +6,28 @@ use Kanboard\Helper\HookHelper;
class HookHelperTest extends Base
{
+ public function testAttachLocalVariables()
+ {
+ $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->attach('test', 'tpl1', array('k1' => 'v1'));
+ $this->assertEquals('tpl1_content', $hookHelper->render('test', array('k0' => 'v0')));
+ }
+
public function testMultipleHooks()
{
$this->container['template'] = $this
@@ -32,10 +54,10 @@ class HookHelperTest extends Base
)
->will($this->returnValue('tpl2_content'));
- $h = new HookHelper($this->container);
- $h->attach('test', 'tpl1');
- $h->attach('test', 'tpl2');
- $this->assertEquals('tpl1_contenttpl2_content', $h->render('test'));
+ $hookHelper = new HookHelper($this->container);
+ $hookHelper->attach('test', 'tpl1');
+ $hookHelper->attach('test', 'tpl2');
+ $this->assertEquals('tpl1_contenttpl2_content', $hookHelper->render('test'));
}
public function testAssetHooks()
@@ -64,11 +86,11 @@ class HookHelperTest extends Base
)
->will($this->returnValue('<script src="skin.js"></script>'));
- $h = new HookHelper($this->container);
- $h->attach('test1', 'skin.css');
- $h->attach('test2', 'skin.js');
+ $hookHelper = new HookHelper($this->container);
+ $hookHelper->attach('test1', 'skin.css');
+ $hookHelper->attach('test2', 'skin.js');
- $this->assertContains('<link rel="stylesheet" href="skin.css"></link>', $h->asset('css', 'test1'));
- $this->assertContains('<script src="skin.js"></script>', $h->asset('js', 'test2'));
+ $this->assertContains('<link rel="stylesheet" href="skin.css"></link>', $hookHelper->asset('css', 'test1'));
+ $this->assertContains('<script src="skin.js"></script>', $hookHelper->asset('js', 'test2'));
}
}