test: Replace deprecated @expectedException PHPUnit_Framework_Error

This commit is contained in:
Koji Tanaka 2022-12-31 09:48:04 +09:00 committed by Kamil Wylegala
parent c04692f76c
commit fe34a8551c
7 changed files with 25 additions and 25 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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