From fe34a8551cf09a9523bc22b807c6d800ac13f1aa Mon Sep 17 00:00:00 2001 From: Koji Tanaka Date: Sat, 31 Dec 2022 09:48:04 +0900 Subject: [PATCH] test: Replace deprecated @expectedException PHPUnit_Framework_Error --- .../Component/Auth/ControllerAuthorizeTest.php | 6 +++--- lib/Cake/Test/Case/Core/ConfigureTest.php | 6 +++--- .../Model/Behavior/ContainableBehaviorTest.php | 4 ++-- .../Case/Model/Datasource/Database/MysqlTest.php | 8 ++++---- lib/Cake/Test/Case/Model/ModelValidationTest.php | 8 ++++---- lib/Cake/Test/Case/Utility/SecurityTest.php | 14 +++++++------- lib/Cake/Test/Case/Utility/ValidationTest.php | 4 ++-- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php index 00766713b..7523b6436 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php @@ -47,16 +47,16 @@ class ControllerAuthorizeTest extends CakeTestCase { /** * testControllerTypeError * - * @expectedException PHPUnit_Framework_Error * @return void - * @throws PHPUnit_Framework_Error + * @throws \PHPUnit\Framework\Error */ public function testControllerTypeError() { + $this->expectException(\PHPUnit\Framework\Error::class); try { $this->auth->controller(new StdClass()); $this->fail('No exception thrown'); } catch (TypeError $e) { - throw new PHPUnit_Framework_Error('Raised an error', 100, __FILE__, __LINE__); + throw new \PHPUnit\Framework\Error('Raised an error', 100); } } diff --git a/lib/Cake/Test/Case/Core/ConfigureTest.php b/lib/Cake/Test/Case/Core/ConfigureTest.php index cf769a02a..b11f32f14 100644 --- a/lib/Cake/Test/Case/Core/ConfigureTest.php +++ b/lib/Cake/Test/Case/Core/ConfigureTest.php @@ -456,17 +456,17 @@ class ConfigureTest extends CakeTestCase { /** * test reader() throwing exceptions on missing interface. * - * @expectedException PHPUnit_Framework_Error * @return void - * @throws PHPUnit_Framework_Error + * @throws \PHPUnit\Framework\Error */ public function testReaderExceptionOnIncorrectClass() { + $this->expectException(\PHPUnit\Framework\Error::class); $reader = new StdClass(); try { Configure::config('test', $reader); } catch (TypeError $e) { - throw new PHPUnit_Framework_Error('Raised an error', 100, __FILE__, __LINE__); + throw new \PHPUnit\Framework\Error('Raised an error', 100); } } diff --git a/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php index 48a8731ae..9c5e639ee 100644 --- a/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php @@ -150,10 +150,10 @@ class ContainableBehaviorTest extends CakeTestCase { /** * testInvalidContainments method * - * @expectedException PHPUnit_Framework_Error * @return void */ public function testInvalidContainments() { + $this->expectWarning(); $this->_containments($this->Article, array('Comment', 'InvalidBinding')); } @@ -241,10 +241,10 @@ class ContainableBehaviorTest extends CakeTestCase { /** * testBeforeFindWithNonExistingBinding method * - * @expectedException PHPUnit_Framework_Error * @return void */ public function testBeforeFindWithNonExistingBinding() { + $this->expectWarning(); $this->Article->find('all', array('contain' => array('Comment' => 'NonExistingBinding'))); } diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index 67e8ba929..d7afb7132 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -2883,16 +2883,16 @@ SQL; /** * testDropSchemaNoSchema method * - * @expectedException PHPUnit_Framework_Error * @return void - * @throws PHPUnit_Framework_Error + * @throws \PHPUnit\Framework\Error */ public function testDropSchemaNoSchema() { + $this->expectException(\PHPUnit\Framework\Error::class); try { $this->Dbo->dropSchema(null); $this->fail('No exception'); } catch (TypeError $e) { - throw new PHPUnit_Framework_Error('Raised an error', 100, __FILE__, __LINE__); + throw new \PHPUnit\Framework\Error('Raised an error', 100); } } @@ -3232,10 +3232,10 @@ SQL; /** * testBuildColumnBadType method * - * @expectedException PHPUnit_Framework_Error * @return void */ public function testBuildColumnBadType() { + $this->expectWarning(); $data = array( 'name' => 'testName', 'type' => 'varchar(255)', diff --git a/lib/Cake/Test/Case/Model/ModelValidationTest.php b/lib/Cake/Test/Case/Model/ModelValidationTest.php index 51d1f3431..673d2dddf 100644 --- a/lib/Cake/Test/Case/Model/ModelValidationTest.php +++ b/lib/Cake/Test/Case/Model/ModelValidationTest.php @@ -772,10 +772,10 @@ class ModelValidationTest extends BaseModelTest { * Test that missing validation methods trigger errors in development mode. * Helps to make development easier. * - * @expectedException PHPUnit_Framework_Error * @return void */ public function testMissingValidationErrorTriggering() { + $this->expectWarning(); Configure::write('debug', 2); $TestModel = new ValidationTest1(); @@ -2226,16 +2226,16 @@ class ModelValidationTest extends BaseModelTest { /** * Test that type hint exception is thrown * - * @expectedException PHPUnit_Framework_Error * @return void - * @throws PHPUnit_Framework_Error + * @throws \PHPUnit\Framework\Error */ public function testValidatorTypehintException() { + $this->expectException(\PHPUnit\Framework\Error::class); try { new ModelValidator('asdasds'); $this->fail('No exeption raised'); } catch (TypeError $e) { - throw new PHPUnit_Framework_Error('Raised an error', 100, __FILE__, __LINE__); + throw new \PHPUnit\Framework\Error('Raised an error', 100); } } diff --git a/lib/Cake/Test/Case/Utility/SecurityTest.php b/lib/Cake/Test/Case/Utility/SecurityTest.php index 13327b48c..ddb38b6d3 100644 --- a/lib/Cake/Test/Case/Utility/SecurityTest.php +++ b/lib/Cake/Test/Case/Utility/SecurityTest.php @@ -87,40 +87,40 @@ class SecurityTest extends CakeTestCase { /** * testHashInvalidSalt method * - * @expectedException PHPUnit_Framework_Error * @return void */ public function testHashInvalidSalt() { + $this->expectWarning(); Security::hash('someKey', 'blowfish', true); } /** * testHashAnotherInvalidSalt * - * @expectedException PHPUnit_Framework_Error * @return void */ public function testHashAnotherInvalidSalt() { + $this->expectWarning(); Security::hash('someKey', 'blowfish', '$1$lksdjoijfaoijs'); } /** * testHashYetAnotherInvalidSalt * - * @expectedException PHPUnit_Framework_Error * @return void */ public function testHashYetAnotherInvalidSalt() { + $this->expectWarning(); Security::hash('someKey', 'blowfish', '$2a$10$123'); } /** * testHashInvalidCost method * - * @expectedException PHPUnit_Framework_Error * @return void */ public function testHashInvalidCost() { + $this->expectWarning(); Security::setCost(1000); } /** @@ -269,10 +269,10 @@ class SecurityTest extends CakeTestCase { /** * testCipherEmptyKey method * - * @expectedException PHPUnit_Framework_Error * @return void */ public function testCipherEmptyKey() { + $this->expectWarning(); $txt = 'some_text'; $key = ''; Security::cipher($txt, $key); @@ -321,10 +321,10 @@ class SecurityTest extends CakeTestCase { /** * testRijndaelInvalidOperation method * - * @expectedException PHPUnit_Framework_Error * @return void */ public function testRijndaelInvalidOperation() { + $this->expectWarning(); $txt = 'The quick brown fox jumped over the lazy dog.'; $key = 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi'; Security::rijndael($txt, $key, 'foo'); @@ -333,10 +333,10 @@ class SecurityTest extends CakeTestCase { /** * testRijndaelInvalidKey method * - * @expectedException PHPUnit_Framework_Error * @return void */ public function testRijndaelInvalidKey() { + $this->expectWarning(); $txt = 'The quick brown fox jumped over the lazy dog.'; $key = 'too small'; Security::rijndael($txt, $key, 'encrypt'); diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index b88a7b994..533512f25 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -2294,20 +2294,20 @@ class ValidationTest extends CakeTestCase { /** * test pass through failure on postal * - * @expectedException PHPUnit_Framework_Error * @return void */ public function testPassThroughMethodFailure() { + $this->expectWarning(); Validation::phone('text', null, 'testNl'); } /** * test the pass through calling of an alternate locale with postal() * - * @expectedException PHPUnit_Framework_Error * @return void */ public function testPassThroughClassFailure() { + $this->expectWarning(); Validation::postal('text', null, 'AUTOFAIL'); }