test: Replace deprecated @expectedException* to expectWarning*()/expectNotice*()

This commit is contained in:
Koji Tanaka 2022-12-31 09:08:28 +09:00 committed by Kamil Wylegala
parent eaefdbb977
commit c04692f76c
7 changed files with 10 additions and 10 deletions

View file

@ -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);

View file

@ -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',

View file

@ -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();
}

View file

@ -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'

View file

@ -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

View file

@ -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',

View file

@ -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');
}