From 33b2f0489a77e4ea5e2bfe01c36dac55ba54cdc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Mon, 31 May 2010 22:17:45 -0430 Subject: [PATCH] Migrating ThemeViewTest to phpunit --- cake/tests/cases/libs/view/theme.test.php | 52 +++++++---------------- 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/cake/tests/cases/libs/view/theme.test.php b/cake/tests/cases/libs/view/theme.test.php index 188f0368b68..71a9f7ea3db 100644 --- a/cake/tests/cases/libs/view/theme.test.php +++ b/cake/tests/cases/libs/view/theme.test.php @@ -126,7 +126,7 @@ function getLayoutFileName($name = null) { * @return void */ function cakeError($method, $messages) { - $error =& new ThemeViewTestErrorHandler($method, $messages); + $error = new ThemeViewTestErrorHandler($method, $messages); return $error; } } @@ -147,11 +147,15 @@ class ThemeViewTest extends CakeTestCase { */ function setUp() { Router::reload(); - $this->Controller =& new Controller(); - $this->PostsController =& new ThemePostsController(); + $this->Controller = new Controller(); + $this->PostsController = new ThemePostsController(); $this->PostsController->viewPath = 'posts'; $this->PostsController->index(); - $this->ThemeView =& new ThemeView($this->PostsController); + $this->ThemeView = new ThemeView($this->PostsController); + App::build(array( + 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), + 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) + )); } /** @@ -165,6 +169,7 @@ function tearDown() { unset($this->PostsController); unset($this->Controller); ClassRegistry::flush(); + App::build(); } /** * test that the theme view can be constructed without going into the registry @@ -174,34 +179,11 @@ function tearDown() { function testConstructionNoRegister() { ClassRegistry::flush(); $controller = null; - $Theme =& new ThemeView($controller, false); - $ThemeTwo =& ClassRegistry::getObject('view'); + $Theme = new ThemeView($controller, false); + $ThemeTwo = ClassRegistry::getObject('view'); $this->assertFalse($ThemeTwo); } -/** - * startTest - * - * @access public - * @return void - */ - function startTest() { - App::build(array( - 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), - 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) - )); - } - -/** - * endTest - * - * @access public - * @return void - */ - function endTest() { - App::build(); - } - /** * testPluginGetTemplate method * @@ -215,7 +197,7 @@ function testPluginThemedGetTemplate() { $this->Controller->action = 'index'; $this->Controller->theme = 'test_theme'; - $ThemeView =& new TestThemeView($this->Controller); + $ThemeView = new TestThemeView($this->Controller); $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'tests' . DS .'index.ctp'; $result = $ThemeView->getViewFileName('index'); $this->assertEqual($result, $expected); @@ -242,7 +224,7 @@ function testGetTemplate() { $this->Controller->action = 'display'; $this->Controller->params['pass'] = array('home'); - $ThemeView =& new TestThemeView($this->Controller); + $ThemeView = new TestThemeView($this->Controller); $ThemeView->theme = 'test_theme'; $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS .'pages' . DS .'home.ctp'; $result = $ThemeView->getViewFileName('home'); @@ -282,12 +264,10 @@ function testMissingView() { $this->Controller->params['pass'] = array('home'); - restore_error_handler(); - $View =& new TestThemeView($this->Controller); + $View = new TestThemeView($this->Controller); ob_start(); $result = $View->getViewFileName('does_not_exist'); $expected = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean()); - set_error_handler('simpleTestErrorHandler'); $this->assertPattern("/PagesController::/", $expected); $this->assertPattern("/views(\/|\\\)themed(\/|\\\)my_theme(\/|\\\)pages(\/|\\\)does_not_exist.ctp/", $expected); } @@ -304,7 +284,7 @@ function testMissingLayout() { $this->Controller->layout = 'whatever'; $this->Controller->theme = 'my_theme'; - $View =& new TestThemeView($this->Controller); + $View = new TestThemeView($this->Controller); ob_start(); $result = $View->getLayoutFileName(); $expected = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean()); @@ -327,7 +307,7 @@ function testMemoryLeakInPaths() { $this->Controller->layout = 'whatever'; $this->Controller->theme = 'test_theme'; - $View =& new ThemeView($this->Controller); + $View = new ThemeView($this->Controller); $View->element('test_element'); $start = memory_get_usage();