Skip to content

Commit

Permalink
[TASK] Update testing framework
Browse files Browse the repository at this point in the history
Updates TYPO3 testing framework to version 8.x and
performs required compatibility adaptions.

Resolves: #3918
  • Loading branch information
dkd-friedrich committed Apr 3, 2024
1 parent 817b77d commit 21f4c32
Show file tree
Hide file tree
Showing 116 changed files with 842 additions and 1,095 deletions.
40 changes: 25 additions & 15 deletions Build/Test/IntegrationTests.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
bootstrap="IntegrationTestsBootstrap.php"
backupStaticAttributes="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
backupGlobals="true"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="../../.Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
cacheDirectory=".phpunit.cache"
cacheResult="false"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
failOnDeprecation="true"
failOnNotice="true"
failOnRisky="true"
failOnWarning="true"
requireCoverageMetadata="false"
processIsolation="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false">
<coverage processUncoveredFiles="false">
>
<coverage includeUncoveredFiles="false"></coverage>
<source>
<include>
<directory suffix=".php">../../Classes/</directory>
<directory>../../Classes</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="ext-solr-integration-tests">
<directory>../../Tests/Integration/</directory>
</testsuite>
</testsuites>
<php>
<ini name="display_errors" value="1"/>
<env name="TYPO3_CONTEXT" value="Testing"/>
</php>
</phpunit>
23 changes: 0 additions & 23 deletions Build/Test/IntegrationTestsBootstrap.php

This file was deleted.

48 changes: 28 additions & 20 deletions Build/Test/UnitTests.xml
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
bootstrap="UnitTestsBootstrap.php"
backupStaticAttributes="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
backupGlobals="true"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="../../.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php"
cacheDirectory=".phpunit.cache"
cacheResult="false"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false">
<extensions>
<extension class="\ApacheSolrForTypo3\Solr\Tests\PHPUnitExtensions\BypassFinals"/>
</extensions>
<coverage processUncoveredFiles="false">
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
failOnDeprecation="true"
failOnNotice="true"
failOnRisky="true"
failOnWarning="true"
requireCoverageMetadata="false"
>
<source>
<include>
<directory suffix=".php">../../Classes/</directory>
<directory>../../Classes</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="ext-solr-unit-tests">
<directory>../../Tests/Unit/</directory>
</testsuite>
</testsuites>
</phpunit>
<php>
<ini name="display_errors" value="1"/>
<env name="TYPO3_CONTEXT" value="Testing"/>
</php>
<extensions>
<bootstrap class="DG\BypassFinals\PHPUnitExtension"/>
</extensions>
</phpunit>
82 changes: 0 additions & 82 deletions Build/Test/UnitTestsBootstrap.php

This file was deleted.

8 changes: 4 additions & 4 deletions Classes/Report/SiteHandlingStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ class SiteHandlingStatus extends AbstractSolrStatus

public const
CSS_STATUS_NOTICE = 'notice',
CSS_STATUS_INFO = 'info',
CSS_STATUS_OK = 'success',
CSS_STATUS_WARNING = 'warning',
CSS_STATUS_ERROR = 'danger';
CSS_STATUS_INFO = 'info',
CSS_STATUS_OK = 'success',
CSS_STATUS_WARNING = 'warning',
CSS_STATUS_ERROR = 'danger';

protected SiteRepository $siteRepository;

