Skip to content

Commit f009e96

Browse files
committed
Adding test for lazy loading helpers using the collection
1 parent c700fed commit f009e96

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

lib/Cake/Test/Case/View/HelperCollectionTest.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,25 @@ public function testLoad() {
6767
$this->assertTrue($this->Helpers->enabled('Html'));
6868
}
6969

70+
/**
71+
* test lazy loading of helpers
72+
*
73+
* @return void
74+
*/
75+
public function testLazyLoad() {
76+
$result = $this->Helpers->Html;
77+
$this->assertInstanceOf('HtmlHelper', $result);
78+
79+
$result = $this->Helpers->Form;
80+
$this->assertInstanceOf('FormHelper', $result);
81+
82+
App::build(array('Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)));
83+
$this->View->plugin = 'TestPlugin';
84+
CakePlugin::load(array('TestPlugin'));
85+
$result = $this->Helpers->OtherHelper;
86+
$this->assertInstanceOf('OtherHelperHelper', $result);
87+
}
88+
7089
/**
7190
* Tests loading as an alias
7291
*
@@ -149,8 +168,8 @@ public function testUnload() {
149168
$this->assertEquals(array('Form', 'Html'), $result, 'loaded helpers is wrong');
150169

151170
$this->Helpers->unload('Html');
152-
$this->assertFalse(isset($this->Helpers->Html));
153-
$this->assertTrue(isset($this->Helpers->Form));
171+
$this->assertNotContains('Html', $this->Helpers->attached());
172+
$this->assertContains('Form', $this->Helpers->attached());
154173

155174
$result = $this->Helpers->attached();
156175
$this->assertEquals(array('Form'), $result, 'loaded helpers is wrong');

0 commit comments

Comments
 (0)