From c04692f76cdd05fc3319e39be7e2ccd803351bef Mon Sep 17 00:00:00 2001 From: Koji Tanaka Date: Sat, 31 Dec 2022 09:08:28 +0900 Subject: [PATCH] test: Replace deprecated @expectedException* to expectWarning*()/expectNotice*() --- lib/Cake/Test/Case/Cache/CacheTest.php | 2 +- .../Case/Controller/Component/Auth/CrudAuthorizeTest.php | 2 +- lib/Cake/Test/Case/Core/CakePluginTest.php | 2 +- .../Test/Case/Model/Validator/CakeValidationRuleTest.php | 4 ++-- lib/Cake/Test/Case/View/Helper/JsHelperTest.php | 2 +- lib/Cake/Test/Case/View/Helper/MootoolsEngineHelperTest.php | 2 +- lib/Cake/Test/Case/View/ViewTest.php | 6 +++--- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/Cake/Test/Case/Cache/CacheTest.php b/lib/Cake/Test/Case/Cache/CacheTest.php index f5374c218..fed9d846c 100644 --- a/lib/Cake/Test/Case/Cache/CacheTest.php +++ b/lib/Cake/Test/Case/Cache/CacheTest.php @@ -128,10 +128,10 @@ class CacheTest extends CakeTestCase { * * Test that the cache class doesn't cause fatal errors with a partial path * - * @expectedException PHPUnit_Framework_Error_Warning * @return void */ public function testInvalidConfig() { + $this->expectWarning(); // In debug mode it would auto create the folder. $debug = Configure::read('debug'); Configure::write('debug', 0); diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/CrudAuthorizeTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/CrudAuthorizeTest.php index 131f4de19..784909e59 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/CrudAuthorizeTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/CrudAuthorizeTest.php @@ -60,10 +60,10 @@ class CrudAuthorizeTest extends CakeTestCase { /** * test authorize() without a mapped action, ensure an error is generated. * - * @expectedException PHPUnit_Framework_Error_Warning * @return void */ public function testAuthorizeNoMappedAction() { + $this->expectWarning(); $request = new CakeRequest('/posts/foobar', false); $request->addParams(array( 'controller' => 'posts', diff --git a/lib/Cake/Test/Case/Core/CakePluginTest.php b/lib/Cake/Test/Case/Core/CakePluginTest.php index 42e0c31a8..eafd0681e 100644 --- a/lib/Cake/Test/Case/Core/CakePluginTest.php +++ b/lib/Cake/Test/Case/Core/CakePluginTest.php @@ -170,9 +170,9 @@ class CakePluginTest extends CakeTestCase { * Tests that loading a missing routes file throws a warning * * @return void - * @expectedException PHPUNIT_FRAMEWORK_ERROR_WARNING */ public function testLoadMultipleWithDefaultsMissingFile() { + $this->expectWarning(); CakePlugin::load(array('TestPlugin', 'TestPluginTwo'), array('bootstrap' => true, 'routes' => true)); CakePlugin::routes(); } diff --git a/lib/Cake/Test/Case/Model/Validator/CakeValidationRuleTest.php b/lib/Cake/Test/Case/Model/Validator/CakeValidationRuleTest.php index 53cecda16..39c4db388 100644 --- a/lib/Cake/Test/Case/Model/Validator/CakeValidationRuleTest.php +++ b/lib/Cake/Test/Case/Model/Validator/CakeValidationRuleTest.php @@ -101,11 +101,11 @@ class CakeValidationRuleTest extends CakeTestCase { /** * Make sure errors are triggered when validation is missing. * - * @expectedException PHPUnit_Framework_Error_Warning - * @expectedExceptionMessage Could not find validation handler totallyMissing for fieldName * @return void */ public function testCustomMethodMissingError() { + $this->expectWarning(); + $this->expectWarningMessage('Could not find validation handler totallyMissing for fieldName'); $def = array('rule' => array('totallyMissing')); $data = array( 'fieldName' => 'some data' diff --git a/lib/Cake/Test/Case/View/Helper/JsHelperTest.php b/lib/Cake/Test/Case/View/Helper/JsHelperTest.php index 8b0e4745d..bd62b7991 100644 --- a/lib/Cake/Test/Case/View/Helper/JsHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/JsHelperTest.php @@ -206,10 +206,10 @@ class JsHelperTest extends CakeTestCase { /** * test that methods dispatch internally and to the engine class * - * @expectedException PHPUnit_Framework_Error_Warning * @return void */ public function testMethodDispatching() { + $this->expectWarning(); $this->_useMock(); $this->Js->TestJsEngine diff --git a/lib/Cake/Test/Case/View/Helper/MootoolsEngineHelperTest.php b/lib/Cake/Test/Case/View/Helper/MootoolsEngineHelperTest.php index ead1bc379..99cc49fd7 100644 --- a/lib/Cake/Test/Case/View/Helper/MootoolsEngineHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/MootoolsEngineHelperTest.php @@ -274,10 +274,10 @@ class MootoolsEngineHelperTest extends CakeTestCase { /** * test drop() method with the required drag option missing * - * @expectedException PHPUnit_Framework_Error_Warning * @return void */ public function testDropWithMissingOption() { + $this->expectWarning(); $this->Moo->get('#drop-me'); $this->Moo->drop(array( 'drop' => 'onDrop', diff --git a/lib/Cake/Test/Case/View/ViewTest.php b/lib/Cake/Test/Case/View/ViewTest.php index d6a38819e..91dba6bc9 100644 --- a/lib/Cake/Test/Case/View/ViewTest.php +++ b/lib/Cake/Test/Case/View/ViewTest.php @@ -767,30 +767,30 @@ class ViewTest extends CakeTestCase { /** * Test elementInexistent method * - * @expectedException PHPUnit_Framework_Error_Notice * @return void */ public function testElementInexistent() { + $this->expectNotice(); $this->View->element('non_existent_element'); } /** * Test elementInexistent2 method * - * @expectedException PHPUnit_Framework_Error_Notice * @return void */ public function testElementInexistent2() { + $this->expectNotice(); $this->View->element('TestPlugin.plugin_element', array(), array('plugin' => 'test_plugin')); } /** * Test elementInexistent3 method * - * @expectedException PHPUnit_Framework_Error_Notice * @return void */ public function testElementInexistent3() { + $this->expectNotice(); $this->View->element('test_plugin.plugin_element'); }