fix(AppTest): add error handlers on exit

This commit is contained in:
Jérémy Dufraisse 2023-03-21 08:55:54 +01:00
parent 1f89a43499
commit d4711dddd1

View File

@ -16,6 +16,33 @@ use Throwable;
final class AppTest extends TestCase {
/**
* register error handlers
*/
public function testInit()
{
$displayErrors = true;
set_error_handler(function(
int $errno,
string $errstr,
?string $errfile = null,
?int $errline = null,
?array $errcontext = null
) use (&$displayErrors){
if ($displayErrors){
echo "\nError $errstr ($errno)\nIn file $errfile\nLine : $errline\n";
}
});
register_shutdown_function(function (){
$lastErr = error_get_last();
if (!is_null($lastErr)){
echo "\nAn error occured\n".json_encode($lastErr)."\n";
}
});
$this->assertTrue($displayErrors);
}
/**
* @depends testInit
* @dataProvider apiRewriteProvider
* @covers App::update_SERVERIfNeeded
* @param string $rootFolder,
@ -62,7 +89,7 @@ final class AppTest extends TestCase {
return $data;
}
public function prepareData(
protected function prepareData(
array &$data,
string $name,
string $rootFolder,