Skip to content

Commit

Permalink
[TASK] Avoid withConsecutive() in RequestHandlerTest
Browse files Browse the repository at this point in the history
Even though the RequestHandlerTest unit tests
are an aweful mocking party, we can't simply
throw them away since the class is so important.

They should still be turned into functional
tests later, to be more useful, maybe together
with a refactoring of that class.

The patch just changes the tests to avoid
withConsecutive(), which does not improve
the situation, but a bigger refactoring
is currently a bit too much with our current
goal of "just" adding phpunit 10 compatibility.

Resolves: #100410
Related: #100249
Releases: main
Change-Id: I8b09013b826ed56e0c6e96eade4c9f4a61346273
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78379
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Tested-by: Oliver Klee <typo3-coding@oliverklee.de>
Tested-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
  • Loading branch information
lolli42 authored and o-ba committed Apr 3, 2023
1 parent 9fff061 commit 29319fd
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions typo3/sysext/frontend/Tests/Unit/Http/RequestHandlerTest.php
Expand Up @@ -35,6 +35,9 @@
use TYPO3\CMS\Frontend\Http\RequestHandler;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

/**
* @todo: It looks as if these unit tests should be turned into functional tests
*/
class RequestHandlerTest extends UnitTestCase
{
protected bool $resetSingletonInstances = true;
Expand Down Expand Up @@ -449,10 +452,21 @@ public function generateMultipleMetaTags(array $typoScript, string $stdWrapResul

$pageRendererMock = $this->getMockBuilder(PageRenderer::class)->disableOriginalConstructor()->getMock();
$pageRendererMock->method('getDocType')->willReturn(DocType::html5);
$pageRendererMock->expects(self::exactly(2))->method('setMetaTag')->withConsecutive(
$series = [
[$expectedTags[0]['type'], $expectedTags[0]['name'], $expectedTags[0]['content'], [], false],
[$expectedTags[1]['type'], $expectedTags[1]['name'], $expectedTags[1]['content'], [], false]
);
[$expectedTags[1]['type'], $expectedTags[1]['name'], $expectedTags[1]['content'], [], false],
];
$pageRendererMock
->expects(self::exactly(2))
->method('setMetaTag')
->willReturnCallback(function (string $type, string $name, string $content, array $subProperties, bool $replace) use (&$series): void {
$expectedArgs = array_shift($series);
self::assertSame($expectedArgs[0], $type);
self::assertSame($expectedArgs[1], $name);
self::assertSame($expectedArgs[2], $content);
self::assertSame($expectedArgs[3], $subProperties);
self::assertSame($expectedArgs[4], $replace);
});
$frontendTypoScript = new FrontendTypoScript(new RootNode(), []);
$frontendTypoScript->setSetupArray([]);
$request = (new ServerRequest())->withAttribute('frontend.typoscript', $frontendTypoScript);
Expand Down

0 comments on commit 29319fd

Please sign in to comment.