Navigation Menu

Skip to content

Commit

Permalink
Starting to modify Helper constructors.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 11, 2010
1 parent 1d983e1 commit 087ccab
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 45 deletions.
4 changes: 3 additions & 1 deletion cake/libs/view/helper.php
Expand Up @@ -145,8 +145,10 @@ class Helper extends Object {
/**
* Default Constructor
*
* @param View $View The View this helper is being attached to.
* @param array $settings Configuration settings for the helper.
*/
public function __construct() {
public function __construct(View $View, $settings = array()) {
// Nothing to see here.
}

Expand Down
3 changes: 2 additions & 1 deletion cake/libs/view/helpers/js.php
Expand Up @@ -81,10 +81,11 @@ class JsHelper extends AppHelper {
/**
* Constructor - determines engine helper
*
* @param View $View the view object the helper is attached to.
* @param array $settings Settings array contains name of engine helper.
* @return void
*/
public function __construct($settings = array()) {
public function __construct(View $View, $settings = array()) {
$className = 'Jquery';
if (is_array($settings) && isset($settings[0])) {
$className = $settings[0];
Expand Down
6 changes: 4 additions & 2 deletions cake/libs/view/helpers/paginator.php
Expand Up @@ -85,10 +85,12 @@ class PaginatorHelper extends AppHelper {
*
* The chosen custom helper must implement a `link()` method.
*
* @param View $View the view object the helper is attached to.
* @param array $settings Array of settings.
* @return void
*/
function __construct($config = array()) {
$ajaxProvider = isset($config['ajax']) ? $config['ajax'] : 'Js';
function __construct(View $View, $settings = array()) {
$ajaxProvider = isset($settings['ajax']) ? $settings['ajax'] : 'Js';
$this->helpers[] = $ajaxProvider;
$this->_ajaxHelperClass = $ajaxProvider;
if (!class_exists($ajaxProvider . 'Helper')) {
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/xml.php
Expand Up @@ -43,7 +43,7 @@ class XmlHelper extends AppHelper {
*
* @return void
*/
function __construct() {
function __construct(View $View, $settings = array()) {
parent::__construct();
$this->Xml =& new Xml();
$this->Xml->options(array('verifyNs' => false));
Expand Down
41 changes: 1 addition & 40 deletions cake/tests/cases/libs/view/view.test.php
Expand Up @@ -706,7 +706,7 @@ function testRenderLayoutWithMockCacheHelper() {
$View->helpers = array('Cache', 'Html', 'Session');
$View->loadHelpers();

$View->Helpers->Cache = $this->getMock('CacheHelper');
$View->Helpers->Cache = $this->getMock('CacheHelper', array(), array($View));
$View->Helpers->Cache->expects($this->exactly(2))->method('cache');

$result = $View->render('index');
Expand Down Expand Up @@ -797,45 +797,6 @@ function testRenderCache() {
@unlink($path);
}

/**
* testRenderNocache method
*
* @access public
* @return void
*/

/* This is a new test case for a pending enhancement
function testRenderNocache() {
$this->PostsController->helpers = array('Cache', 'Html');
$this->PostsController->constructClasses();
$this->PostsController->cacheAction = 21600;
$this->PostsController->here = '/posts/nocache_multiple_element';
$this->PostsController->action = 'nocache_multiple_element';
$this->PostsController->nocache_multiple_element();
Configure::write('Cache.check', true);
Configure::write('Cache.disable', false);
$filename = CACHE . 'views' . DS . 'posts_nocache_multiple_element.php';
$View = new TestView($this->PostsController);
$View->render();
ob_start();
$View->renderCache($filename, getMicroTime());
$result = ob_get_clean();
@unlink($filename);
$this->assertPattern('/php echo \$foo;/', $result);
$this->assertPattern('/php echo \$bar;/', $result);
$this->assertPattern('/php \$barfoo = \'in sub2\';/', $result);
$this->assertPattern('/php echo \$barfoo;/', $result);
$this->assertPattern('/printing: "in sub2"/', $result);
$this->assertPattern('/php \$foobar = \'in sub1\';/', $result);
$this->assertPattern('/php echo \$foobar;/', $result);
$this->assertPattern('/printing: "in sub1"/', $result);
}
*/

/**
* testSet method
*
Expand Down

0 comments on commit 087ccab

Please sign in to comment.