Skip to content
Snippets Groups Projects
Commit 6e4a2b50 authored by Torben Hansen's avatar Torben Hansen Committed by Nikita Hovratov
Browse files

[TASK] Replace prophecy in EXT:core ProductionExceptionHandlerTest

Resolves: #98791
Releases: main
Change-Id: I092627dc7555156be9e2cb5d67e1de928f386bea
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76706


Tested-by: default avatarOliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: default avatarOliver Klee <typo3-coding@oliverklee.de>
Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarNikita Hovratov <nikita.h@live.de>
Reviewed-by: default avatarNikita Hovratov <nikita.h@live.de>
parent 316db326
Branches
Tags
No related merge requests found
......@@ -18,7 +18,6 @@ declare(strict_types=1);
namespace TYPO3\CMS\Core\Tests\Unit\Error;
use PHPUnit\Framework\MockObject\MockObject;
use Prophecy\PhpUnit\ProphecyTrait;
use Psr\Log\LoggerInterface;
use Psr\Log\LoggerTrait;
use TYPO3\CMS\Core\Error\ProductionExceptionHandler;
......@@ -26,19 +25,10 @@ use TYPO3\CMS\Core\Information\Typo3Information;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
/**
* testcase for the \TYPO3\CMS\Core\Error\ProductionExceptionHandler class.
*/
class ProductionExceptionHandlerTest extends UnitTestCase
{
use ProphecyTrait;
protected bool $resetSingletonInstances = true;
/**
* @var \TYPO3\CMS\Core\Error\ProductionExceptionHandler|MockObject
*/
protected $subject;
protected ProductionExceptionHandler&MockObject $subject;
/**
* Sets up this test case.
......@@ -69,9 +59,9 @@ class ProductionExceptionHandlerTest extends UnitTestCase
*/
public function echoExceptionWebEscapesExceptionMessage(): void
{
$typo3InformationProphecy = $this->prophesize(Typo3Information::class);
$typo3InformationProphecy->getCopyrightYear()->willReturn('1999-20XX');
GeneralUtility::addInstance(Typo3Information::class, $typo3InformationProphecy->reveal());
$typo3InformationMock = $this->createMock(Typo3Information::class);
$typo3InformationMock->method('getCopyrightYear')->willReturn('1999-20XX');
GeneralUtility::addInstance(Typo3Information::class, $typo3InformationMock);
$message = '<b>b</b><script>alert(1);</script>';
$exception = new \Exception($message, 1476049364);
ob_start();
......@@ -87,9 +77,9 @@ class ProductionExceptionHandlerTest extends UnitTestCase
*/
public function echoExceptionWebEscapesExceptionTitle(): void
{
$typo3InformationProphecy = $this->prophesize(Typo3Information::class);
$typo3InformationProphecy->getCopyrightYear()->willReturn('1999-20XX');
GeneralUtility::addInstance(Typo3Information::class, $typo3InformationProphecy->reveal());
$typo3InformationMock = $this->createMock(Typo3Information::class);
$typo3InformationMock->method('getCopyrightYear')->willReturn('1999-20XX');
GeneralUtility::addInstance(Typo3Information::class, $typo3InformationMock);
$title = '<b>b</b><script>alert(1);</script>';
$exception = $this->getMockBuilder(\Exception::class)
->addMethods(['getTitle'])
......@@ -142,14 +132,12 @@ class ProductionExceptionHandlerTest extends UnitTestCase
/**
* @test
* @dataProvider exampleUrlsForTokenAnonymization
* @param string $originalUrl
* @param string $expectedUrl
*/
public function logEntriesContainAnonymousTokens(string $originalUrl, string $expectedUrl): void
{
$typo3InformationProphecy = $this->prophesize(Typo3Information::class);
$typo3InformationProphecy->getCopyrightYear()->willReturn('1999-20XX');
GeneralUtility::addInstance(Typo3Information::class, $typo3InformationProphecy->reveal());
$typo3InformationMock = $this->createMock(Typo3Information::class);
$typo3InformationMock->method('getCopyrightYear')->willReturn('1999-20XX');
GeneralUtility::addInstance(Typo3Information::class, $typo3InformationMock);
$subject = new ProductionExceptionHandler();
$logger = new class () implements LoggerInterface {
use LoggerTrait;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment