Skip to content

Commit

Permalink
Updating most helper test cases to use View in their constructors.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 11, 2010
1 parent 68ff2e5 commit 0e933e8
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 24 deletions.
7 changes: 7 additions & 0 deletions cake/libs/view/helpers/xml.php
Expand Up @@ -38,6 +38,13 @@ class XmlHelper extends AppHelper {
*/
public $encoding = 'UTF-8';

/**
* Xml instance
*
* @var Xml
*/
public $Xml;

/**
* Constructor
*
Expand Down
3 changes: 2 additions & 1 deletion cake/tests/cases/libs/view/helpers/cache.test.php
Expand Up @@ -76,7 +76,8 @@ function skip() {
*/
function setUp() {
$this->Controller = new CacheTestController();
$this->Cache = new CacheHelper();
$View = new View($this->Controller);
$this->Cache = new CacheHelper($View);
$this->_cacheSettings = Configure::read('Cache');
Configure::write('Cache.check', true);
Configure::write('Cache.disable', false);
Expand Down
8 changes: 4 additions & 4 deletions cake/tests/cases/libs/view/helpers/form.test.php
Expand Up @@ -672,10 +672,10 @@ function setUp() {
parent::setUp();
Router::reload();

$this->Form =& new FormHelper();
$this->Form->Html =& new HtmlHelper();
$this->Controller =& new ContactTestController();
$this->View =& new View($this->Controller);
$this->Controller = new ContactTestController();
$this->View = new View($this->Controller);

$this->Form = new FormHelper($this->View);
$this->Form->params['action'] = 'add';

ClassRegistry::addObject('view', $view);
Expand Down
5 changes: 3 additions & 2 deletions cake/tests/cases/libs/view/helpers/html.test.php
Expand Up @@ -108,8 +108,9 @@ class HtmlHelperTest extends CakeTestCase {
* @return void
*/
function startTest() {
$this->Html =& new HtmlHelper();
$view =& new View(new TheHtmlTestController());
$view = new View(new TheHtmlTestController());
$this->Html = new HtmlHelper($view);

ClassRegistry::addObject('view', $view);
$this->_appEncoding = Configure::read('App.encoding');
$this->_asset = Configure::read('Asset');
Expand Down
4 changes: 3 additions & 1 deletion cake/tests/cases/libs/view/helpers/jquery_engine.test.php
Expand Up @@ -27,7 +27,9 @@ class JqueryEngineHelperTest extends CakeTestCase {
* @return void
*/
function startTest() {
$this->Jquery =& new JqueryEngineHelper();
$controller = null;
$View = new View($controller);
$this->Jquery = new JqueryEngineHelper($View);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion cake/tests/cases/libs/view/helpers/number.test.php
Expand Up @@ -42,7 +42,8 @@ class NumberHelperTest extends CakeTestCase {
* @return void
*/
function startTest() {
$this->Number =& new NumberHelper();
$view = $this->getMock('View', array(), array(), '', false);
$this->Number = new NumberHelper($view);
}

/**
Expand Down
15 changes: 8 additions & 7 deletions cake/tests/cases/libs/view/helpers/paginator.test.php
Expand Up @@ -34,7 +34,9 @@ class PaginatorHelperTest extends CakeTestCase {
* @return void
*/
function setUp() {
$this->Paginator = new PaginatorHelper();
$controller = null;
$this->View = new View($controller);
$this->Paginator = new PaginatorHelper($this->View);
$this->Paginator->params['paging'] = array(
'Article' => array(
'current' => 9,
Expand All @@ -55,8 +57,7 @@ function setUp() {
)
)
);
$this->Paginator->Html = new HtmlHelper();
$this->Paginator->Js = $this->getMock('PaginatorHelper');
$this->Paginator->Js = $this->getMock('PaginatorHelper', array(), array($this->View));

Configure::write('Routing.prefixes', array());
Router::reload();
Expand All @@ -69,7 +70,7 @@ function setUp() {
* @return void
*/
function tearDown() {
unset($this->Paginator);
unset($this->View, $this->Paginator);
}

/**
Expand Down Expand Up @@ -1910,8 +1911,8 @@ function testAjaxLinkGenerationLink() {
* @return void
*/
function testMockAjaxProviderClassInjection() {
$mock = $this->getMock('PaginatorHelper', array(), array(), 'PaginatorMockJsHelper');
$Paginator = new PaginatorHelper(array('ajax' => 'PaginatorMockJs'));
$mock = $this->getMock('PaginatorHelper', array(), array($this->View), 'PaginatorMockJsHelper');
$Paginator = new PaginatorHelper($this->View, array('ajax' => 'PaginatorMockJs'));
$Paginator->params['paging'] = array(
'Article' => array(
'current' => 9,
Expand All @@ -1928,6 +1929,6 @@ function testMockAjaxProviderClassInjection() {
$result = $Paginator->link('Page 2', array('page' => 2), array('update' => '#content'));

$this->expectException();
$Paginator = new PaginatorHelper(array('ajax' => 'Form'));
$Paginator = new PaginatorHelper($this->View, array('ajax' => 'Form'));
}
}
6 changes: 3 additions & 3 deletions cake/tests/cases/libs/view/helpers/rss.test.php
Expand Up @@ -34,9 +34,9 @@ class RssHelperTest extends CakeTestCase {
* @return void
*/
function setUp() {
$this->Rss =& new RssHelper();
$this->Rss->Time =& new TimeHelper();
$this->Rss->beforeRender();
$controller = null;
$this->View = new View($controller);
$this->Rss = new RssHelper($this->View);

$manager =& XmlManager::getInstance();
$manager->namespaces = array();
Expand Down
6 changes: 4 additions & 2 deletions cake/tests/cases/libs/view/helpers/session.test.php
Expand Up @@ -38,7 +38,9 @@ class SessionHelperTest extends CakeTestCase {
* @return void
*/
function setUp() {
$this->Session = new SessionHelper();
$controller = null;
$this->View = new View($controller);
$this->Session = new SessionHelper($this->View);

$_SESSION = array(
'test' => 'info',
Expand Down Expand Up @@ -76,7 +78,7 @@ function setUp() {
*/
function tearDown() {
$_SESSION = array();
unset($this->Session);
unset($this->View, $this->Session);
App::build();
}

Expand Down
4 changes: 3 additions & 1 deletion cake/tests/cases/libs/view/helpers/time.test.php
Expand Up @@ -37,7 +37,9 @@ class TimeHelperTest extends CakeTestCase {
* @return void
*/
function setUp() {
$this->Time = new TimeHelper();
$controller = null;
$View = new View($controller);
$this->Time = new TimeHelper($View);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions cake/tests/cases/libs/view/helpers/xml.test.php
Expand Up @@ -75,8 +75,9 @@ class XmlHelperTest extends CakeTestCase {
* @return void
*/
function setUp() {
$this->Xml =& new XmlHelper();
$this->Xml->beforeRender();
$controller = null;
$View = new View($controller);
$this->Xml = new XmlHelper($View);
$manager =& XmlManager::getInstance();
$manager->namespaces = array();
}
Expand Down

0 comments on commit 0e933e8

Please sign in to comment.