From 210f8c9e2ce9acf9d5beed2e5189abf9d6dfc0d7 Mon Sep 17 00:00:00 2001 From: Ceeram Date: Sun, 13 Nov 2011 04:23:27 +0100 Subject: [PATCH] adding tests for plugindot syntax in view filenames --- lib/Cake/Test/Case/View/ViewTest.php | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/Cake/Test/Case/View/ViewTest.php b/lib/Cake/Test/Case/View/ViewTest.php index 63c9ff646..bc6f4994b 100644 --- a/lib/Cake/Test/Case/View/ViewTest.php +++ b/lib/Cake/Test/Case/View/ViewTest.php @@ -322,6 +322,24 @@ class ViewTest extends CakeTestCase { $result = $View->getLayoutFileName(); $this->assertEquals($expected, $result); + $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Pages' . DS .'home.ctp'; + $result = $View->getViewFileName('TestPlugin.home'); + $this->assertEqual($expected, $result); + + CakePlugin::load('TestPlugin'); + $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Pages' . DS .'home.ctp'; + $result = $View->getViewFileName('TestPlugin.home'); + $this->assertEqual($expected, $result); + + $View->viewPath = 'Tests'; + $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS .'Tests' . DS .'index.ctp'; + $result = $View->getViewFileName('TestPlugin.index'); + $this->assertEqual($expected, $result); + + $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Layouts' . DS .'default.ctp'; + $result = $View->getLayoutFileName('TestPlugin.default'); + $this->assertEqual($expected, $result); + $View->layoutPath = 'rss'; $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Layouts' . DS . 'rss' . DS . 'default.ctp'; $result = $View->getLayoutFileName(); @@ -423,6 +441,13 @@ class ViewTest extends CakeTestCase { $result = $this->View->element('plugin_element', array(), array('plugin' => 'test_plugin')); $this->assertEquals($result, 'this is the plugin element using params[plugin]'); + $result = $this->View->element('TestPlugin.plugin_element'); + $this->assertEqual($result, 'this is the plugin element using params[plugin]'); + + $result = $this->View->element('test_plugin.plugin_element'); + $this->assertPattern('/Not Found:/', $result); + $this->assertPattern('/test_plugin.plugin_element/', $result); + $this->View->plugin = 'TestPlugin'; $result = $this->View->element('test_plugin_element'); $this->assertEquals($result, 'this is the test set using View::$plugin plugin element'); @@ -430,6 +455,10 @@ class ViewTest extends CakeTestCase { $result = $this->View->element('non_existant_element'); $this->assertRegExp('/Not Found:/', $result); $this->assertRegExp('/non_existant_element/', $result); + + $result = $this->View->element('TestPlugin.plugin_element', array(), array('plugin' => 'test_plugin')); + $this->assertRegExp('/Not Found:/', $result); + $this->assertRegExp('/TestPlugin.plugin_element/', $result); } /** @@ -747,6 +776,9 @@ class ViewTest extends CakeTestCase { $result = $View->getViewFileName('index'); $this->assertRegExp('/Posts(\/|\\\)index.ctp/', $result); + $result = $View->getViewFileName('TestPlugin.index'); + $this->assertPattern('/Posts(\/|\\\)index.ctp/', $result); + $result = $View->getViewFileName('/Pages/home'); $this->assertRegExp('/Pages(\/|\\\)home.ctp/', $result);