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
|
* testControllerTypeError
|
||||||
*
|
*
|
||||||
|
* @expectedException PHPUnit_Framework_Error
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testControllerTypeError() {
|
public function testControllerTypeError() {
|
||||||
try {
|
try {
|
||||||
$this->auth->controller(new StdClass());
|
$this->auth->controller(new StdClass());
|
||||||
$this->fail('No exception thrown');
|
$this->fail('No exception thrown');
|
||||||
} catch (Throwable $t) {
|
} catch (TypeError $e) {
|
||||||
$this->assertTrue(true, 'Exception was raised');
|
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.
|
* test reader() throwing exceptions on missing interface.
|
||||||
*
|
*
|
||||||
|
* @expectedException PHPUnit_Framework_Error
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testReaderExceptionOnIncorrectClass() {
|
public function testReaderExceptionOnIncorrectClass() {
|
||||||
|
@ -456,9 +457,8 @@ class ConfigureTest extends CakeTestCase {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Configure::config('test', $reader);
|
Configure::config('test', $reader);
|
||||||
$this->fail('No error raised');
|
} catch (TypeError $e) {
|
||||||
} catch (Throwable $t) {
|
throw new PHPUnit_Framework_Error('Raised an error', 100, __FILE__, __LINE__);
|
||||||
$this->assertTrue(true, 'TypeError raised');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2908,14 +2908,15 @@ SQL;
|
||||||
/**
|
/**
|
||||||
* testDropSchemaNoSchema method
|
* testDropSchemaNoSchema method
|
||||||
*
|
*
|
||||||
|
* @expectedException PHPUnit_Framework_Error
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testDropSchemaNoSchema() {
|
public function testDropSchemaNoSchema() {
|
||||||
try {
|
try {
|
||||||
$this->Dbo->dropSchema(null);
|
$this->Dbo->dropSchema(null);
|
||||||
$this->fail('No exception');
|
$this->fail('No exception');
|
||||||
} catch (Throwable $t) {
|
} catch (TypeError $e) {
|
||||||
$this->assertTrue(true, 'Exception raised');
|
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
|
* Test that type hint exception is thrown
|
||||||
*
|
*
|
||||||
|
* @expectedException PHPUnit_Framework_Error
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testValidatorTypehintException() {
|
public function testValidatorTypehintException() {
|
||||||
try {
|
try {
|
||||||
new ModelValidator('asdasds');
|
new ModelValidator('asdasds');
|
||||||
$this->fail('No exeption raised');
|
$this->fail('No exeption raised');
|
||||||
} catch (Throwable $t) {
|
} catch (TypeError $e) {
|
||||||
$this->assertTrue(true, 'An error/exception was raised');
|
throw new PHPUnit_Framework_Error('Raised an error', 100, __FILE__, __LINE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue