Skip to content

Commit

Permalink
Use loadHelper() instead of manipulating $helpers array in test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Oct 14, 2014
1 parent 865912f commit a219530
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/TestCase/View/ViewTest.php
Expand Up @@ -102,7 +102,7 @@ public function index() {
class TestView extends AppView {

public function initialize() {
$this->helpers['Html'] = ['mykey' => 'myval'];
$this->loadHelper('Html', ['mykey' => 'myval']);
}

/**
Expand Down Expand Up @@ -1116,14 +1116,15 @@ public function testAfterLayout() {
* @return void
*/
public function testRenderLoadHelper() {
$this->PostsController->helpers = array('Session', 'Html', 'Form', 'Number');
$this->PostsController->helpers = array('Session', 'Form', 'Number');
$View = $this->PostsController->createView('Cake\Test\TestCase\View\TestView');

$result = $View->render('index', false);
$this->assertEquals('posts index', $result);

$attached = $View->helpers()->loaded();
$this->assertEquals(array('Session', 'Html', 'Form', 'Number'), $attached);
// HtmlHelper is loaded in TestView::initialize()
$this->assertEquals(array('Html', 'Session', 'Form', 'Number'), $attached);

$this->PostsController->helpers = array('Html', 'Form', 'Number', 'TestPlugin.PluggedHelper');
$View = $this->PostsController->createView('Cake\Test\TestCase\View\TestView');
Expand Down

0 comments on commit a219530

Please sign in to comment.