2017-11-24 15:08:43 +01:00
|
|
|
<?php
|
|
|
|
|
2023-02-03 20:41:59 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-04-19 20:41:38 +02:00
|
|
|
namespace Engelsystem\Test\Unit\Exceptions\Handlers;
|
2017-11-24 15:08:43 +01:00
|
|
|
|
|
|
|
use Engelsystem\Exceptions\Handlers\LegacyDevelopment;
|
|
|
|
use Engelsystem\Http\Request;
|
|
|
|
use ErrorException;
|
2019-04-24 10:45:00 +02:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
2017-11-24 15:08:43 +01:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
class LegacyDevelopmentTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
2022-12-22 00:08:54 +01:00
|
|
|
* @covers \Engelsystem\Exceptions\Handlers\LegacyDevelopment::formatStackTrace
|
|
|
|
* @covers \Engelsystem\Exceptions\Handlers\LegacyDevelopment::render
|
|
|
|
* @covers \Engelsystem\Exceptions\Handlers\LegacyDevelopment::getDisplayNameOfValue
|
2017-11-24 15:08:43 +01:00
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testRender(): void
|
2017-11-24 15:08:43 +01:00
|
|
|
{
|
|
|
|
$handler = new LegacyDevelopment();
|
2019-04-24 10:45:00 +02:00
|
|
|
/** @var Request|MockObject $request */
|
2017-11-24 15:08:43 +01:00
|
|
|
$request = $this->createMock(Request::class);
|
2020-04-05 19:32:55 +02:00
|
|
|
$exception = new ErrorException('Lorem <b>Ipsum</b>', 4242, 1, 'foo.php', 9999);
|
2017-11-24 15:08:43 +01:00
|
|
|
|
|
|
|
$regex = sprintf(
|
2020-04-05 19:32:55 +02:00
|
|
|
'%%<pre.*>.*ErrorException.*4242.*Lorem <b>Ipsum</b>.*%s.*%s.*%s.*</pre>%%is',
|
2017-11-24 15:08:43 +01:00
|
|
|
'foo.php',
|
|
|
|
9999,
|
|
|
|
__FUNCTION__
|
|
|
|
);
|
|
|
|
$this->expectOutputRegex($regex);
|
|
|
|
|
|
|
|
$handler->render($request, $exception);
|
|
|
|
}
|
|
|
|
}
|