Skip to content
Permalink
Browse files

Added Helper::$settings

  • Loading branch information...
ADmad committed Nov 30, 2012
1 parent 1de8ed1 commit 4a6ebaa07b9d94fdc51f990169d7871e1b38c612
Showing with 39 additions and 1 deletion.
  1. +29 −1 lib/Cake/Test/Case/View/HelperTest.php
  2. +10 −0 lib/Cake/View/Helper.php
@@ -158,10 +158,20 @@ public function schema($field = false) {
class TestHelper extends Helper {
/**
* Settings for this helper.
*
* @var array
*/
public $settings = array(
'key1' => 'val1',
'key2' => array('key2.1' => 'val2.1', 'key2.2' => 'val2.2')
);
/**
* Helpers for this helper.
*
* @var string
* @var array
*/
public $helpers = array('Html', 'TestPlugin.OtherHelper');
@@ -264,6 +274,24 @@ public static function entityProvider() {
);
}
/**
* Test settings merging
*
* @return void
*/
public function testSettingsMerging() {
$Helper = new TestHelper($this->View, array(
'key3' => 'val3',
'key2' => array('key2.2' => 'newval')
));
$expected = array(
'key1' => 'val1',
'key2' => array('key2.1' => 'val2.1', 'key2.2' => 'newval'),
'key3' => 'val3'
);
$this->assertEquals($expected, $Helper->settings);
}
/**
* Test setting an entity and retrieving the entity, model and field.
*
@@ -24,6 +24,13 @@
*/
class Helper extends Object {
/**
* Settings for this helper.
*
* @var array
*/
public $settings = array();
/**
* List of helpers used by this helper
*
@@ -164,6 +171,9 @@ class Helper extends Object {
public function __construct(View $View, $settings = array()) {
$this->_View = $View;
$this->request = $View->request;
if ($settings) {
$this->settings = Hash::merge($this->settings, $settings);
}
if (!empty($this->helpers)) {
$this->_helperMap = ObjectCollection::normalizeObjectArray($this->helpers);
}

0 comments on commit 4a6ebaa

Please sign in to comment.
You can’t perform that action at this time.