diff --git a/lib/Cake/Test/TestCase/View/Helper/CacheHelperTest.php b/lib/Cake/Test/TestCase/View/Helper/CacheHelperTest.php index f6e04b6a4b6..a3e43b9e7af 100644 --- a/lib/Cake/Test/TestCase/View/Helper/CacheHelperTest.php +++ b/lib/Cake/Test/TestCase/View/Helper/CacheHelperTest.php @@ -16,11 +16,17 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ - -App::uses('Controller', 'Controller'); -App::uses('Model', 'Model'); -App::uses('View', 'View'); -App::uses('CacheHelper', 'View/Helper'); +namespace Cake\Test\TestCase\View\Helper; + +use Cake\TestSuite\TestCase, + Cake\Controller\Controller, + Cake\Model\Model, + Cake\View\View, + Cake\View\Helper\CacheHelper, + Cake\Core\App, + Cake\Core\Configure, + Cake\Routing\Router, + Cake\Network\Request; /** * CacheTestController class @@ -57,7 +63,7 @@ public function cache_parsing() { * * @package Cake.Test.Case.View.Helper */ -class CacheHelperTest extends CakeTestCase { +class CacheHelperTest extends TestCase { /** * Checks if TMP/views is writable, and skips the case if it is not. @@ -78,14 +84,14 @@ public function skip() { public function setUp() { parent::setUp(); $_GET = array(); - $request = new CakeRequest(); + $request = new Request(); $this->Controller = new CacheTestController($request); $View = new View($this->Controller); $this->Cache = new CacheHelper($View); Configure::write('Cache.check', true); Configure::write('Cache.disable', false); App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) + 'View' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS) ), App::RESET); } @@ -555,7 +561,7 @@ public function testAfterRenderConditions() { $View->cacheAction = '+1 day'; $View->output = 'test'; - $Cache = $this->getMock('CacheHelper', array('_parseContent'), array($View)); + $Cache = $this->getMock('Cake\View\Helper\CacheHelper', array('_parseContent'), array($View)); $Cache->expects($this->once()) ->method('_parseContent') ->with('posts/index', 'content') @@ -582,7 +588,7 @@ public function testAfterLayoutConditions() { $View->cacheAction = '+1 day'; $View->output = 'test'; - $Cache = $this->getMock('CacheHelper', array('cache'), array($View)); + $Cache = $this->getMock('Cake\View\Helper\CacheHelper', array('cache'), array($View)); $Cache->expects($this->once()) ->method('cache') ->with('posts/index', $View->output) diff --git a/lib/Cake/Test/TestCase/View/Helper/FormHelperTest.php b/lib/Cake/Test/TestCase/View/Helper/FormHelperTest.php index e5230241aff..b6e4855d0a6 100644 --- a/lib/Cake/Test/TestCase/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/TestCase/View/Helper/FormHelperTest.php @@ -16,15 +16,22 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('ClassRegistry', 'Utility'); -App::uses('Controller', 'Controller'); -App::uses('View', 'View'); -App::uses('Model', 'Model'); -App::uses('Security', 'Utility'); -App::uses('CakeRequest', 'Network'); -App::uses('HtmlHelper', 'View/Helper'); -App::uses('FormHelper', 'View/Helper'); -App::uses('Router', 'Routing'); +namespace Cake\Test\TestCase\View\Helper; + +use Cake\TestSuite\TestCase, + Cake\TestSuite\Fixture\TestModel, + Cake\Controller\Controller, + Cake\Model\Model, + Cake\View\View, + Cake\View\Helper\FormHelper, + Cake\View\Helper\HtmlHelper, + Cake\Core\App, + Cake\Core\Plugin, + Cake\Core\Configure, + Cake\Routing\Router, + Cake\Network\Request, + Cake\Utility\ClassRegistry, + Cake\Utility\Security; /** * ContactTestController class @@ -55,7 +62,7 @@ class ContactTestController extends Controller { * @package cake * @package Cake.Test.Case.View.Helper */ -class Contact extends CakeTestModel { +class Contact extends TestModel { /** * primaryKey property @@ -136,14 +143,21 @@ public function setSchema($schema) { * * @var array */ - public $hasAndBelongsToMany = array('ContactTag' => array('with' => 'ContactTagsContact')); + public $hasAndBelongsToMany = array( + 'ContactTag' => array( + 'className' => 'Cake\Test\TestCase\View\Helper\ContactTag', + 'with' => 'Cake\Test\TestCase\View\Helper\ContactTagsContact' + ) + ); /** * hasAndBelongsToMany property * * @var array */ - public $belongsTo = array('User' => array('className' => 'UserForm')); + public $belongsTo = array( + 'User' => array('className' => 'UserForm' + )); } /** @@ -152,7 +166,7 @@ public function setSchema($schema) { * @package cake * @package Cake.Test.Case.View.Helper */ -class ContactTagsContact extends CakeTestModel { +class ContactTagsContact extends TestModel { /** * useTable property @@ -261,7 +275,7 @@ class ContactTag extends Model { * @package cake * @package Cake.Test.Case.View.Helper */ -class UserForm extends CakeTestModel { +class UserForm extends TestModel { /** * useTable property @@ -316,7 +330,7 @@ class UserForm extends CakeTestModel { * @package cake * @package Cake.Test.Case.View.Helper */ -class OpenidUrl extends CakeTestModel { +class OpenidUrl extends TestModel { /** * useTable property @@ -386,7 +400,7 @@ public function beforeValidate($options = array()) { * @package cake * @package Cake.Test.Case.View.Helper */ -class ValidateUser extends CakeTestModel { +class ValidateUser extends TestModel { /** * primaryKey property @@ -450,7 +464,7 @@ public function beforeValidate($options = array()) { * @package cake * @package Cake.Test.Case.View.Helper */ -class ValidateProfile extends CakeTestModel { +class ValidateProfile extends TestModel { /** * primaryKey property @@ -524,7 +538,7 @@ public function beforeValidate($options = array()) { * @package cake * @package Cake.Test.Case.View.Helper */ -class ValidateItem extends CakeTestModel { +class ValidateItem extends TestModel { /** * primaryKey property @@ -588,7 +602,7 @@ public function beforeValidate($options = array()) { * @package cake * @package Cake.Test.Case.View.Helper */ -class TestMail extends CakeTestModel { +class TestMail extends TestModel { /** * primaryKey property @@ -619,7 +633,7 @@ class TestMail extends CakeTestModel { * @subpackage Cake.Test.Case.View.Helper * @property FormHelper $Form */ -class FormHelperTest extends CakeTestCase { +class FormHelperTest extends TestCase { /** * Fixtures to be used @@ -644,12 +658,14 @@ public function setUp() { parent::setUp(); Configure::write('App.base', ''); + Configure::write('App.namespace', 'Cake\Test\TestCase\View\Helper'); + $this->Controller = new ContactTestController(); $this->View = new View($this->Controller); $this->Form = new FormHelper($this->View); $this->Form->Html = new HtmlHelper($this->View); - $this->Form->request = new CakeRequest('contacts/add', false); + $this->Form->request = new Request('contacts/add', false); $this->Form->request->here = '/contacts/add'; $this->Form->request['action'] = 'add'; $this->Form->request->webroot = ''; @@ -2624,7 +2640,7 @@ public function testInputWithMatchingFieldAndModelName() { * @return void */ public function testFormInputs() { - $this->Form->create('Contact'); + $this->Form->create('Cake\Test\TestCase\View\Helper\Contact'); $result = $this->Form->inputs('The Legend'); $expected = array( 'loadFixtures('Post'); App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) + 'Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS) )); - CakePlugin::load('TestPlugin'); - $this->Form->request['models'] = array('TestPluginPost' => array('plugin' => 'TestPlugin', 'className' => 'TestPluginPost')); + Plugin::load('TestPlugin'); + $this->Form->request['models'] = array( + 'TestPluginPost' => array( + 'plugin' => 'TestPlugin', + 'className' => 'TestPluginPost' + ) + ); $this->assertFalse(ClassRegistry::isKeySet('TestPluginPost')); $this->Form->create('TestPluginPost'); $this->assertTrue(ClassRegistry::isKeySet('TestPluginPost')); - $this->assertInstanceOf('TestPluginPost', ClassRegistry::getObject('TestPluginPost')); + $this->assertInstanceOf('TestPlugin\Model\TestPluginPost', ClassRegistry::getObject('TestPluginPost')); - CakePlugin::unload(); + Plugin::unload(); App::build(); } diff --git a/lib/Cake/Test/TestCase/View/Helper/HtmlHelperTest.php b/lib/Cake/Test/TestCase/View/Helper/HtmlHelperTest.php index 4b726201687..9cd30f64837 100644 --- a/lib/Cake/Test/TestCase/View/Helper/HtmlHelperTest.php +++ b/lib/Cake/Test/TestCase/View/Helper/HtmlHelperTest.php @@ -16,14 +16,22 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ - -App::uses('Controller', 'Controller'); -App::uses('Helper', 'View'); -App::uses('AppHelper', 'View/Helper'); -App::uses('HtmlHelper', 'View/Helper'); -App::uses('FormHelper', 'View/Helper'); -App::uses('ClassRegistry', 'Utility'); -App::uses('Folder', 'Utility'); +namespace Cake\Test\TestCase\View\Helper; + +use Cake\TestSuite\TestCase, + Cake\Model\Model, + Cake\Controller\Controller, + Cake\Routing\Router, + Cake\View\View, + Cake\View\Helper\FormHelper, + Cake\View\Helper\HtmlHelper, + Cake\Core\App, + Cake\Core\Configure, + Cake\Core\Plugin, + Cake\Network\Request, + Cake\Utility\ClassRegistry, + Cake\Utility\File, + Cake\Utility\Folder; if (!defined('FULL_BASE_URL')) { define('FULL_BASE_URL', 'http://cakephp.org'); @@ -115,7 +123,7 @@ class Html5TestHelper extends TestHtmlHelper { * * @package Cake.Test.Case.View.Helper */ -class HtmlHelperTest extends CakeTestCase { +class HtmlHelperTest extends TestCase { /** * Regexp for CDATA start block @@ -145,13 +153,13 @@ class HtmlHelperTest extends CakeTestCase { */ public function setUp() { parent::setUp(); - $this->View = $this->getMock('View', array('append'), array(new TheHtmlTestController())); + $this->View = $this->getMock('Cake\View\View', array('append'), array(new TheHtmlTestController())); $this->Html = new TestHtmlHelper($this->View); - $this->Html->request = new CakeRequest(null, false); + $this->Html->request = new Request(null, false); $this->Html->request->webroot = ''; App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) + 'Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS) )); Configure::write('Asset.timestamp', false); @@ -402,13 +410,11 @@ public function testImageTagWithTheme() { $this->skipIf(!is_writable(WWW_ROOT), 'Cannot write to webroot.'); $themeExists = is_dir(WWW_ROOT . 'theme'); - App::uses('File', 'Utility'); - $testfile = WWW_ROOT . 'theme' . DS . 'test_theme' . DS . 'img' . DS . '__cake_test_image.gif'; $File = new File($testfile, true); App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) + 'View' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS) )); Configure::write('Asset.timestamp', true); Configure::write('debug', 1); @@ -446,10 +452,10 @@ public function testImageTagWithTheme() { */ public function testThemeAssetsInMainWebrootPath() { App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) + 'View' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS) )); $webRoot = Configure::read('App.www_root'); - Configure::write('App.www_root', CAKE . 'Test' . DS . 'test_app' . DS . 'webroot' . DS); + Configure::write('App.www_root', CAKE . 'Test' . DS . 'TestApp' . DS . 'webroot' . DS); $this->Html->theme = 'test_theme'; $result = $this->Html->css('webroot_test'); @@ -504,11 +510,11 @@ public function testCssLink() { $result = $this->Html->css('screen.css'); $this->assertTags($result, $expected); - CakePlugin::load('TestPlugin'); + Plugin::load('TestPlugin'); $result = $this->Html->css('TestPlugin.style', null, array('plugin' => false)); $expected['link']['href'] = 'preg:/.*css\/TestPlugin\.style\.css/'; $this->assertTags($result, $expected); - CakePlugin::unload('TestPlugin'); + Plugin::unload('TestPlugin'); $result = $this->Html->css('my.css.library'); $expected['link']['href'] = 'preg:/.*css\/my\.css\.library\.css/'; @@ -566,7 +572,7 @@ public function testCssLink() { */ public function testPluginCssLink() { Configure::write('Asset.filter.css', false); - CakePlugin::load('TestPlugin'); + Plugin::load('TestPlugin'); $result = $this->Html->css('TestPlugin.test_plugin_asset'); $expected = array( @@ -599,7 +605,7 @@ public function testPluginCssLink() { $this->assertTags($result[1], $expected); $this->assertEquals(2, count($result)); - CakePlugin::unload('TestPlugin'); + Plugin::unload('TestPlugin'); } /** @@ -648,7 +654,7 @@ public function testCssTimestamping() { * @return void */ public function testPluginCssTimestamping() { - CakePlugin::load('TestPlugin'); + Plugin::load('TestPlugin'); Configure::write('debug', 2); Configure::write('Asset.timestamp', true); @@ -683,7 +689,7 @@ public function testPluginCssTimestamping() { $expected['link']['href'] = 'preg:/\/testing\/longer\/test_plugin\/css\/test_plugin_asset\.css\?[0-9]+/'; $this->assertTags($result, $expected); - CakePlugin::unload('TestPlugin'); + Plugin::unload('TestPlugin'); } /** @@ -717,7 +723,7 @@ public function testScriptTimestamping() { * @return void */ public function testPluginScriptTimestamping() { - CakePlugin::load('TestPlugin'); + Plugin::load('TestPlugin'); $pluginPath = App::pluginPath('TestPlugin'); $pluginJsPath = $pluginPath . 'webroot/js'; @@ -739,7 +745,7 @@ public function testPluginScriptTimestamping() { unlink($pluginJsPath . DS . '__cake_js_test.js'); Configure::write('Asset.timestamp', false); - CakePlugin::unload('TestPlugin'); + Plugin::unload('TestPlugin'); } /** @@ -823,7 +829,7 @@ public function testScript() { * @return void */ public function testPluginScript() { - CakePlugin::load('TestPlugin'); + Plugin::load('TestPlugin'); $result = $this->Html->script('TestPlugin.foo'); $expected = array( @@ -879,7 +885,7 @@ public function testPluginScript() { ); $this->assertTags($result, $expected); - CakePlugin::unload('TestPlugin'); + Plugin::unload('TestPlugin'); } /** @@ -940,13 +946,11 @@ public function testScriptInTheme() { $this->skipIf(!is_writable(WWW_ROOT), 'Cannot write to webroot.'); $themeExists = is_dir(WWW_ROOT . 'theme'); - App::uses('File', 'Utility'); - $testfile = WWW_ROOT . 'theme' . DS . 'test_theme' . DS . 'js' . DS . '__test_js.js'; $File = new File($testfile, true); App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) + 'View' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS) )); $this->Html->webroot = '/'; @@ -1801,7 +1805,7 @@ public function testCrumbListFirstLink() { */ public function testLoadConfig() { - $path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS; + $path = CAKE . 'Test' . DS . 'TestApp' . DS . 'Config' . DS; $result = $this->Html->loadConfig('htmlhelper_tags', $path); $expected = array( @@ -1828,7 +1832,7 @@ public function testLoadConfig() { * testLoadConfigWrongFile method * * @return void - * @expectedException ConfigureException + * @expectedException Cake\Error\ConfigureException */ public function testLoadConfigWrongFile() { $result = $this->Html->loadConfig('wrong_file'); @@ -1838,10 +1842,10 @@ public function testLoadConfigWrongFile() { * testLoadConfigWrongReader method * * @return void - * @expectedException ConfigureException + * @expectedException Cake\Error\ConfigureException */ public function testLoadConfigWrongReader() { - $path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS; + $path = CAKE . 'Test' . DS . 'TestApp' . DS . 'Config' . DS; $result = $this->Html->loadConfig(array('htmlhelper_tags', 'wrong_reader'), $path); } diff --git a/lib/Cake/Test/TestCase/View/Helper/JqueryEngineHelperTest.php b/lib/Cake/Test/TestCase/View/Helper/JqueryEngineHelperTest.php index 4823f1ec5fc..f34af5e27b8 100644 --- a/lib/Cake/Test/TestCase/View/Helper/JqueryEngineHelperTest.php +++ b/lib/Cake/Test/TestCase/View/Helper/JqueryEngineHelperTest.php @@ -15,13 +15,15 @@ * @package Cake.Test.Case.View.Helper * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +namespace Cake\Test\TestCase\View\Helper; -App::uses('HtmlHelper', 'View/Helper'); -App::uses('JsHelper', 'View/Helper'); -App::uses('JqueryEngineHelper', 'View/Helper'); -App::uses('View', 'View'); +use Cake\TestSuite\TestCase, + Cake\View\Helper\HtmlHelper, + Cake\View\Helper\JsHelper, + Cake\View\Helper\JqueryEngineHelper, + Cake\View\View; -class JqueryEngineHelperTest extends CakeTestCase { +class JqueryEngineHelperTest extends TestCase { /** * setUp @@ -31,7 +33,7 @@ class JqueryEngineHelperTest extends CakeTestCase { public function setUp() { parent::setUp(); $controller = null; - $this->View = $this->getMock('View', array('addScript'), array(&$controller)); + $this->View = $this->getMock('Cake\View\View', array('addScript'), array(&$controller)); $this->Jquery = new JqueryEngineHelper($this->View); } diff --git a/lib/Cake/Test/TestCase/View/Helper/JsHelperTest.php b/lib/Cake/Test/TestCase/View/Helper/JsHelperTest.php index 8589850a8a5..28139880cb9 100644 --- a/lib/Cake/Test/TestCase/View/Helper/JsHelperTest.php +++ b/lib/Cake/Test/TestCase/View/Helper/JsHelperTest.php @@ -18,12 +18,17 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('HtmlHelper', 'View/Helper'); -App::uses('JsHelper', 'View/Helper'); -App::uses('JsBaseEngineHelper', 'View/Helper'); -App::uses('FormHelper', 'View/Helper'); -App::uses('View', 'View'); -App::uses('ClassRegistry', 'Utility'); +namespace Cake\Test\TestCase\View\Helper; + +use Cake\TestSuite\TestCase, + Cake\View\Helper\HtmlHelper, + Cake\View\Helper\JsHelper, + Cake\View\Helper\JsBaseEngineHelper, + Cake\View\Helper\FormHelper, + Cake\View\View, + Cake\Utility\ClassRegistry, + Cake\Network\Request, + Cake\Core\Configure; class JsEncodingObject { @@ -101,7 +106,7 @@ public function serializeForm($options = array()) { * * @package Cake.Test.Case.View.Helper */ -class JsHelperTest extends CakeTestCase { +class JsHelperTest extends TestCase { /** * Regexp for CDATA start block @@ -127,9 +132,9 @@ public function setUp() { Configure::write('Asset.timestamp', false); $controller = null; - $this->View = $this->getMock('View', array('append'), array(&$controller)); + $this->View = $this->getMock('Cake\View\View', array('append'), array(&$controller)); $this->Js = new JsHelper($this->View, 'Option'); - $request = new CakeRequest(null, false); + $request = new Request(null, false); $this->Js->request = $request; $this->Js->Html = new HtmlHelper($this->View); $this->Js->Html->request = $request; @@ -156,14 +161,14 @@ public function tearDown() { * @return void */ protected function _useMock() { - $request = new CakeRequest(null, false); + $request = new Request(null, false); if (!class_exists('TestJsEngineHelper', false)) { - $this->getMock('JsBaseEngineHelper', array(), array($this->View), 'TestJsEngineHelper'); + $this->getMock('Cake\View\Helper\JsBaseEngineHelper', array(), array($this->View), 'TestJsEngineHelper'); } $this->Js = new JsHelper($this->View, array('TestJs')); - $this->Js->TestJsEngine = new TestJsEngineHelper($this->View); + $this->Js->TestJsEngine = new \TestJsEngineHelper($this->View); $this->mockObjects[] = $this->Js->TestJsEngine; $this->Js->request = $request; $this->Js->Html = new HtmlHelper($this->View); @@ -208,7 +213,7 @@ public function testMethodDispatching() { $this->Js->event('click', 'callback'); - $this->Js->TestJsEngine = new StdClass(); + $this->Js->TestJsEngine = new \StdClass(); $this->Js->someMethodThatSurelyDoesntExist(); } @@ -352,7 +357,7 @@ public function testWriteScriptsInFile() { $this->skipIf(!is_writable(JS), 'webroot/js is not Writable, script caching test has been skipped.'); $this->Js->request->webroot = '/'; - $this->Js->JsBaseEngine = new TestJsEngineHelper($this->View); + $this->Js->JsBaseEngine = new \TestJsEngineHelper($this->View); $this->Js->buffer('one = 1;'); $this->Js->buffer('two = 2;'); $result = $this->Js->writeBuffer(array('onDomReady' => false, 'cache' => true)); @@ -722,7 +727,7 @@ public function testSetVarsAtTopOfBufferedScripts() { * * @package Cake.Test.Case.View.Helper */ -class JsBaseEngineTest extends CakeTestCase { +class JsBaseEngineTest extends TestCase { /** * setUp method diff --git a/lib/Cake/Test/TestCase/View/Helper/MootoolsEngineHelperTest.php b/lib/Cake/Test/TestCase/View/Helper/MootoolsEngineHelperTest.php index 91af71eb30b..dc221674566 100644 --- a/lib/Cake/Test/TestCase/View/Helper/MootoolsEngineHelperTest.php +++ b/lib/Cake/Test/TestCase/View/Helper/MootoolsEngineHelperTest.php @@ -16,12 +16,15 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('View', 'View'); -App::uses('HtmlHelper', 'View/Helper'); -App::uses('JsHelper', 'View/Helper'); -App::uses('MootoolsEngineHelper', 'View/Helper'); +namespace Cake\Test\TestCase\View\Helper; -class MootoolsEngineHelperTest extends CakeTestCase { +use Cake\TestSuite\TestCase, + Cake\View\View, + Cake\View\Helper\HtmlHelper, + Cake\View\Helper\JsHelper, + Cake\View\Helper\MootoolsEngineHelper; + +class MootoolsEngineHelperTest extends TestCase { /** * setUp @@ -31,7 +34,7 @@ class MootoolsEngineHelperTest extends CakeTestCase { public function setUp() { parent::setUp(); $controller = null; - $this->View = $this->getMock('View', array('addScript'), array(&$controller)); + $this->View = $this->getMock('Cake\View\View', array('addScript'), array(&$controller)); $this->Moo = new MootoolsEngineHelper($this->View); } diff --git a/lib/Cake/Test/TestCase/View/Helper/NumberHelperTest.php b/lib/Cake/Test/TestCase/View/Helper/NumberHelperTest.php index f75ffd9d1da..8d2a190334a 100644 --- a/lib/Cake/Test/TestCase/View/Helper/NumberHelperTest.php +++ b/lib/Cake/Test/TestCase/View/Helper/NumberHelperTest.php @@ -16,16 +16,21 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +namespace Cake\Test\TestCase\View\Helper; -App::uses('View', 'View'); -App::uses('NumberHelper', 'View/Helper'); +use Cake\TestSuite\TestCase, + Cake\View\Helper\NumberHelper, + Cake\View\View, + Cake\Core\App, + Cake\Core\Configure, + Cake\Core\Plugin; /** * NumberHelperTestObject class */ class NumberHelperTestObject extends NumberHelper { - public function attach(CakeNumberMock $cakeNumber) { + public function attach(NumberMock $cakeNumber) { $this->_engine = $cakeNumber; } @@ -36,9 +41,9 @@ public function engine() { } /** - * CakeNumberMock class + * NumberMock class */ -class CakeNumberMock { +class NumberMock { } /** @@ -46,7 +51,7 @@ class CakeNumberMock { * * @package Cake.Test.Case.View.Helper */ -class NumberHelperTest extends CakeTestCase { +class NumberHelperTest extends TestCase { /** * setUp method @@ -56,6 +61,9 @@ class NumberHelperTest extends CakeTestCase { public function setUp() { parent::setUp(); $this->View = new View(null); + + $this->_appNamespace = Configure::read('App.namespace'); + Configure::write('App.namespace', 'TestApp'); } /** @@ -65,6 +73,7 @@ public function setUp() { */ public function tearDown() { parent::tearDown(); + Configure::write('App.namespace', $this->_appNamespace); unset($this->View); } @@ -76,8 +85,8 @@ public function testNumberHelperProxyMethodCalls() { 'precision', 'toReadableSize', 'toPercentage', 'format', 'currency', 'addFormat', ); - $CakeNumber = $this->getMock('CakeNumberMock', $methods); - $Number = new NumberHelperTestObject($this->View, array('engine' => 'CakeNumberMock')); + $CakeNumber = $this->getMock(__NAMESPACE__ . '\NumberMock', $methods); + $Number = new NumberHelperTestObject($this->View, array('engine' => __NAMESPACE__ . '\NumberMock')); $Number->attach($CakeNumber); foreach ($methods as $method) { $CakeNumber->expects($this->at(0))->method($method); @@ -90,18 +99,18 @@ public function testNumberHelperProxyMethodCalls() { */ public function testEngineOverride() { App::build(array( - 'Utility' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Utility' . DS) + 'Utility' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Utility' . DS) ), App::REGISTER); $Number = new NumberHelperTestObject($this->View, array('engine' => 'TestAppEngine')); - $this->assertInstanceOf('TestAppEngine', $Number->engine()); + $this->assertInstanceOf('TestApp\Utility\TestAppEngine', $Number->engine()); App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) + 'Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS) )); - CakePlugin::load('TestPlugin'); + Plugin::load('TestPlugin'); $Number = new NumberHelperTestObject($this->View, array('engine' => 'TestPlugin.TestPluginEngine')); - $this->assertInstanceOf('TestPluginEngine', $Number->engine()); - CakePlugin::unload('TestPlugin'); + $this->assertInstanceOf('TestPlugin\Utility\TestPluginEngine', $Number->engine()); + Plugin::unload('TestPlugin'); } } diff --git a/lib/Cake/Test/TestCase/View/Helper/PaginatorHelperTest.php b/lib/Cake/Test/TestCase/View/Helper/PaginatorHelperTest.php index fb8289f0c43..fcf5fd5b12e 100644 --- a/lib/Cake/Test/TestCase/View/Helper/PaginatorHelperTest.php +++ b/lib/Cake/Test/TestCase/View/Helper/PaginatorHelperTest.php @@ -16,11 +16,16 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('View', 'View'); -App::uses('HtmlHelper', 'View/Helper'); -App::uses('JsHelper', 'View/Helper'); -App::uses('PaginatorHelper', 'View/Helper'); -App::uses('FormHelper', 'View/Helper'); +namespace Cake\Test\TestCase\View\Helper; +use Cake\TestSuite\TestCase, + Cake\View\Helper\PaginatorHelper, + Cake\View\Helper\HtmlHelper, + Cake\View\Helper\FormHelper, + Cake\View\Helper\JsHelper, + Cake\View\View, + Cake\Network\Request, + Cake\Core\Configure, + Cake\Routing\Router; if (!defined('FULL_BASE_URL')) { define('FULL_BASE_URL', 'http://cakephp.org'); @@ -31,7 +36,7 @@ * * @package Cake.Test.Case.View.Helper */ -class PaginatorHelperTest extends CakeTestCase { +class PaginatorHelperTest extends TestCase { /** * setUp method @@ -42,8 +47,8 @@ public function setUp() { $controller = null; $this->View = new View($controller); $this->Paginator = new PaginatorHelper($this->View); - $this->Paginator->Js = $this->getMock('PaginatorHelper', array(), array($this->View)); - $this->Paginator->request = new CakeRequest(null, false); + $this->Paginator->Js = $this->getMock('Cake\View\Helper\PaginatorHelper', array(), array($this->View)); + $this->Paginator->request = new Request(null, false); $this->Paginator->request->addParams(array( 'paging' => array( 'Article' => array( @@ -2335,11 +2340,11 @@ public function testAjaxLinkGenerationLink() { /** * test that mock classes injected into paginatorHelper are called when using link() * - * @expectedException CakeException + * @expectedException Cake\Error\Exception * @return void */ public function testMockAjaxProviderClassInjection() { - $mock = $this->getMock('PaginatorHelper', array(), array($this->View), 'PaginatorMockJsHelper'); + $mock = $this->getMock('Cake\View\Helper\PaginatorHelper', array(), array($this->View), 'PaginatorMockJsHelper'); $Paginator = new PaginatorHelper($this->View, array('ajax' => 'PaginatorMockJs')); $Paginator->request->params['paging'] = array( 'Article' => array( @@ -2442,7 +2447,7 @@ public function testCurrent() { * @return void */ public function testNoDefaultModel() { - $this->Paginator->request = new CakeRequest(null, false); + $this->Paginator->request = new Request(null, false); $this->assertNull($this->Paginator->defaultModel()); } diff --git a/lib/Cake/Test/TestCase/View/Helper/PrototypeEngineHelperTest.php b/lib/Cake/Test/TestCase/View/Helper/PrototypeEngineHelperTest.php index 2df8cefa3ec..85bf90c1182 100644 --- a/lib/Cake/Test/TestCase/View/Helper/PrototypeEngineHelperTest.php +++ b/lib/Cake/Test/TestCase/View/Helper/PrototypeEngineHelperTest.php @@ -15,13 +15,15 @@ * @package Cake.Test.Case.View.Helper * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +namespace Cake\Test\TestCase\View\Helper; -App::uses('View', 'View'); -App::uses('HtmlHelper', 'View/Helper'); -App::uses('JsHelper', 'View/Helper'); -App::uses('PrototypeEngineHelper', 'View/Helper'); +use Cake\TestSuite\TestCase, + Cake\View\View, + Cake\View\Helper\HtmlHelper, + Cake\View\Helper\JsHelper, + Cake\View\Helper\PrototypeEngineHelper; -class PrototypeEngineHelperTest extends CakeTestCase { +class PrototypeEngineHelperTest extends TestCase { /** * setUp @@ -31,7 +33,7 @@ class PrototypeEngineHelperTest extends CakeTestCase { public function setUp() { parent::setUp(); $controller = null; - $this->View = $this->getMock('View', array('addScript'), array(&$controller)); + $this->View = $this->getMock('Cake\View\View', array('addScript'), array(&$controller)); $this->Proto = new PrototypeEngineHelper($this->View); } diff --git a/lib/Cake/Test/TestCase/View/Helper/RssHelperTest.php b/lib/Cake/Test/TestCase/View/Helper/RssHelperTest.php index bfffdf4fcf1..e7b022c13fb 100644 --- a/lib/Cake/Test/TestCase/View/Helper/RssHelperTest.php +++ b/lib/Cake/Test/TestCase/View/Helper/RssHelperTest.php @@ -16,17 +16,21 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('View', 'View'); -App::uses('RssHelper', 'View/Helper'); -App::uses('TimeHelper', 'View/Helper'); -App::uses('File', 'Utility'); +namespace Cake\Test\TestCase\View\Helper; + +use Cake\TestSuite\TestCase, + Cake\View\Helper\RssHelper, + Cake\View\Helper\TimeHelper, + Cake\View\View, + Cake\Utility\Folder, + Cake\Utility\File; /** * RssHelperTest class * * @package Cake.Test.Case.View.Helper */ -class RssHelperTest extends CakeTestCase { +class RssHelperTest extends TestCase { /** * setUp method diff --git a/lib/Cake/Test/TestCase/View/Helper/SessionHelperTest.php b/lib/Cake/Test/TestCase/View/Helper/SessionHelperTest.php index 62fc004a362..da98da34a93 100644 --- a/lib/Cake/Test/TestCase/View/Helper/SessionHelperTest.php +++ b/lib/Cake/Test/TestCase/View/Helper/SessionHelperTest.php @@ -16,17 +16,21 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ - -App::uses('Controller', 'Controller'); -App::uses('View', 'View'); -App::uses('SessionHelper', 'View/Helper'); +namespace Cake\Test\TestCase\View\Helper; +use Cake\TestSuite\TestCase, + Cake\View\Helper\SessionHelper, + Cake\View\View, + Cake\Controller\Controller, + Cake\Model\Datasource\Session, + Cake\Core\Plugin, + Cake\Core\App; /** * SessionHelperTest class * * @package Cake.Test.Case.View.Helper */ -class SessionHelperTest extends CakeTestCase { +class SessionHelperTest extends TestCase { /** * setUp method @@ -38,10 +42,10 @@ public function setUp() { $controller = null; $this->View = new View($controller); $this->Session = new SessionHelper($this->View); - CakeSession::start(); + Session::start(); - if (!CakeSession::started()) { - CakeSession::start(); + if (!Session::started()) { + Session::start(); } $_SESSION = array( @@ -80,7 +84,7 @@ public function setUp() { public function tearDown() { $_SESSION = array(); unset($this->View, $this->Session); - CakePlugin::unload(); + Plugin::unload(); parent::tearDown(); } @@ -128,7 +132,7 @@ public function testFlash() { $this->assertEquals($expected, $result); App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) + 'View' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS) )); $result = $this->Session->flash('notification'); $result = str_replace("\r\n", "\n", $result); @@ -161,7 +165,7 @@ public function testFlashAttributes() { */ public function testFlashElementInAttrs() { App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) + 'View' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS) )); $result = $this->Session->flash('flash', array( 'element' => 'session_helper', @@ -178,9 +182,9 @@ public function testFlashElementInAttrs() { */ public function testFlashWithPluginElement() { App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) + 'Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS) )); - CakePlugin::load('TestPlugin'); + Plugin::load('TestPlugin'); $result = $this->Session->flash('flash', array( 'element' => 'plugin_element', diff --git a/lib/Cake/Test/TestCase/View/Helper/TextHelperTest.php b/lib/Cake/Test/TestCase/View/Helper/TextHelperTest.php index 7538f2094ae..6c0d935e67e 100644 --- a/lib/Cake/Test/TestCase/View/Helper/TextHelperTest.php +++ b/lib/Cake/Test/TestCase/View/Helper/TextHelperTest.php @@ -16,9 +16,13 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ - -App::uses('View', 'View'); -App::uses('TextHelper', 'View/Helper'); +namespace Cake\Test\TestCase\View\Helper; +use Cake\TestSuite\TestCase, + Cake\View\Helper\TextHelper, + Cake\View\View, + Cake\Core\App, + Cake\Core\Configure, + Cake\Core\Plugin; class TextHelperTestObject extends TextHelper { @@ -43,7 +47,7 @@ class StringMock { * * @package Cake.Test.Case.View.Helper */ -class TextHelperTest extends CakeTestCase { +class TextHelperTest extends TestCase { /** * setUp method @@ -54,6 +58,9 @@ public function setUp() { parent::setUp(); $this->View = new View(null); $this->Text = new TextHelper($this->View); + + $this->_appNamespace = Configure::read('App.namespace'); + Configure::write('App.namespace', 'TestApp'); } /** @@ -62,7 +69,8 @@ public function setUp() { * @return void */ public function tearDown() { - unset($this->View); + unset($this->Text, $this->View); + Configure::write('App.namespace', $this->_appNamespace); parent::tearDown(); } @@ -73,8 +81,8 @@ public function testTextHelperProxyMethodCalls() { $methods = array( 'highlight', 'stripLinks', 'truncate', 'excerpt', 'toList', ); - $String = $this->getMock('StringMock', $methods); - $Text = new TextHelperTestObject($this->View, array('engine' => 'StringMock')); + $String = $this->getMock(__NAMESPACE__ . '\StringMock', $methods); + $Text = new TextHelperTestObject($this->View, array('engine' => __NAMESPACE__ . '\StringMock')); $Text->attach($String); foreach ($methods as $method) { $String->expects($this->at(0))->method($method); @@ -87,18 +95,18 @@ public function testTextHelperProxyMethodCalls() { */ public function testEngineOverride() { App::build(array( - 'Utility' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Utility' . DS) + 'Utility' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Utility' . DS) ), App::REGISTER); $Text = new TextHelperTestObject($this->View, array('engine' => 'TestAppEngine')); - $this->assertInstanceOf('TestAppEngine', $Text->engine()); + $this->assertInstanceOf('TestApp\Utility\TestAppEngine', $Text->engine()); App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) + 'Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS) )); - CakePlugin::load('TestPlugin'); + Plugin::load('TestPlugin'); $Text = new TextHelperTestObject($this->View, array('engine' => 'TestPlugin.TestPluginEngine')); - $this->assertInstanceOf('TestPluginEngine', $Text->engine()); - CakePlugin::unload('TestPlugin'); + $this->assertInstanceOf('TestPlugin\Utility\TestPluginEngine', $Text->engine()); + Plugin::unload('TestPlugin'); } /** diff --git a/lib/Cake/Test/TestCase/View/Helper/TimeHelperTest.php b/lib/Cake/Test/TestCase/View/Helper/TimeHelperTest.php index 1eecd96354a..e66959d12c6 100644 --- a/lib/Cake/Test/TestCase/View/Helper/TimeHelperTest.php +++ b/lib/Cake/Test/TestCase/View/Helper/TimeHelperTest.php @@ -16,16 +16,20 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('TimeHelper', 'View/Helper'); -App::uses('View', 'View'); -App::uses('CakeTime', 'Utility'); +namespace Cake\Test\TestCase\View\Helper; +use Cake\TestSuite\TestCase, + Cake\View\Helper\TimeHelper, + Cake\View\View, + Cake\Core\App, + Cake\Core\Configure, + Cake\Core\Plugin; /** * TimeHelperTestObject class */ class TimeHelperTestObject extends TimeHelper { - public function attach(CakeTimeMock $cakeTime) { + public function attach(TimeMock $cakeTime) { $this->_engine = $cakeTime; } @@ -36,9 +40,9 @@ public function engine() { } /** - * CakeTimeMock class + * TimeMock class */ -class CakeTimeMock { +class TimeMock { } /** @@ -46,7 +50,7 @@ class CakeTimeMock { * * @package Cake.Test.Case.View.Helper */ -class TimeHelperTest extends CakeTestCase { +class TimeHelperTest extends TestCase { public $Time = null; @@ -60,6 +64,9 @@ class TimeHelperTest extends CakeTestCase { public function setUp() { parent::setUp(); $this->View = new View(null); + + $this->_appNamespace = Configure::read('App.namespace'); + Configure::write('App.namespace', 'TestApp'); } /** @@ -69,6 +76,7 @@ public function setUp() { */ public function tearDown() { unset($this->View); + Configure::write('App.namespace', $this->_appNamespace); parent::tearDown(); } @@ -83,8 +91,8 @@ public function testTimeHelperProxyMethodCalls() { 'isTomorrow', 'toQuarter', 'toUnix', 'toAtom', 'toRSS', 'timeAgoInWords', 'wasWithinLast', 'gmt', 'format', 'i18nFormat', ); - $CakeTime = $this->getMock('CakeTimeMock', $methods); - $Time = new TimeHelperTestObject($this->View, array('engine' => 'CakeTimeMock')); + $CakeTime = $this->getMock(__NAMESPACE__ . '\TimeMock', $methods); + $Time = new TimeHelperTestObject($this->View, array('engine' => __NAMESPACE__ . '\TimeMock')); $Time->attach($CakeTime); foreach ($methods as $method) { $CakeTime->expects($this->at(0))->method($method); @@ -97,18 +105,18 @@ public function testTimeHelperProxyMethodCalls() { */ public function testEngineOverride() { App::build(array( - 'Utility' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Utility' . DS) + 'Utility' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Utility' . DS) ), App::REGISTER); $Time = new TimeHelperTestObject($this->View, array('engine' => 'TestAppEngine')); - $this->assertInstanceOf('TestAppEngine', $Time->engine()); + $this->assertInstanceOf('TestApp\Utility\TestAppEngine', $Time->engine()); App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) + 'Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS) )); - CakePlugin::load('TestPlugin'); + Plugin::load('TestPlugin'); $Time = new TimeHelperTestObject($this->View, array('engine' => 'TestPlugin.TestPluginEngine')); - $this->assertInstanceOf('TestPluginEngine', $Time->engine()); - CakePlugin::unload('TestPlugin'); + $this->assertInstanceOf('TestPlugin\Utility\TestPluginEngine', $Time->engine()); + Plugin::unload('TestPlugin'); } /** diff --git a/lib/Cake/Test/TestCase/View/HelperCollectionTest.php b/lib/Cake/Test/TestCase/View/HelperCollectionTest.php index eae0ce37235..0797f00573f 100644 --- a/lib/Cake/Test/TestCase/View/HelperCollectionTest.php +++ b/lib/Cake/Test/TestCase/View/HelperCollectionTest.php @@ -16,10 +16,14 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +namespace Cake\Test\TestCase\View; -App::uses('HelperCollection', 'View'); -App::uses('HtmlHelper', 'View/Helper'); -App::uses('View', 'View'); +use Cake\TestSuite\TestCase, + Cake\View\HelperCollection, + Cake\View\View, + Cake\View\Helper\HtmlHelper, + Cake\Core\App, + Cake\Core\Plugin; /** * Extended HtmlHelper @@ -27,7 +31,7 @@ class HtmlAliasHelper extends HtmlHelper { } -class HelperCollectionTest extends CakeTestCase { +class HelperCollectionTest extends TestCase { /** * setUp @@ -36,7 +40,7 @@ class HelperCollectionTest extends CakeTestCase { */ public function setUp() { parent::setUp(); - $this->View = $this->getMock('View', array(), array(null)); + $this->View = $this->getMock('Cake\View\View', array(), array(null)); $this->Helpers = new HelperCollection($this->View); } @@ -46,7 +50,7 @@ public function setUp() { * @return void */ public function tearDown() { - CakePlugin::unload(); + Plugin::unload(); unset($this->Helpers, $this->View); parent::tearDown(); } @@ -58,8 +62,8 @@ public function tearDown() { */ public function testLoad() { $result = $this->Helpers->load('Html'); - $this->assertInstanceOf('HtmlHelper', $result); - $this->assertInstanceOf('HtmlHelper', $this->Helpers->Html); + $this->assertInstanceOf('Cake\View\Helper\HtmlHelper', $result); + $this->assertInstanceOf('Cake\View\Helper\HtmlHelper', $this->Helpers->Html); $result = $this->Helpers->attached(); $this->assertEquals(array('Html'), $result, 'attached() results are wrong.'); @@ -74,22 +78,22 @@ public function testLoad() { */ public function testLazyLoad() { $result = $this->Helpers->Html; - $this->assertInstanceOf('HtmlHelper', $result); + $this->assertInstanceOf('Cake\View\Helper\HtmlHelper', $result); $result = $this->Helpers->Form; - $this->assertInstanceOf('FormHelper', $result); + $this->assertInstanceOf('Cake\View\Helper\FormHelper', $result); - App::build(array('Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS))); + App::build(array('Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS))); $this->View->plugin = 'TestPlugin'; - CakePlugin::load(array('TestPlugin')); + Plugin::load(array('TestPlugin')); $result = $this->Helpers->OtherHelper; - $this->assertInstanceOf('OtherHelperHelper', $result); + $this->assertInstanceOf('TestPlugin\View\Helper\OtherHelperHelper', $result); } /** * test lazy loading of helpers * - * @expectedException MissingHelperException + * @expectedException Cake\Error\MissingHelperException * @return void */ public function testLazyLoadException() { @@ -102,9 +106,9 @@ public function testLazyLoadException() { * @return void */ public function testLoadWithAlias() { - $result = $this->Helpers->load('Html', array('className' => 'HtmlAlias')); - $this->assertInstanceOf('HtmlAliasHelper', $result); - $this->assertInstanceOf('HtmlAliasHelper', $this->Helpers->Html); + $result = $this->Helpers->load('Html', array('className' => __NAMESPACE__ . '\HtmlAliasHelper')); + $this->assertInstanceOf(__NAMESPACE__ . '\HtmlAliasHelper', $result); + $this->assertInstanceOf(__NAMESPACE__ . '\HtmlAliasHelper', $this->Helpers->Html); $result = $this->Helpers->attached(); $this->assertEquals(array('Html'), $result, 'attached() results are wrong.'); @@ -112,13 +116,13 @@ public function testLoadWithAlias() { $this->assertTrue($this->Helpers->enabled('Html')); $result = $this->Helpers->load('Html'); - $this->assertInstanceOf('HtmlAliasHelper', $result); + $this->assertInstanceOf(__NAMESPACE__ . '\HtmlAliasHelper', $result); - App::build(array('Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS))); - CakePlugin::load(array('TestPlugin')); + App::build(array('Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS))); + Plugin::load(array('TestPlugin')); $result = $this->Helpers->load('SomeOther', array('className' => 'TestPlugin.OtherHelper')); - $this->assertInstanceOf('OtherHelperHelper', $result); - $this->assertInstanceOf('OtherHelperHelper', $this->Helpers->SomeOther); + $this->assertInstanceOf('TestPlugin\View\Helper\OtherHelperHelper', $result); + $this->assertInstanceOf('TestPlugin\View\Helper\OtherHelperHelper', $this->Helpers->SomeOther); $result = $this->Helpers->attached(); $this->assertEquals(array('Html', 'SomeOther'), $result, 'attached() results are wrong.'); @@ -132,8 +136,8 @@ public function testLoadWithAlias() { */ public function testLoadWithEnabledFalse() { $result = $this->Helpers->load('Html', array('enabled' => false)); - $this->assertInstanceOf('HtmlHelper', $result); - $this->assertInstanceOf('HtmlHelper', $this->Helpers->Html); + $this->assertInstanceOf('Cake\View\Helper\HtmlHelper', $result); + $this->assertInstanceOf('Cake\View\Helper\HtmlHelper', $this->Helpers->Html); $this->assertFalse($this->Helpers->enabled('Html'), 'Html should be disabled'); } @@ -141,7 +145,7 @@ public function testLoadWithEnabledFalse() { /** * test missinghelper exception * - * @expectedException MissingHelperException + * @expectedException Cake\Error\MissingHelperException * @return void */ public function testLoadMissingHelper() { @@ -155,12 +159,13 @@ public function testLoadMissingHelper() { */ public function testLoadPluginHelper() { App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), + 'Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS), )); - CakePlugin::load(array('TestPlugin')); + Plugin::load(array('TestPlugin')); + $result = $this->Helpers->load('TestPlugin.OtherHelper'); - $this->assertInstanceOf('OtherHelperHelper', $result, 'Helper class is wrong.'); - $this->assertInstanceOf('OtherHelperHelper', $this->Helpers->OtherHelper, 'Class is wrong'); + $this->assertInstanceOf('TestPlugin\View\Helper\OtherHelperHelper', $result, 'Helper class is wrong.'); + $this->assertInstanceOf('TestPlugin\View\Helper\OtherHelperHelper', $this->Helpers->OtherHelper, 'Class is wrong'); App::build(); } diff --git a/lib/Cake/Test/TestCase/View/HelperTest.php b/lib/Cake/Test/TestCase/View/HelperTest.php index 65d9d8eb5d9..f8f7ad95c37 100644 --- a/lib/Cake/Test/TestCase/View/HelperTest.php +++ b/lib/Cake/Test/TestCase/View/HelperTest.php @@ -16,11 +16,17 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ - -App::uses('View', 'View'); -App::uses('Helper', 'View'); -App::uses('Model', 'Model'); -App::uses('Router', 'Routing'); +namespace Cake\Test\TestCase\View; +use Cake\TestSuite\TestCase, + Cake\View\Helper, + Cake\View\View, + Cake\Model\Model, + Cake\Routing\Router, + Cake\Network\Request, + Cake\Core\Plugin, + Cake\Core\Configure, + Cake\Core\App, + Cake\Utility\ClassRegistry; /** * HelperTestPost class @@ -185,7 +191,7 @@ public function parseAttributes($options, $exclude = null, $insertBefore = ' ', * * @package Cake.Test.Case.View */ -class HelperTest extends CakeTestCase { +class HelperTest extends TestCase { /** * setUp method @@ -200,14 +206,14 @@ public function setUp() { $null = null; $this->View = new View($null); $this->Helper = new Helper($this->View); - $this->Helper->request = new CakeRequest(null, false); + $this->Helper->request = new Request(null, false); ClassRegistry::addObject('HelperTestPost', new HelperTestPost()); ClassRegistry::addObject('HelperTestComment', new HelperTestComment()); ClassRegistry::addObject('HelperTestTag', new HelperTestTag()); App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), + 'Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS), )); } @@ -220,7 +226,7 @@ public function tearDown() { parent::tearDown(); Configure::delete('Asset'); - CakePlugin::unload(); + Plugin::unload(); unset($this->Helper, $this->View); } @@ -633,7 +639,7 @@ public function testAssetUrl() { */ public function testAssetUrlPlugin() { $this->Helper->webroot = ''; - CakePlugin::load('TestPlugin'); + Plugin::load('TestPlugin'); $result = $this->Helper->assetUrl('TestPlugin.style', array('ext' => '.css')); $this->assertEquals('test_plugin/style.css', $result); @@ -641,7 +647,7 @@ public function testAssetUrlPlugin() { $result = $this->Helper->assetUrl('TestPlugin.style', array('ext' => '.css', 'plugin' => false)); $this->assertEquals('TestPlugin.style.css', $result); - CakePlugin::unload('TestPlugin'); + Plugin::unload('TestPlugin'); } /** @@ -665,9 +671,9 @@ public function testAssetUrlTimestampForce() { public function testAssetTimestampPluginsAndThemes() { Configure::write('Asset.timestamp', 'force'); App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS), + 'View' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS), )); - CakePlugin::load(array('TestPlugin')); + Plugin::load(array('TestPlugin')); $result = $this->Helper->assetTimestamp('/test_plugin/css/test_plugin_asset.css'); $this->assertRegExp('#/test_plugin/css/test_plugin_asset.css\?[0-9]+$#', $result, 'Missing timestamp plugin'); @@ -861,7 +867,7 @@ public function testWebrootPaths() { $this->Helper->theme = 'test_theme'; App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) + 'View' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS) )); $result = $this->Helper->webroot('/img/cake.power.gif'); @@ -873,7 +879,7 @@ public function testWebrootPaths() { $this->assertEquals($expected, $result); $webRoot = Configure::read('App.www_root'); - Configure::write('App.www_root', CAKE . 'Test' . DS . 'test_app' . DS . 'webroot' . DS); + Configure::write('App.www_root', CAKE . 'Test' . DS . 'TestApp' . DS . 'webroot' . DS); $result = $this->Helper->webroot('/img/cake.power.gif'); $expected = '/theme/test_theme/img/cake.power.gif'; @@ -901,12 +907,13 @@ public function testWebrootPaths() { */ public function testLazyLoadingHelpers() { App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), + 'Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS), )); - CakePlugin::load(array('TestPlugin')); + Plugin::load(array('TestPlugin')); + $Helper = new TestHelper($this->View); - $this->assertInstanceOf('OtherHelperHelper', $Helper->OtherHelper); - $this->assertInstanceOf('HtmlHelper', $Helper->Html); + $this->assertInstanceOf('TestPlugin\View\Helper\OtherHelperHelper', $Helper->OtherHelper); + $this->assertInstanceOf('Cake\View\Helper\HtmlHelper', $Helper->Html); App::build(); } @@ -916,6 +923,11 @@ public function testLazyLoadingHelpers() { * @return void */ public function testThatHelperHelpersAreNotAttached() { + App::build(array( + 'Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS), + )); + Plugin::loadAll(); + $Helper = new TestHelper($this->View); $Helper->OtherHelper; diff --git a/lib/Cake/Test/TestCase/View/JsonViewTest.php b/lib/Cake/Test/TestCase/View/JsonViewTest.php index 39a3e7a1dff..ec3d8d80719 100644 --- a/lib/Cake/Test/TestCase/View/JsonViewTest.php +++ b/lib/Cake/Test/TestCase/View/JsonViewTest.php @@ -16,18 +16,20 @@ * @since CakePHP(tm) v 2.1.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ - -App::uses('Controller', 'Controller'); -App::uses('CakeRequest', 'Network'); -App::uses('CakeResponse', 'Network'); -App::uses('JsonView', 'View'); +namespace Cake\Test\TestCase\View; +use Cake\TestSuite\TestCase, + Cake\View\JsonView, + Cake\Controller\Controller, + Cake\Network\Request, + Cake\Network\Response, + Cake\Core\App; /** * JsonViewTest * * @package Cake.Test.Case.View */ -class JsonViewTest extends CakeTestCase { +class JsonViewTest extends TestCase { /** * testRenderWithoutView method @@ -35,8 +37,8 @@ class JsonViewTest extends CakeTestCase { * @return void */ public function testRenderWithoutView() { - $Request = new CakeRequest(); - $Response = new CakeResponse(); + $Request = new Request(); + $Response = new Response(); $Controller = new Controller($Request, $Response); $data = array('user' => 'fake', 'list' => array('item1', 'item2')); $Controller->set(array('data' => $data, '_serialize' => 'data')); @@ -53,8 +55,8 @@ public function testRenderWithoutView() { * @return void */ public function testRenderWithoutViewMultiple() { - $Request = new CakeRequest(); - $Response = new CakeResponse(); + $Request = new Request(); + $Response = new Response(); $Controller = new Controller($Request, $Response); $data = array('no' => 'nope', 'user' => 'fake', 'list' => array('item1', 'item2')); $Controller->set($data); @@ -73,10 +75,10 @@ public function testRenderWithoutViewMultiple() { */ public function testRenderWithView() { App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) + 'View' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS) )); - $Request = new CakeRequest(); - $Response = new CakeResponse(); + $Request = new Request(); + $Response = new Response(); $Controller = new Controller($Request, $Response); $Controller->name = $Controller->viewPath = 'Posts'; diff --git a/lib/Cake/Test/TestCase/View/MediaViewTest.php b/lib/Cake/Test/TestCase/View/MediaViewTest.php index 3b723c0bfea..89fa6138415 100644 --- a/lib/Cake/Test/TestCase/View/MediaViewTest.php +++ b/lib/Cake/Test/TestCase/View/MediaViewTest.php @@ -16,17 +16,17 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ - -App::uses('Controller', 'Controller'); -App::uses('MediaView', 'View'); -App::uses('CakeResponse', 'Network'); +namespace Cake\Test\TestCase\View; +use Cake\TestSuite\TestCase, + Cake\View\MediaView, + Cake\Controller\Controller; /** * MediaViewTest class * * @package Cake.Test.Case.View */ -class MediaViewTest extends CakeTestCase { +class MediaViewTest extends TestCase { /** * setUp method @@ -35,8 +35,8 @@ class MediaViewTest extends CakeTestCase { */ public function setUp() { parent::setUp(); - $this->MediaView = $this->getMock('MediaView', array('_isActive', '_clearBuffer', '_flushBuffer')); - $this->MediaView->response = $this->getMock('CakeResponse'); + $this->MediaView = $this->getMock('Cake\View\MediaView', array('_isActive', '_clearBuffer', '_flushBuffer')); + $this->MediaView->response = $this->getMock('Cake\Network\Response'); } /** @@ -52,7 +52,7 @@ public function tearDown() { /** * tests that rendering a file that does not exists throws an exception * - * @expectedException NotFoundException + * @expectedException Cake\Error\NotFoundException * @return void */ public function testRenderNotFound() { @@ -70,7 +70,7 @@ public function testRenderNotFound() { */ public function testRender() { $this->MediaView->viewVars = array( - 'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS, + 'path' => CAKE . 'Test' . DS . 'TestApp' . DS . 'Vendor' . DS . 'css' . DS, 'id' => 'test_asset.css', 'extension' => 'css', ); @@ -117,7 +117,7 @@ public function testRenderWithUnknownFileTypeGeneric() { $currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; $_SERVER['HTTP_USER_AGENT'] = 'Some generic browser'; $this->MediaView->viewVars = array( - 'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS, + 'path' => CAKE . 'Test' . DS . 'TestApp' . DS . 'Config' . DS, 'id' => 'no_section.ini', 'extension' => 'ini', ); @@ -176,7 +176,7 @@ public function testRenderWithUnknownFileTypeOpera() { $currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; $_SERVER['HTTP_USER_AGENT'] = 'Opera/9.80 (Windows NT 6.0; U; en) Presto/2.8.99 Version/11.10'; $this->MediaView->viewVars = array( - 'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS, + 'path' => CAKE . 'Test' . DS . 'TestApp' . DS . 'Config' . DS, 'id' => 'no_section.ini', 'extension' => 'ini', ); @@ -240,7 +240,7 @@ public function testRenderWithUnknownFileTypeIE() { $currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; Media Center PC 4.0; SLCC1; .NET CLR 3.0.04320)'; $this->MediaView->viewVars = array( - 'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS, + 'path' => CAKE . 'Test' . DS . 'TestApp' . DS . 'Config' . DS, 'id' => 'no_section.ini', 'extension' => 'ini', 'name' => 'config' @@ -303,7 +303,7 @@ public function testRenderWithUnknownFileTypeIE() { */ public function testConnectionAborted() { $this->MediaView->viewVars = array( - 'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS, + 'path' => CAKE . 'Test' . DS . 'TestApp' . DS . 'Vendor' . DS . 'css' . DS, 'id' => 'test_asset.css', 'extension' => 'css', ); @@ -326,7 +326,7 @@ public function testConnectionAborted() { */ public function testConnectionAbortedOnBuffering() { $this->MediaView->viewVars = array( - 'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS, + 'path' => CAKE . 'Test' . DS . 'TestApp' . DS . 'Vendor' . DS . 'css' . DS, 'id' => 'test_asset.css', 'extension' => 'css', ); @@ -359,7 +359,7 @@ public function testConnectionAbortedOnBuffering() { */ public function testRenderUpperExtension() { $this->MediaView->viewVars = array( - 'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'img' . DS, + 'path' => CAKE . 'Test' . DS . 'TestApp' . DS . 'Vendor' . DS . 'img' . DS, 'id' => 'test_2.JPG', 'extension' => 'JPG', ); @@ -383,7 +383,7 @@ public function testRenderUpperExtension() { */ public function testRenderExtensionNotSet() { $this->MediaView->viewVars = array( - 'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'img' . DS, + 'path' => CAKE . 'Test' . DS . 'TestApp' . DS . 'Vendor' . DS . 'img' . DS, 'id' => 'test_2.JPG', ); diff --git a/lib/Cake/Test/TestCase/View/ScaffoldViewTest.php b/lib/Cake/Test/TestCase/View/ScaffoldViewTest.php index a5f2d85c093..0e0ec7e4dab 100644 --- a/lib/Cake/Test/TestCase/View/ScaffoldViewTest.php +++ b/lib/Cake/Test/TestCase/View/ScaffoldViewTest.php @@ -16,12 +16,19 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('Controller', 'Controller'); -App::uses('Scaffold', 'Controller'); -App::uses('ScaffoldView', 'View'); -App::uses('AppModel', 'Model'); +namespace Cake\Test\TestCase\View; +use Cake\TestSuite\TestCase, + Cake\View\ScaffoldView, + Cake\Controller\Controller, + Cake\Controller\Scaffold, + Cake\Network\Request, + Cake\Routing\Router, + Cake\Core\App, + Cake\Core\Configure, + Cake\Core\Plugin; require_once dirname(dirname(__FILE__)) . DS . 'Model' . DS . 'models.php'; +class_alias('Cake\Test\TestCase\Model\ScaffoldMock', 'Cake\Model\ScaffoldMock'); /** * TestScaffoldView class @@ -69,7 +76,7 @@ class ScaffoldViewMockController extends Controller { * * @package Cake.Test.Case.Controller */ -class ScaffoldViewTest extends CakeTestCase { +class ScaffoldViewTest extends TestCase { /** * fixtures property @@ -85,15 +92,15 @@ class ScaffoldViewTest extends CakeTestCase { */ public function setUp() { parent::setUp(); - $this->request = new CakeRequest(null, false); + $this->request = new Request(null, false); $this->Controller = new ScaffoldViewMockController($this->request); - $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader')); + $this->Controller->response = $this->getMock('Cake\Network\Response', array('_sendHeader')); App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS), - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) + 'View' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS), + 'Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS) )); - CakePlugin::load('TestPlugin'); + Plugin::load('TestPlugin'); } /** @@ -160,11 +167,11 @@ public function testGetViewFilename() { $ScaffoldView = new TestScaffoldView($Controller); $result = $ScaffoldView->testGetFilename('admin_edit'); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Posts' . DS . 'scaffold.form.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Posts' . DS . 'scaffold.form.ctp'; $this->assertEquals($expected, $result); $result = $ScaffoldView->testGetFilename('edit'); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Posts' . DS . 'scaffold.form.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Posts' . DS . 'scaffold.form.ctp'; $this->assertEquals($expected, $result); $Controller = new ScaffoldViewMockController($this->request); @@ -179,12 +186,12 @@ public function testGetViewFilename() { $ScaffoldView = new TestScaffoldView($Controller); $result = $ScaffoldView->testGetFilename('admin_add'); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Tests' . DS . 'scaffold.form.ctp'; $this->assertEquals($expected, $result); $result = $ScaffoldView->testGetFilename('add'); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Tests' . DS . 'scaffold.form.ctp'; $this->assertEquals($expected, $result); @@ -203,7 +210,7 @@ public function testGetViewFileNameWithTheme() { $ScaffoldView = new TestScaffoldView($this->Controller); $result = $ScaffoldView->testGetFilename('index'); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS . 'scaffold.index.ctp'; $this->assertEquals($expected, $result); } diff --git a/lib/Cake/Test/TestCase/View/ThemeViewTest.php b/lib/Cake/Test/TestCase/View/ThemeViewTest.php index ec7838382b5..c1b5c710f95 100644 --- a/lib/Cake/Test/TestCase/View/ThemeViewTest.php +++ b/lib/Cake/Test/TestCase/View/ThemeViewTest.php @@ -16,10 +16,13 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('View', 'View'); -App::uses('ThemeView', 'View'); -App::uses('Controller', 'Controller'); - +namespace Cake\Test\TestCase\View; +use Cake\TestSuite\TestCase, + Cake\View\ThemeView, + Cake\Controller\Controller, + Cake\Network\Request, + Cake\Core\App, + Cake\Core\Plugin; /** * ThemePosts2Controller class @@ -97,7 +100,7 @@ public function getLayoutFileName($name = null) { * * @package Cake.Test.Case.View */ -class ThemeViewTest extends CakeTestCase { +class ThemeViewTest extends TestCase { /** * setUp method @@ -106,18 +109,18 @@ class ThemeViewTest extends CakeTestCase { */ public function setUp() { parent::setUp(); - $request = new CakeRequest('posts/index'); + $request = new Request('posts/index'); $this->Controller = new Controller($request); $this->PostsController = new ThemePosts2Controller($request); $this->PostsController->viewPath = 'posts'; $this->PostsController->index(); $this->ThemeView = new ThemeView($this->PostsController); App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) + 'Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS), + 'View' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS) )); App::objects('plugins', null, false); - CakePlugin::load(array('TestPlugin')); + Plugin::load(array('TestPlugin')); } /** @@ -130,7 +133,7 @@ public function tearDown() { unset($this->ThemeView); unset($this->PostsController); unset($this->Controller); - CakePlugin::unload(); + Plugin::unload(); } /** @@ -146,15 +149,15 @@ public function testPluginThemedGetTemplate() { $this->Controller->theme = 'TestTheme'; $ThemeView = new TestTheme2View($this->Controller); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Tests' . DS . 'index.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Tests' . DS . 'index.ctp'; $result = $ThemeView->getViewFileName('index'); $this->assertEquals($expected, $result); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Layouts' . DS . 'plugin_default.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Layouts' . DS . 'plugin_default.ctp'; $result = $ThemeView->getLayoutFileName('plugin_default'); $this->assertEquals($expected, $result); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS . 'default.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS . 'default.ctp'; $result = $ThemeView->getLayoutFileName('default'); $this->assertEquals($expected, $result); } @@ -173,25 +176,25 @@ public function testGetTemplate() { $ThemeView = new TestTheme2View($this->Controller); $ThemeView->theme = 'TestTheme'; - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages' . DS . 'home.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS .'Pages' . DS . 'home.ctp'; $result = $ThemeView->getViewFileName('home'); $this->assertEquals($expected, $result); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS . 'index.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS . 'index.ctp'; $result = $ThemeView->getViewFileName('/Posts/index'); $this->assertEquals($expected, $result); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS . 'default.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS . 'default.ctp'; $result = $ThemeView->getLayoutFileName(); $this->assertEquals($expected, $result); $ThemeView->layoutPath = 'rss'; - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Layouts' . DS . 'rss' . DS . 'default.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Layouts' . DS . 'rss' . DS . 'default.ctp'; $result = $ThemeView->getLayoutFileName(); $this->assertEquals($expected, $result); $ThemeView->layoutPath = 'Emails' . DS . 'html'; - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Layouts' . DS . 'Emails' . DS . 'html' . DS . 'default.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Layouts' . DS . 'Emails' . DS . 'html' . DS . 'default.ctp'; $result = $ThemeView->getLayoutFileName(); $this->assertEquals($expected, $result); } @@ -199,7 +202,7 @@ public function testGetTemplate() { /** * testMissingView method * - * @expectedException MissingViewException + * @expectedException Cake\Error\MissingViewException * @return void */ public function testMissingView() { @@ -222,7 +225,7 @@ public function testMissingView() { /** * testMissingLayout method * - * @expectedException MissingLayoutException + * @expectedException Cake\Error\MissingLayoutException * @return void */ public function testMissingLayout() { diff --git a/lib/Cake/Test/TestCase/View/ViewTest.php b/lib/Cake/Test/TestCase/View/ViewTest.php index 33c0ceb9011..6ca62865c90 100644 --- a/lib/Cake/Test/TestCase/View/ViewTest.php +++ b/lib/Cake/Test/TestCase/View/ViewTest.php @@ -16,13 +16,18 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +namespace Cake\Test\TestCase\View; -App::uses('View', 'View'); -App::uses('Helper', 'View'); -App::uses('Controller', 'Controller'); -App::uses('CacheHelper', 'View/Helper'); -App::uses('ErrorHandler', 'Error'); - +use Cake\TestSuite\TestCase, + Cake\View\View, + Cake\View\Helper, + Cake\Controller\Controller, + Cake\Cache\Cache, + Cake\Core\App, + Cake\Core\Configure, + Cake\Core\Plugin, + Cake\Network\Request, + Cake\Utility\ClassRegistry; /** * ViewPostsController class @@ -229,7 +234,7 @@ public function afterLayout($layoutFile) { * * @package Cake.Test.Case.View */ -class ViewTest extends CakeTestCase { +class ViewTest extends TestCase { /** * Fixtures used in this test. @@ -246,14 +251,14 @@ class ViewTest extends CakeTestCase { public function setUp() { parent::setUp(); - $request = $this->getMock('CakeRequest'); + $request = $this->getMock('Cake\Network\Request'); $this->Controller = new Controller($request); $this->PostsController = new ViewPostsController($request); $this->PostsController->viewPath = 'Posts'; $this->PostsController->index(); $this->View = new View($this->PostsController); - $themeRequest = new CakeRequest('posts/index'); + $themeRequest = new Request('posts/index'); $this->ThemeController = new Controller($themeRequest); $this->ThemePostsController = new ThemePostsController($themeRequest); $this->ThemePostsController->viewPath = 'posts'; @@ -261,12 +266,12 @@ public function setUp() { $this->ThemeView = new View($this->ThemePostsController); App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) + 'Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS), + 'View' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS) ), App::RESET); App::objects('plugins', null, false); - CakePlugin::load(array('TestPlugin', 'TestPlugin', 'PluginJs')); + Plugin::load(array('TestPlugin', 'TestPlugin', 'PluginJs')); Configure::write('debug', 2); } @@ -277,7 +282,7 @@ public function setUp() { */ public function tearDown() { parent::tearDown(); - CakePlugin::unload(); + Plugin::unload(); unset($this->View); unset($this->PostsController); unset($this->Controller); @@ -300,25 +305,25 @@ public function testGetTemplate() { $ThemeView = new TestThemeView($this->Controller); $ThemeView->theme = 'TestTheme'; - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages' . DS . 'home.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS .'Pages' . DS . 'home.ctp'; $result = $ThemeView->getViewFileName('home'); $this->assertEquals($expected, $result); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS . 'index.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS . 'index.ctp'; $result = $ThemeView->getViewFileName('/Posts/index'); $this->assertEquals($expected, $result); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS . 'default.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS . 'default.ctp'; $result = $ThemeView->getLayoutFileName(); $this->assertEquals($expected, $result); $ThemeView->layoutPath = 'rss'; - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Layouts' . DS . 'rss' . DS . 'default.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Layouts' . DS . 'rss' . DS . 'default.ctp'; $result = $ThemeView->getLayoutFileName(); $this->assertEquals($expected, $result); $ThemeView->layoutPath = 'Emails' . DS . 'html'; - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Layouts' . DS . 'Emails' . DS . 'html' . DS . 'default.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Layouts' . DS . 'Emails' . DS . 'html' . DS . 'default.ctp'; $result = $ThemeView->getLayoutFileName(); $this->assertEquals($expected, $result); } @@ -336,11 +341,11 @@ public function testPluginGetTemplate() { $View = new TestView($this->Controller); - $expected = CakePlugin::path('TestPlugin') . 'View' . DS . 'Tests' . DS . 'index.ctp'; + $expected = Plugin::path('TestPlugin') . 'View' . DS .'Tests' . DS . 'index.ctp'; $result = $View->getViewFileName('index'); $this->assertEquals($expected, $result); - $expected = CakePlugin::path('TestPlugin') . 'View' . DS . 'Layouts' . DS . 'default.ctp'; + $expected = Plugin::path('TestPlugin') . 'View' . DS . 'Layouts' . DS . 'default.ctp'; $result = $View->getLayoutFileName(); $this->assertEquals($expected, $result); } @@ -358,15 +363,15 @@ public function testPluginThemedGetTemplate() { $this->Controller->theme = 'TestTheme'; $ThemeView = new TestThemeView($this->Controller); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Tests' . DS . 'index.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Tests' . DS . 'index.ctp'; $result = $ThemeView->getViewFileName('index'); $this->assertEquals($expected, $result); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Layouts' . DS . 'plugin_default.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Layouts' . DS . 'plugin_default.ctp'; $result = $ThemeView->getLayoutFileName('plugin_default'); $this->assertEquals($expected, $result); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS . 'default.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS . 'default.ctp'; $result = $ThemeView->getLayoutFileName('default'); $this->assertEquals($expected, $result); } @@ -388,11 +393,11 @@ public function testPluginPathGeneration() { $this->assertEquals($expected, $paths); $paths = $View->paths('TestPlugin'); - $pluginPath = CakePlugin::path('TestPlugin'); + $pluginPath = Plugin::path('TestPlugin'); $expected = array( - CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Plugin' . DS . 'TestPlugin' . DS, + CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Plugin' . DS . 'TestPlugin' . DS, $pluginPath . 'View' . DS, - CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS, + CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS, CAKE . 'View' . DS, CAKE . 'Console' . DS . 'Templates' . DS . 'skel' . DS . 'View' . DS ); @@ -412,12 +417,12 @@ public function testCamelCasePluginGetTemplate() { $View = new TestView($this->Controller); App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) + 'Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS), + 'View' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS) )); - $pluginPath = CakePlugin::path('TestPlugin'); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Tests' . DS . 'index.ctp'; + $pluginPath = Plugin::path('TestPlugin'); + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS .'TestPlugin' . DS . 'View' . DS .'Tests' . DS . 'index.ctp'; $result = $View->getViewFileName('index'); $this->assertEquals($expected, $result); @@ -440,29 +445,29 @@ public function testGetViewFileNames() { $View = new TestView($this->Controller); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages' . DS . 'home.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS .'Pages' . DS . 'home.ctp'; $result = $View->getViewFileName('home'); $this->assertEquals($expected, $result); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Posts' . DS . 'index.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS .'Posts' . DS . 'index.ctp'; $result = $View->getViewFileName('/Posts/index'); $this->assertEquals($expected, $result); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Posts' . DS . 'index.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS .'Posts' . DS . 'index.ctp'; $result = $View->getViewFileName('../Posts/index'); $this->assertEquals($expected, $result); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages' . DS . 'page.home.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS .'Pages' . DS . 'page.home.ctp'; $result = $View->getViewFileName('page.home'); $this->assertEquals($expected, $result, 'Should not ruin files with dots.'); - CakePlugin::load('TestPlugin'); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages' . DS . 'home.ctp'; + Plugin::load('TestPlugin'); + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS .'Pages' . DS . 'home.ctp'; $result = $View->getViewFileName('TestPlugin.home'); $this->assertEquals($expected, $result, 'Plugin is missing the view, cascade to app.'); $View->viewPath = 'Tests'; - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Tests' . DS . 'index.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Tests' . DS . 'index.ctp'; $result = $View->getViewFileName('TestPlugin.index'); $this->assertEquals($expected, $result); } @@ -480,17 +485,17 @@ public function testGetLayoutFileName() { $View = new TestView($this->Controller); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Layouts' . DS . 'default.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Layouts' . DS . 'default.ctp'; $result = $View->getLayoutFileName(); $this->assertEquals($expected, $result); $View->layoutPath = 'rss'; - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Layouts' . DS . 'rss' . DS . 'default.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Layouts' . DS . 'rss' . DS . 'default.ctp'; $result = $View->getLayoutFileName(); $this->assertEquals($expected, $result); $View->layoutPath = 'Emails' . DS . 'html'; - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Layouts' . DS . 'Emails' . DS . 'html' . DS . 'default.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS . 'Layouts' . DS . 'Emails' . DS . 'html' . DS . 'default.ctp'; $result = $View->getLayoutFileName(); $this->assertEquals($expected, $result); } @@ -507,14 +512,14 @@ public function testGetLayoutFileNamePlugin() { $this->Controller->action = 'display'; $View = new TestView($this->Controller); - CakePlugin::load('TestPlugin'); + Plugin::load('TestPlugin'); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Layouts' . DS . 'default.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Layouts' . DS . 'default.ctp'; $result = $View->getLayoutFileName('TestPlugin.default'); $this->assertEquals($expected, $result); $View->plugin = 'TestPlugin'; - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Layouts' . DS . 'default.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Layouts' . DS . 'default.ctp'; $result = $View->getLayoutFileName('default'); $this->assertEquals($expected, $result); } @@ -522,7 +527,7 @@ public function testGetLayoutFileNamePlugin() { /** * testMissingView method * - * @expectedException MissingViewException + * @expectedException Cake\Error\MissingViewException * @return void */ public function testMissingView() { @@ -555,7 +560,7 @@ public function testMissingView() { /** * testMissingLayout method * - * @expectedException MissingLayoutException + * @expectedException Cake\Error\MissingLayoutException * @return void */ public function testMissingLayout() { @@ -661,8 +666,10 @@ public function testElement() { * */ public function testElementCallbacks() { - $this->getMock('HtmlHelper', array(), array($this->View), 'ElementCallbackMockHtmlHelper'); - $this->View->helpers = array('ElementCallbackMockHtml'); + $this->getMock('Cake\View\Helper\HtmlHelper', array(), array($this->View), 'ElementCallbackMockHtmlHelper'); + $this->View->helpers = array( + 'ElementCallbackMockHtml' => array('className' => '\ElementCallbackMockHtmlHelper') + ); $this->View->loadHelpers(); $this->View->ElementCallbackMockHtml->expects($this->at(0))->method('beforeRender'); @@ -765,7 +772,7 @@ public function testElementCache() { public function testMagicGet() { $View = new View($this->PostsController); $View->loadHelper('Html'); - $this->assertInstanceOf('HtmlHelper', $View->Html); + $this->assertInstanceOf('Cake\View\Helper\HtmlHelper', $View->Html); } /** @@ -794,8 +801,8 @@ public function testLoadHelpers() { $View->helpers = array('Html', 'Form'); $View->loadHelpers(); - $this->assertInstanceOf('HtmlHelper', $View->Html, 'Object type is wrong.'); - $this->assertInstanceOf('FormHelper', $View->Form, 'Object type is wrong.'); + $this->assertInstanceOf('Cake\View\Helper\HtmlHelper', $View->Html, 'Object type is wrong.'); + $this->assertInstanceOf('Cake\View\Helper\FormHelper', $View->Form, 'Object type is wrong.'); } /** @@ -807,8 +814,8 @@ public function testLazyLoadHelpers() { $View = new View($this->PostsController); $View->helpers = array(); - $this->assertInstanceOf('HtmlHelper', $View->Html, 'Object type is wrong.'); - $this->assertInstanceOf('FormHelper', $View->Form, 'Object type is wrong.'); + $this->assertInstanceOf('Cake\View\Helper\HtmlHelper', $View->Html, 'Object type is wrong.'); + $this->assertInstanceOf('Cake\View\Helper\FormHelper', $View->Form, 'Object type is wrong.'); } /** @@ -819,12 +826,12 @@ public function testLazyLoadHelpers() { public function testHelperCallbackTriggering() { $View = new View($this->PostsController); $View->helpers = array(); - $View->Helpers = $this->getMock('HelperCollection', array('trigger'), array($View)); + $View->Helpers = $this->getMock('Cake\View\HelperCollection', array('trigger'), array($View)); $View->Helpers->expects($this->at(0))->method('trigger') ->with( $this->logicalAnd( - $this->isInstanceOf('CakeEvent'), + $this->isInstanceOf('Cake\Event\Event'), $this->attributeEqualTo('_name', 'View.beforeRender'), $this->attributeEqualTo('_subject', $View) ) @@ -832,7 +839,7 @@ public function testHelperCallbackTriggering() { $View->Helpers->expects($this->at(1))->method('trigger') ->with( $this->logicalAnd( - $this->isInstanceOf('CakeEvent'), + $this->isInstanceOf('Cake\Event\Event'), $this->attributeEqualTo('_name', 'View.beforeRenderFile'), $this->attributeEqualTo('_subject', $View) ) @@ -841,7 +848,7 @@ public function testHelperCallbackTriggering() { $View->Helpers->expects($this->at(2))->method('trigger') ->with( $this->logicalAnd( - $this->isInstanceOf('CakeEvent'), + $this->isInstanceOf('Cake\Event\Event'), $this->attributeEqualTo('_name', 'View.afterRenderFile'), $this->attributeEqualTo('_subject', $View) ) @@ -849,7 +856,7 @@ public function testHelperCallbackTriggering() { $View->Helpers->expects($this->at(3))->method('trigger') ->with( $this->logicalAnd( - $this->isInstanceOf('CakeEvent'), + $this->isInstanceOf('Cake\Event\Event'), $this->attributeEqualTo('_name', 'View.afterRender'), $this->attributeEqualTo('_subject', $View) ) @@ -858,7 +865,7 @@ public function testHelperCallbackTriggering() { $View->Helpers->expects($this->at(4))->method('trigger') ->with( $this->logicalAnd( - $this->isInstanceOf('CakeEvent'), + $this->isInstanceOf('Cake\Event\Event'), $this->attributeEqualTo('_name', 'View.beforeLayout'), $this->attributeEqualTo('_subject', $View) ) @@ -867,7 +874,7 @@ public function testHelperCallbackTriggering() { $View->Helpers->expects($this->at(5))->method('trigger') ->with( $this->logicalAnd( - $this->isInstanceOf('CakeEvent'), + $this->isInstanceOf('Cake\Event\Event'), $this->attributeEqualTo('_name', 'View.beforeRenderFile'), $this->attributeEqualTo('_subject', $View) ) @@ -876,7 +883,7 @@ public function testHelperCallbackTriggering() { $View->Helpers->expects($this->at(6))->method('trigger') ->with( $this->logicalAnd( - $this->isInstanceOf('CakeEvent'), + $this->isInstanceOf('Cake\Event\Event'), $this->attributeEqualTo('_name', 'View.afterRenderFile'), $this->attributeEqualTo('_subject', $View) ) @@ -885,7 +892,7 @@ public function testHelperCallbackTriggering() { $View->Helpers->expects($this->at(7))->method('trigger') ->with( $this->logicalAnd( - $this->isInstanceOf('CakeEvent'), + $this->isInstanceOf('Cake\Event\Event'), $this->attributeEqualTo('_name', 'View.afterLayout'), $this->attributeEqualTo('_subject', $View) ) @@ -900,7 +907,11 @@ public function testHelperCallbackTriggering() { * @return void */ public function testBeforeLayout() { - $this->PostsController->helpers = array('Session', 'TestAfter', 'Html'); + $this->PostsController->helpers = array( + 'Session', + 'TestAfter' => array('className' => __NAMESPACE__ . '\TestAfterHelper'), + 'Html' + ); $View = new View($this->PostsController); $View->render('index'); $this->assertEquals('Valuation', $View->Helpers->TestAfter->property); @@ -912,7 +923,11 @@ public function testBeforeLayout() { * @return void */ public function testAfterLayout() { - $this->PostsController->helpers = array('Session', 'TestAfter', 'Html'); + $this->PostsController->helpers = array( + 'Session', + 'TestAfter' => array('className' => __NAMESPACE__ . '\TestAfterHelper'), + 'Html' + ); $this->PostsController->set('variable', 'values'); $View = new View($this->PostsController); @@ -1019,7 +1034,7 @@ public function testGetViewFileNameSubdirWithPluginAndViewPath() { $this->PostsController->name = 'Posts'; $View = new TestView($this->PostsController); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Elements' . DS . 'sub_dir' . DS . 'sub_element.ctp'; $this->assertEquals($expected, $View->getViewFileName('sub_dir/sub_element')); } @@ -1064,7 +1079,7 @@ public function testViewFileName() { $result = $View->getViewFileName('../Themed/TestTheme/Posts/index'); $this->assertRegExp('/Themed(\/|\\\)TestTheme(\/|\\\)Posts(\/|\\\)index.ctp/', $result); - $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Posts' . DS . 'index.ctp'; + $expected = CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS .'Posts' . DS . 'index.ctp'; $result = $View->getViewFileName('../Posts/index'); $this->assertEquals($expected, $result); } @@ -1167,7 +1182,7 @@ public function testSet() { /** * testBadExt method * - * @expectedException MissingViewException + * @expectedException Cake\Error\MissingViewException * @return void */ public function testBadExt() { @@ -1193,7 +1208,7 @@ public function testAltExt() { /** * testAltBadExt method * - * @expectedException MissingViewException + * @expectedException Cake\Error\MissingViewException * @return void */ public function testAltBadExt() { @@ -1271,7 +1286,7 @@ public function testBlockAppendUndefined() { /** * setting an array should cause an exception. * - * @expectedException CakeException + * @expectedException Cake\Error\Exception * @return void */ public function testBlockSetArrayException() { @@ -1281,7 +1296,7 @@ public function testBlockSetArrayException() { /** * Appending an array should cause an exception. * - * @expectedException CakeException + * @expectedException Cake\Error\Exception * @return void */ public function testBlockAppendArrayException() { @@ -1322,7 +1337,7 @@ public function testNestedBlocks() { * Test that an exception gets thrown when you leave a block open at the end * of a view. * - * @expectedException CakeException + * @expectedException Cake\Error\Exception * @return void */ public function testExceptionOnOpenBlock() { diff --git a/lib/Cake/Test/TestCase/View/XmlViewTest.php b/lib/Cake/Test/TestCase/View/XmlViewTest.php index 9cf3b9ae0d1..0e185f44661 100644 --- a/lib/Cake/Test/TestCase/View/XmlViewTest.php +++ b/lib/Cake/Test/TestCase/View/XmlViewTest.php @@ -16,18 +16,21 @@ * @since CakePHP(tm) v 2.1.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ - -App::uses('Controller', 'Controller'); -App::uses('CakeRequest', 'Network'); -App::uses('CakeResponse', 'Network'); -App::uses('XmlView', 'View'); +namespace Cake\Test\TestCase\View; +use Cake\TestSuite\TestCase, + Cake\View\XmlView, + Cake\Network\Request, + Cake\Network\Response, + Cake\Controller\Controller, + Cake\Core\App, + Cake\Utility\Xml; /** * XmlViewTest * * @package Cake.Test.Case.View */ -class XmlViewTest extends CakeTestCase { +class XmlViewTest extends TestCase { /** * testRenderWithoutView method @@ -35,8 +38,8 @@ class XmlViewTest extends CakeTestCase { * @return void */ public function testRenderWithoutView() { - $Request = new CakeRequest(); - $Response = new CakeResponse(); + $Request = new Request(); + $Response = new Response(); $Controller = new Controller($Request, $Response); $data = array('users' => array('user' => array('user1', 'user2'))); $Controller->set(array('users' => $data, '_serialize' => 'users')); @@ -54,8 +57,8 @@ public function testRenderWithoutView() { * @return void */ public function testRenderWithoutViewMultiple() { - $Request = new CakeRequest(); - $Response = new CakeResponse(); + $Request = new Request(); + $Response = new Response(); $Controller = new Controller($Request, $Response); $data = array('no' => 'nope', 'user' => 'fake', 'list' => array('item1', 'item2')); $Controller->set($data); @@ -77,10 +80,10 @@ public function testRenderWithoutViewMultiple() { */ public function testRenderWithView() { App::build(array('View' => array( - CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS + CAKE . 'Test' . DS . 'TestApp' . DS . 'View' . DS ))); - $Request = new CakeRequest(); - $Response = new CakeResponse(); + $Request = new Request(); + $Response = new Response(); $Controller = new Controller($Request, $Response); $Controller->name = $Controller->viewPath = 'Posts'; @@ -103,7 +106,7 @@ public function testRenderWithView() { $expected = 'user1user2'; $this->assertSame($expected, str_replace(array("\r", "\n"), '', $output)); $this->assertSame('application/xml', $Response->type()); - $this->assertInstanceOf('HelperCollection', $View->Helpers); + $this->assertInstanceOf('Cake\View\HelperCollection', $View->Helpers); } }