Expand Down
12 changes: 10 additions & 2 deletions Classes/ViewHelpers/SearchFormViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use ApacheSolrForTypo3\Solr\System\Url\UrlHelper;
use ApacheSolrForTypo3\Solr\System\Util\SiteUtility;
use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
Expand Down Expand Up @@ -109,7 +110,10 @@ public function render()
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->add('pageUid', $pageUid);
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->add('languageUid', ($GLOBALS['TSFE']?->getLanguage()->getLanguageId() ?? 0));
$this->getTemplateVariableContainer()->add(
'languageUid',
($this->renderingContext->getRequest()->getAttribute('language')?->getLanguageId() ?? 0)
);
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->add('existingParameters', $this->getExistingSearchParameters());
// @extensionScannerIgnoreLine
Expand Down Expand Up @@ -139,7 +143,11 @@ protected function getExistingSearchParameters(): array
{
$searchParameters = [];
if ($this->getTypoScriptConfiguration()->getSearchKeepExistingParametersForNewSearches()) {
$arguments = GeneralUtility::_GPmerged($this->getTypoScriptConfiguration()->getSearchPluginNamespace());
$request = $this->renderingContext->getRequest();
$pluginNamespace = $this->getTypoScriptConfiguration()->getSearchPluginNamespace();
$arguments = $request->getQueryParams()[$pluginNamespace];
ArrayUtility::mergeRecursiveWithOverrule($arguments, $request->getParsedBody()[$pluginNamespace]);

unset($arguments['q'], $arguments['id'], $arguments['L']);
$searchParameters = $this->translateSearchParametersToInputTagAttributes($arguments);
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/Integration/Access/RootlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace ApacheSolrForTypo3\Solr\Tests\Integration\Access;

use ApacheSolrForTypo3\Solr\Access\Rootline;
use ApacheSolrForTypo3\Solr\Tests\Integration\IntegrationTest;
use ApacheSolrForTypo3\Solr\Tests\Integration\IntegrationTestBase;

/**
* Class RootlineTest
*/
class RootlineTest extends IntegrationTest
class RootlineTest extends IntegrationTestBase
{
/**
* @test
Expand Down
4 changes: 2 additions & 2 deletions Tests/Integration/Backend/SettingsPreviewOnPluginsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace ApacheSolrForTypo3\Solr\Tests\Integration\Backend;

use ApacheSolrForTypo3\Solr\Backend\SettingsPreviewOnPlugins;
use ApacheSolrForTypo3\Solr\Tests\Integration\IntegrationTest;
use ApacheSolrForTypo3\Solr\Tests\Integration\IntegrationTestBase;
use PHPUnit\Framework\MockObject\MockObject;
use TYPO3\CMS\Backend\View\Event\PageContentPreviewRenderingEvent;
use TYPO3\CMS\Backend\View\PageLayoutContext;
Expand All @@ -16,7 +16,7 @@
* configuration.
* This testcase checks if the SummaryController produces the expected output.
*/
class SettingsPreviewOnPluginsTest extends IntegrationTest
class SettingsPreviewOnPluginsTest extends IntegrationTestBase
{
protected array $flexFormArray = [
'search' => [
Expand Down
22 changes: 9 additions & 13 deletions Tests/Integration/ConnectionManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* @author Timo Hund
*/
class ConnectionManagerTest extends IntegrationTest
class ConnectionManagerTest extends IntegrationTestBase
{
/**
* @inheritdoc
Expand All @@ -42,12 +42,10 @@ protected function setUp(): void
$this->writeDefaultSolrTestSiteConfiguration();
}

public function canFindSolrConnectionsByRootPageIdDataProvider(): array
public static function canFindSolrConnectionsByRootPageIdDataProvider(): \Traversable
{
return [
['rootPageId' => 1, 'siteName' => 'integration_tree_one', 'expectedSolrHost' => 'solr.testone.endpoint'],
['rootPageId' => 111, 'siteName' => 'integration_tree_two', 'expectedSolrHost' => 'solr.testtwo.endpoint'],
];
yield ['rootPageId' => 1, 'siteName' => 'integration_tree_one', 'expectedSolrHost' => 'solr.testone.endpoint'];
yield ['rootPageId' => 111, 'siteName' => 'integration_tree_two', 'expectedSolrHost' => 'solr.testtwo.endpoint'];
}

/**
Expand All @@ -63,7 +61,7 @@ public function canFindSolrConnectionsByRootPageIdDataProvider(): array
* @test
* @dataProvider canFindSolrConnectionsByRootPageIdDataProvider
*/
public function canFindSolrConnectionsByRootPageId(int $rootPageId, string $siteName, string $expectedSolrHost)
public function canFindSolrConnectionsByRootPageId(int $rootPageId, string $siteName, string $expectedSolrHost): void
{
$this->mergeSiteConfiguration($siteName, ['solr_host_read' => $expectedSolrHost]);
$this->importCSVDataSet(__DIR__ . '/Fixtures/connection_basic.csv');
Expand All @@ -78,12 +76,10 @@ public function canFindSolrConnectionsByRootPageId(int $rootPageId, string $site
}
}

public function canFindSolrConnectionsByPageIdDataProvider(): array
public static function canFindSolrConnectionsByPageIdDataProvider(): \Traversable
{
return [
['pageId' => 11, 'siteName' => 'integration_tree_one', 'expectedSolrHost' => 'solr.testone.endpoint'],
['pageId' => 21, 'siteName' => 'integration_tree_two', 'expectedSolrHost' => 'solr.testtwo.endpoint'],
];
yield ['pageId' => 11, 'siteName' => 'integration_tree_one', 'expectedSolrHost' => 'solr.testone.endpoint'];
yield ['pageId' => 21, 'siteName' => 'integration_tree_two', 'expectedSolrHost' => 'solr.testtwo.endpoint'];
}

/**
Expand All @@ -110,7 +106,7 @@ public function canFindSolrConnectionsByPageIdDataProvider(): array
* @test
* @dataProvider canFindSolrConnectionsByPageIdDataProvider
*/
public function canFindSolrConnectionsByPageId(int $pageId, string $siteName, string $expectedSolrHost)
public function canFindSolrConnectionsByPageId(int $pageId, string $siteName, string $expectedSolrHost): void
{
$this->mergeSiteConfiguration($siteName, ['solr_host_read' => $expectedSolrHost]);
$this->importCSVDataSet(__DIR__ . '/Fixtures/connection_basic.csv');
Expand Down
Loading

0 comments on commit 21f4c32

Please sign in to comment.