Skip to content

Commit

Permalink
[BUGFIX] Fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Apen committed Dec 10, 2024
1 parent 1ee654a commit 57d979f
Show file tree
Hide file tree
Showing 14 changed files with 232 additions and 196 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: [ '8.1' ]
php-versions: [ '8.2' ]
packages:
- typo3: '^11'
testingframework: '^7'
- typo3: '^12'
testingframework: '^8'
- typo3: '^13'
testingframework: 'dev-main'
steps:
- name: Check out repository
Expand Down
51 changes: 22 additions & 29 deletions Build/FunctionalTests.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,28 @@
<phpunit
backupGlobals="true"
bootstrap="../.Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
convertDeprecationsToExceptions="false"
beStrictAboutTestsThatDoNotTestAnything="false"
backupGlobals="true"
bootstrap="../.Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
testdox="true"
colors="true"
processIsolation="false"
stopOnError="true"
stopOnWarning="true"
stopOnDeprecation="true"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
beStrictAboutTestsThatDoNotTestAnything="false"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnPhpunitDeprecations="true"
>

<testsuites>
<testsuite name="tests">
<directory>../Tests/Functional/</directory>
</testsuite>
</testsuites>
<testsuites>
<testsuite name="tests">
<directory>../Tests/Functional/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>../Classes/</directory>
<directory>../Tests/</directory>
</whitelist>
</filter>

<php>
<env name="typo3DatabaseDriver" value="pdo_sqlite"/>
</php>
<php>
<env name="typo3DatabaseDriver" value="pdo_sqlite"/>
</php>

</phpunit>
35 changes: 0 additions & 35 deletions Build/Local/FunctionalTests.xml

This file was deleted.

28 changes: 0 additions & 28 deletions Build/Local/UnitTests.xml

This file was deleted.

39 changes: 15 additions & 24 deletions Build/UnitTests.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
<phpunit
backupGlobals="true"
bootstrap="../.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
convertDeprecationsToExceptions="false"
beStrictAboutTestsThatDoNotTestAnything="false"
backupGlobals="true"
bootstrap="../.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php"
colors="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
beStrictAboutTestsThatDoNotTestAnything="false"
displayDetailsOnTestsThatTriggerWarnings="true"
>
<testsuites>
<testsuite name="tests">
<directory>../Tests/Unit/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>../Classes/</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="tests">
<directory>../Tests/Unit/</directory>
</testsuite>
</testsuites>

