mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix type error tests to work in PHP5 & PHP7.1
Catch the TypeErrors that are raised and make the match the PHP5 behavior of a converted error.
This commit is contained in:
parent
e3221b1c38
commit
0a2a400ea4
4 changed files with 12 additions and 9 deletions
|
@ -47,14 +47,15 @@ class ControllerAuthorizeTest extends CakeTestCase {
|
|||
/**
|
||||
* testControllerTypeError
|
||||
*
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
* @return void
|
||||
*/
|
||||
public function testControllerTypeError() {
|
||||
try {
|
||||
$this->auth->controller(new StdClass());
|
||||
$this->fail('No exception thrown');
|
||||
} catch (Throwable $t) {
|
||||
$this->assertTrue(true, 'Exception was raised');
|
||||
} catch (TypeError $e) {
|
||||
throw new PHPUnit_Framework_Error('Raised an error', 100, __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -449,6 +449,7 @@ class ConfigureTest extends CakeTestCase {
|
|||
/**
|
||||
* test reader() throwing exceptions on missing interface.
|
||||
*
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
* @return void
|
||||
*/
|
||||
public function testReaderExceptionOnIncorrectClass() {
|
||||
|
@ -456,9 +457,8 @@ class ConfigureTest extends CakeTestCase {
|
|||
|
||||
try {
|
||||
Configure::config('test', $reader);
|
||||
$this->fail('No error raised');
|
||||
} catch (Throwable $t) {
|
||||
$this->assertTrue(true, 'TypeError raised');
|
||||
} catch (TypeError $e) {
|
||||
throw new PHPUnit_Framework_Error('Raised an error', 100, __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2908,14 +2908,15 @@ SQL;
|
|||
/**
|
||||
* testDropSchemaNoSchema method
|
||||
*
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
* @return void
|
||||
*/
|
||||
public function testDropSchemaNoSchema() {
|
||||
try {
|
||||
$this->Dbo->dropSchema(null);
|
||||
$this->fail('No exception');
|
||||
} catch (Throwable $t) {
|
||||
$this->assertTrue(true, 'Exception raised');
|
||||
} catch (TypeError $e) {
|
||||
throw new PHPUnit_Framework_Error('Raised an error', 100, __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2223,14 +2223,15 @@ class ModelValidationTest extends BaseModelTest {
|
|||
/**
|
||||
* Test that type hint exception is thrown
|
||||
*
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
* @return void
|
||||
*/
|
||||
public function testValidatorTypehintException() {
|
||||
try {
|
||||
new ModelValidator('asdasds');
|
||||
$this->fail('No exeption raised');
|
||||
} catch (Throwable $t) {
|
||||
$this->assertTrue(true, 'An error/exception was raised');
|
||||
} catch (TypeError $e) {
|
||||
throw new PHPUnit_Framework_Error('Raised an error', 100, __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue