Skip to content

Commit

Permalink
[FIX] Tests for TYPO3 dev-main @2024.09.23
Browse files Browse the repository at this point in the history
Follow-Up for:
https://review.typo3.org/c/Packages/TYPO3.CMS/+/86184
TYPO3/testing-framework@60f586e
Required for "typo3/testing-framework" and TYPO3 dev-main @2024.09.23
  • Loading branch information
dkd-kaehm committed Sep 23, 2024
1 parent 2a85965 commit ff7e038
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Build/Test/IntegrationTests.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd"
backupGlobals="true"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="../../.Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
Expand All @@ -15,6 +15,7 @@
failOnNotice="true"
failOnRisky="true"
failOnWarning="true"
failOnPhpunitDeprecation="true"
processIsolation="true"
>
<coverage includeUncoveredFiles="false"/>
Expand Down
5 changes: 3 additions & 2 deletions Build/Test/UnitTests.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd"
backupGlobals="true"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="../../.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php"
Expand All @@ -15,6 +15,7 @@
failOnNotice="true"
failOnRisky="true"
failOnWarning="true"
failOnPhpunitDeprecation="true"
requireCoverageMetadata="false"
>
<source>
Expand All @@ -34,4 +35,4 @@
<extensions>
<bootstrap class="DG\BypassFinals\PHPUnitExtension"/>
</extensions>
</phpunit>
</phpunit>
2 changes: 1 addition & 1 deletion Tests/Integration/IndexQueue/PageIndexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public static function canIndexPageWithAccessProtectedContentIntoSolrDataProvide
'expectedNumFoundAnonymousUser' => 0,
'userGroupToCheckAccessFilter' => '0,1,2',
'expectedNumFoundLoggedInUser' => 2,
'core_de',
'core' => 'core_de',
];

yield 'public page with protected content and global content' => [
Expand Down
1 change: 0 additions & 1 deletion Tests/Unit/ContentObject/SetUpContentObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ protected function setUp(): void
parent::setUp();

$tsfe = $this->getMockBuilder(TypoScriptFrontendController::class)
->addMethods(['dummy'])
->disableOriginalConstructor()
->getMock();

Expand Down
10 changes: 9 additions & 1 deletion Tests/Unit/Domain/Search/Suggest/SuggestServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use ApacheSolrForTypo3\Solr\System\Solr\SolrConnection;
use ApacheSolrForTypo3\Solr\Tests\Unit\SetUpUnitTestCase;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockBuilder;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\EventDispatcher\ListenerProviderInterface;
Expand Down Expand Up @@ -126,8 +127,10 @@ public function canHandleInvalidSyntaxInAdditionalFilters(): void
public static SuggestServiceTest $suggestServiceTest;
public function search(Query $query, $offset = 0, $limit = 10): ?ResponseAdapter
{
return self::$suggestServiceTest->getMockBuilder(ResponseAdapter::class)
/** @var ResponseAdapter|MockBuilder $mockObject */
$mockObject = self::$suggestServiceTest->provideMockBuilderInObjectsScope(ResponseAdapter::class)
->onlyMethods([])->disableOriginalConstructor()->getMock();
return $mockObject;
}
};
$searchStub::$suggestServiceTest = $this;
Expand All @@ -146,6 +149,11 @@ public function search(Query $query, $offset = 0, $limit = 10): ?ResponseAdapter
self::assertSame($expectedSuggestions, $suggestions, 'Suggest did not return status false');
}

public function provideMockBuilderInObjectsScope(string $className): ResponseAdapter|MockBuilder
{
return parent::getMockBuilder($className);
}

#[Test]
public function emptyJsonIsReturnedWhenSolrHasNoSuggestions(): void
{
Expand Down
8 changes: 5 additions & 3 deletions Tests/Unit/IndexQueue/PageIndexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ public function testIndexPageItemIsSendingFrontendRequestsToExpectedUrls(): void
$indexResponse->expects(self::once())->method('getActionResult')->with('indexPage')->willReturn(['pageIndexed' => 'Success']);

// Two requests will be send, the first one for the access groups, the second one for the indexing itself
$this->pageIndexerRequestMock->expects(self::exactly(2))->method('send')->with('http://myfrontendurl.de/index.php?id=4711&L=0')->will(
self::onConsecutiveCalls($accessGroupResponse, $indexResponse)
);
$this->pageIndexerRequestMock
->expects(self::exactly(2))
->method('send')
->with('http://myfrontendurl.de/index.php?id=4711&L=0')
->willReturn($accessGroupResponse, $indexResponse);

$pageIndexer = $this->getPageIndexerWithMockedDependencies([]);
$pageRootLineMock = $this->createMock(Rootline::class);
Expand Down
5 changes: 4 additions & 1 deletion Tests/Unit/System/Cache/TwoLevelCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ public function canHandleInvalidCacheIdentifierOnSet(): void
public function canHandleInvalidCacheIdentifierOnGet(): void
{
$cacheBackendMock = $this->createMock(BackendInterface::class);
$cacheBackendMock->expects(self::once())->method('get')->willReturn(self::returnValue(''));
$cacheBackendMock
->expects(self::once())
->method('get')
->willReturn('');
$variableFrontend = new VariableFrontend('TwoLevelCacheTest', $cacheBackendMock);
$this->twoLevelCache = new TwoLevelCache('test', $variableFrontend);

Expand Down
6 changes: 3 additions & 3 deletions Tests/Unit/System/Solr/Service/SolrReadServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public function searchMethodIsTriggeringGetRequest(): void

public static function readServiceExceptionDataProvider(): Traversable
{
yield 'Communication error' => ['exceptionClass' => SolrUnavailableException::class, 0];
yield 'Internal Server error' => ['exceptionClass' => SolrInternalServerErrorException::class, 500];
yield 'Other unspecific error' => ['exceptionClass' => SolrCommunicationException::class, 555];
yield 'Communication error' => ['exceptionClass' => SolrUnavailableException::class, 'statusCode' => 0];
yield 'Internal Server error' => ['exceptionClass' => SolrInternalServerErrorException::class, 'statusCode' => 500];
yield 'Other unspecific error' => ['exceptionClass' => SolrCommunicationException::class, 'statusCode' => 555];
}

#[DataProvider('readServiceExceptionDataProvider')]
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
},
"require-dev": {
"dg/bypass-finals": "^1.6",
"phpunit/phpunit": "^10.5",
"phpunit/phpunit": "^11.2",
"typo3/cms-fluid-styled-content": "*",
"typo3/coding-standards": "dev-main#27798dd4b8a15d2178260dbd6aad83fb0d6a017e",
"typo3/testing-framework": "^8.0",
"typo3/testing-framework": "dev-main#60f586e8923e48be2e7a2dcd9634e9eac51eab6d",
"phpstan/phpstan": "^1.11",
"phpstan/phpstan-phpunit": "^1.3"
},
Expand Down

0 comments on commit ff7e038

Please sign in to comment.