</phpunit>
21 changes: 17 additions & 4 deletions Classes/Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ public static function getExtIcon($extKey)
{
if (!empty($extKey)) {
$extType = self::getExtensionType($extKey);
if (!isset($extType['siteRelPath'])) {
return '';
}
$path = $extType['siteRelPath'] . ExtensionManagementUtility::getExtensionIcon(
Utility::getPathSite() . '/' . $extType['siteRelPath']
);
Expand Down Expand Up @@ -328,7 +331,7 @@ public static function getContentInfosFromTca($type, $value)
$icon = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class)->getIconConfigurationByIdentifier(
$iconPath
);
if (isset($icon['options']) &&str_contains($icon['options']['source'], 'EXT:')) {
if (isset($icon['options']) && str_contains($icon['options']['source'], 'EXT:')) {
$infos['iconext'] = PathUtility::getPublicResourceWebPath($icon['options']['source']);
} elseif (isset($icon['options']['source'])) {
$infos['iconext'] = PathUtility::getAbsoluteWebPath($icon['options']['source']);
Expand Down Expand Up @@ -638,11 +641,12 @@ public static function getExtensionVersion($key): ?string

if (self::isComposerMode()) {
$packageManager = GeneralUtility::makeInstance(PackageManager::class);
/** @var \TYPO3\CMS\Core\Package\PackageInterface $package */
$package = $packageManager->getPackage($key);
if ($package === null) {
return null;
}
return $package->getVersion();
return $package->getPackageMetaData()->getVersion();
}

if (!ExtensionManagementUtility::isLoaded($key)) {
Expand Down Expand Up @@ -1131,7 +1135,14 @@ public static function getLl(string $key): string
*/
public static function exec_SELECT_queryArray($queryParts)
{
return self::exec_SELECTquery($queryParts['SELECT'], $queryParts['FROM'], $queryParts['WHERE'], $queryParts['GROUPBY'], $queryParts['ORDERBY'], $queryParts['LIMIT']);
return self::exec_SELECTquery(
$queryParts['SELECT'],
$queryParts['FROM'],
$queryParts['WHERE'],
$queryParts['GROUPBY'] ?? '',
$queryParts['ORDERBY'] ?? '',
$queryParts['LIMIT'] ?? ''
);
}

/**
Expand Down Expand Up @@ -1237,7 +1248,9 @@ public static function getLanguageService(): LanguageService
if (!empty($GLOBALS['TSFE'])) {
return $GLOBALS['TSFE'];
}
return GeneralUtility::makeInstance(LanguageServiceFactory::class)->create($GLOBALS['BE_USER']->uc['lang'] ?? 'default');
$languageService = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create($GLOBALS['BE_USER']->uc['lang'] ?? 'default');
$GLOBALS['LANG'] = $languageService;
return $languageService;
}

public static function getPathSite(): string
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<source>List of all the CommandControllers declare in $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'] (old way)</source>
</trans-unit>
<trans-unit id="commandcontrollersnew_description">
<source>List of all the Symfony Commands declare in Configuration/Commands.php of the extension</source>
<source>List of all the Symfony Commands</source>
</trans-unit>
<trans-unit id="commandcontrollers_title">
<source>Additional reports - Commands</source>
Expand Down
5 changes: 5 additions & 0 deletions Tests/Functional/Fixtures/be_users.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"be_users",,,,,,,,
,uid,pid,username,email,realName,admin,deleted,disable
,1,0,[email protected],[email protected],Admin,1,0,0
,2,0,[email protected],[email protected],User,0,0,0
,3,0,[email protected],[email protected],User,0,0,0
56 changes: 56 additions & 0 deletions Tests/Functional/Fixtures/pages.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"pages"
,"uid","pid","title","deleted","hidden","no_search"
,1,0,"Congratulations",0,0,0
,2,1,"Frontend User",0,0,0
,3,1,"File Collections",0,0,0
,4,1,"Shared Content",0,0,0
,5,1,"404",0,0,1
,6,1,"Content Examples",0,0,0
,7,6,"And more...",0,0,0
,8,7,"Frames",0,0,0
,9,7,"Images with links",0,0,0
,10,7,"Any language, any character",0,0,0
,11,6,"Special elements",0,0,0
,12,11,"Divider",0,0,0
,13,11,"HTML",0,0,0
,14,11,"Insert records",0,0,0
,15,6,"Menu's",0,0,0
,16,15,"Thumbnails",0,0,0
,17,15,"Sitemap",0,0,0
,18,15,"Sections",0,0,0
,19,15,"Related Pages",0,0,0
,20,15,"Recently Updated",0,0,0
,21,15,"Categorized",0,0,0
,22,15,"Abstract",0,0,0
,23,15,"Pages",0,0,0
,24,6,"Form elements",0,0,0
,25,24,"Search",0,0,0
,26,24,"Login",0,0,0
,27,24,"Forms",0,0,0
,28,6,"Intreractive",0,0,0
,29,28,"Tab",0,0,0
,30,28,"Carousel",0,0,0
,31,28,"Accordion",0,0,0
,32,6,"Media",0,0,0
,33,32,"External Media",0,0,0
,34,32,"Media",0,0,0
,35,32,"Images",0,0,0
,36,32,"File downloads",0,0,0
,37,32,"Text and Media",0,0,0
,38,32,"Text and Images",0,0,0
,39,32,"Audio",0,0,0
,40,6,"Text",0,0,0
,41,40,"Quote",0,0,0
,42,40,"Table",0,0,0
,43,40,"Panel",0,0,0
,44,40,"List Group",0,0,0
,45,40,"Text in Columns",0,0,0
,46,40,"Text and Icon",0,0,0
,47,40,"Text with Teaser",0,0,0
,48,40,"Bullet List",0,0,0
,49,40,"Headers",0,0,0
,50,40,"Rich Text",0,0,0
,51,6,"Overview",0,0,0
,52,1,"Customizings",0,0,0
,53,1,"Features",0,0,0
,54,1,"Home",0,0,0
14 changes: 14 additions & 0 deletions Tests/Functional/Fixtures/tt_content.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"tt_content"
,"uid","pid","deleted","hidden","CType","list_type","header"
,1,53,0,0,"text","","Upgrading TYPO3? No problem."
,2,53,0,0,"textpic","","Ease of Use"
,3,53,0,0,"textpic","","Publishing Content"
,4,53,0,0,"textpic","","Runs everywhere"
,5,53,0,0,"textpic","","Multi-Language and Multiple Domains"
,6,53,0,0,"textpic","","Your data - our strength"
,7,53,0,0,"textpic","","Granular Frontend and Backend Access Rights"
,8,53,0,0,"textpic","","No Design Constraints For Your Web Project"
,9,53,0,0,"textpic","","Frontend Editing"
,10,53,0,0,"text","","And More..."
,11,53,0,0,"text","","Enterprise Features"
,133,25,0,0,"list","indexedsearch_pi2","Search"
17 changes: 16 additions & 1 deletion Tests/Functional/FunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

namespace Sng\AdditionalReports\Tests\Functional;

use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Http\Uri;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Reports\Controller\ReportController;
use TYPO3\CMS\Core\Http\Application as CoreHttpApplication;

class FunctionalTestCase extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
{
Expand All @@ -23,12 +29,21 @@ class FunctionalTestCase extends \TYPO3\TestingFramework\Core\Functional\Functio
protected function setUp(): void
{
parent::setUp();
$this->setUpBackendUserFromFixture(1);

$this->importCSVDataSet(__DIR__ . '/Fixtures/be_users.csv');
$backendUser = $this->setUpBackendUser(1);
Bootstrap::initializeLanguageObject();

$uri = new Uri('https://localhost/typo3/');
$request = new ServerRequest($uri);
$request = $request->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_BE);
$GLOBALS['TYPO3_REQUEST'] = $request;
}

public static function getReportObject()
{
return GeneralUtility::makeInstance(ReportController::class);
}


}
Loading

0 comments on commit 57d979f

Please sign in to comment.