Starting to modify Helper constructors.

This commit is contained in:
mark_story 2010-07-03 01:07:50 -04:00
parent 1d983e1cd4
commit 087ccabffe
5 changed files with 11 additions and 45 deletions

View file

@ -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.
}

View file

@ -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];

View file

@ -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')) {

View file

@ -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));

View file

@ -706,7 +706,7 @@ class ViewTest extends CakeTestCase {
$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');
@ -797,45 +797,6 @@ class ViewTest extends CakeTestCase {
@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
*