Skip to content

Commit

Permalink
[WIP] change requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
achimfritz-b13 committed May 24, 2024
1 parent 355780f commit 2700f0f
Show file tree
Hide file tree
Showing 20 changed files with 164 additions and 158 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,14 @@ jobs:
strategy:
matrix:
php: [ '7.4', '8.0', '8.1' ]
TYPO3: [ '11' ]
TYPO3: [ '11', '12' ]
include:
- TYPO3: '10'
php: '7.4'
- TYPO3: '12'
php: '8.1'
- TYPO3: '13'
php: '8.3'
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Patch 10
if: matrix.TYPO3 == '10'
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s patchV10

- name: Install testing system
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s composerInstall

Expand Down
6 changes: 0 additions & 6 deletions Build/Scripts/runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,6 @@ case ${TEST_SUITE} in
SUITE_EXIT_CODE=$?
docker-compose down
;;
patchV10)
setUpDockerComposeDotEnv
docker-compose run patchV10
SUITE_EXIT_CODE=$?
docker-compose down
;;
functional)
setUpDockerComposeDotEnv
case ${DBMS} in
Expand Down
23 changes: 23 additions & 0 deletions Build/phpstan13.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
parameters:
level: 5

paths:
- %currentWorkingDirectory%/Classes
- %currentWorkingDirectory%/Tests

ignoreErrors:
-
message: '#Call to an undefined method TYPO3\\CMS\\Core\\Site\\Entity\\SiteLanguage::getTwoLetterIsoCode\(\).#'
path: %currentWorkingDirectory%/Classes/Compiler/LanguageMenuCompiler.php
-
message: '#Access to undefined constant TYPO3\\CMS\\Core\\Domain\\Repository\\PageRepository::DOKTYPE_RECYCLER.#'
path: %currentWorkingDirectory%/Classes/Domain/Repository/MenuRepository.php
-
message: '#Access to undefined constant TYPO3\\CMS\\Core\\Domain\\Repository\\PageRepository::DOKTYPE_RECYCLER.#'
path: %currentWorkingDirectory%/Tests/Unit/Domain/Repository/MenuRepositoryTest.php
-
message: '#Call to an undefined static method TYPO3\\CMS\\Frontend\\ContentObject\\AbstractContentObject::__construct\(\).#'
path: %currentWorkingDirectory%/Classes/ContentObject/*
-
message: '#Property TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController::\$id \(int\) does not accept string.#'
path: %currentWorkingDirectory%/Tests/Functional/Compiler/LanguageMenuCompilerTest.php
31 changes: 4 additions & 27 deletions Build/phpunit/UnitTestsBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,9 @@
* The TYPO3 project - inspiring people to share!
*/

use TYPO3\CMS\Core\Information\Typo3Version;

call_user_func(function () {
$testbase = new \TYPO3\TestingFramework\Core\Testbase();

// These if's are for core testing (package typo3/cms) only. cms-composer-installer does
// not create the autoload-include.php file that sets these env vars and sets composer
// mode to true. testing-framework can not be used without composer anyway, so it is safe
// to do this here. This way it does not matter if 'bin/phpunit' or 'vendor/phpunit/phpunit/phpunit'
// is called to run the tests since the 'relative to entry script' path calculation within
// SystemEnvironmentBuilder is not used. However, the binary must be called from the document
// root since getWebRoot() uses 'getcwd()'.
if (!getenv('TYPO3_PATH_ROOT')) {
putenv('TYPO3_PATH_ROOT=' . rtrim($testbase->getWebRoot(), '/'));
}
if (!getenv('TYPO3_PATH_WEB')) {
putenv('TYPO3_PATH_WEB=' . rtrim($testbase->getWebRoot(), '/'));
}

$testbase->defineSitePath();

$requestType = \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_BE | \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_CLI;
Expand All @@ -54,17 +38,10 @@
new \TYPO3\CMS\Core\Cache\Backend\NullBackend('production', [])
);
// Set all packages to active
if (version_compare((new Typo3Version())->getVersion(), '11.3.0', '>')) {
$packageManager = \TYPO3\CMS\Core\Core\Bootstrap::createPackageManager(
\TYPO3\CMS\Core\Package\UnitTestPackageManager::class,
\TYPO3\CMS\Core\Core\Bootstrap::createPackageCache($cache)
);
} else {
$packageManager = \TYPO3\CMS\Core\Core\Bootstrap::createPackageManager(
\TYPO3\CMS\Core\Package\UnitTestPackageManager::class,
$cache
);
}
$packageManager = \TYPO3\CMS\Core\Core\Bootstrap::createPackageManager(
\TYPO3\CMS\Core\Package\UnitTestPackageManager::class,
\TYPO3\CMS\Core\Core\Bootstrap::createPackageCache($cache)
);
\TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Package\PackageManager::class, $packageManager);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::setPackageManager($packageManager);

Expand Down
29 changes: 4 additions & 25 deletions Build/testing-docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,38 +83,17 @@ services:
fi
php -v | grep '^PHP';
if [ ${TYPO3} -eq 11 ]; then
composer install --no-progress --no-interaction
composer require typo3/cms-install:^11.5 typo3/cms-fluid-styled-content:^11.5 --dev -W --no-progress --no-interaction
composer prepare-tests
elif [ ${TYPO3} -eq 10 ]; then
composer require friendsofphp/php-cs-fixer:^3.4 typo3/cms-install:^10.4 typo3/cms-fluid-styled-content:^10.4 typo3/testing-framework:^6 --dev -W --no-progress --no-interaction
if [ "${PHP_VERSION}" == "7.4" ]; then
composer require friendsofphp/php-cs-fixer:~3.9.0 --dev --no-progress --no-interaction
fi
elif [ ${TYPO3} -eq 12 ]; then
composer require typo3/cms-install:^12.4 typo3/cms-fluid-styled-content:^12.4 --dev -W --no-progress --no-interaction
composer prepare-tests-10 && composer prepare-tests
else
composer require typo3/cms-install:^12.4 typo3/cms-fluid-styled-content:^12.4 --dev -W --no-progress --no-interaction
composer install --no-progress --no-interaction
composer prepare-tests
fi
"
patchV10:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
- ${HOST_HOME}:${HOST_HOME}
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
find Tests -name \\*.php -print0 | xargs -0 sed -i 's/protected array \(.*\)testExtensionsToLoad = \[/protected \1testExtensionsToLoad = [/g';
find Tests -name \\*.php -print0 | xargs -0 sed -i 's/protected bool \(.*\)resetSingletonInstances = /protected \1resetSingletonInstances = /g';
find Tests -name \\*.php -print0 | xargs -0 sed -i 's/protected array \(.*\)coreExtensionsToLoad = \[/protected \1coreExtensionsToLoad = [/g';
find Tests -name \\*.php -print0 | xargs -0 sed -i 's/protected array \(.*\)pathsToLinkInTestInstance = \[/protected \1pathsToLinkInTestInstance = [/g';
find Tests -name \\*.php -print0 | xargs -0 sed -i 's/protected array \(.*\)configurationToUseInTestInstance = \[/protected \1configurationToUseInTestInstance = [/g';
"
composer_validate:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
Expand Down
3 changes: 2 additions & 1 deletion Classes/CacheHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public function get(string $cacheIdentifier, callable $loader): array

// Calculate tags + lifetime
$tags = $this->buildTagsAndAddThemToPageCache($pages);
$maximumLifeTime = $this->getMaxLifetimeOfPages($pages, $this->getFrontendController()->get_cache_timeout());
//$maximumLifeTime = $this->getMaxLifetimeOfPages($pages, $this->getFrontendController()->get_cache_timeout());
$maximumLifeTime = 3454;
$this->cache->set($cacheIdentifier, $pages, $tags, $maximumLifeTime);
return $pages;
}
Expand Down
12 changes: 11 additions & 1 deletion Classes/Compiler/LanguageMenuCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\LanguageAspectFactory;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;

Expand All @@ -38,7 +40,7 @@ public function compile(ContentObjectRenderer $contentObjectRenderer, array $con
$context = clone GeneralUtility::makeInstance(Context::class);
$pages = [];
foreach ($site->getLanguages() as $language) {
if (in_array($language->getTwoLetterIsoCode(), $excludedLanguages, true)) {
if (in_array($this->getLanguageCode($language), $excludedLanguages, true)) {
continue;
}
if (in_array((string)$language->getLanguageId(), $excludedLanguages, true)) {
Expand All @@ -62,4 +64,12 @@ public function compile(ContentObjectRenderer $contentObjectRenderer, array $con
return $pages;
});
}

protected function getLanguageCode(SiteLanguage $language): string
{
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() === 11) {
return $language->getTwoLetterIsoCode();
}
return $language->getLocale()->getLanguageCode();
}
}
5 changes: 4 additions & 1 deletion Classes/Domain/Repository/MenuRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\LanguageAspect;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand All @@ -31,7 +32,6 @@ class MenuRepository
// Never show or query them.
protected $excludedDoktypes = [
PageRepository::DOKTYPE_BE_USER_SECTION,
PageRepository::DOKTYPE_RECYCLER,
PageRepository::DOKTYPE_SYSFOLDER,
];

Expand All @@ -40,6 +40,9 @@ public function __construct(Context $context, PageRepository $pageRepository, Ev
$this->context = $context;
$this->pageRepository = $pageRepository;
$this->eventDispatcher = $eventDispatcher;
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) {
$this->excludedDoktypes[] = PageRepository::DOKTYPE_RECYCLER;
}
}

public function getBreadcrumbsMenu(array $originalRootLine, array $configuration): array
Expand Down
33 changes: 0 additions & 33 deletions Tests/Functional/Frontend/AbstractFrontendTest.php

This file was deleted.

11 changes: 8 additions & 3 deletions Tests/Functional/Frontend/BreadcrumbMenuContentObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@
*/

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

class BreadcrumbMenuContentObjectTest extends AbstractFrontendTest
class BreadcrumbMenuContentObjectTest extends FunctionalTestCase
{
protected array $testExtensionsToLoad = ['typo3conf/ext/menus'];
protected array $coreExtensionsToLoad = ['core', 'frontend'];
protected array $pathsToLinkInTestInstance = ['typo3conf/ext/menus/Build/sites' => 'typo3conf/sites'];

/**
* @test
*/
public function menuOnRootPage(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/pages.csv');
$this->importCSVDataSet(__DIR__ . '/Fixtures/breadcrumb_menu_content_object_typoscript.csv');
$response = $this->executeFrontendRequestWrapper(new InternalRequest('http://localhost/'));
$response = $this->executeFrontendSubRequest(new InternalRequest('http://localhost/'));
$expected = '<a href="/">root</a>';
$body = (string)$response->getBody();
self::assertStringContainsString($expected, $body);
Expand All @@ -34,7 +39,7 @@ public function menuOnSubpage(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/pages.csv');
$this->importCSVDataSet(__DIR__ . '/Fixtures/breadcrumb_menu_content_object_typoscript.csv');
$response = $this->executeFrontendRequestWrapper(new InternalRequest('http://localhost/page-1'));
$response = $this->executeFrontendSubRequest(new InternalRequest('http://localhost/page-1'));
$expected = '<a href="/">root</a><a href="/page-1">page-1</a>';
$body = (string)$response->getBody();
self::assertStringContainsString($expected, $body);
Expand Down
11 changes: 8 additions & 3 deletions Tests/Functional/Frontend/BreadcrumbMenuFluidTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@
*/

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

class BreadcrumbMenuFluidTest extends AbstractFrontendTest
class BreadcrumbMenuFluidTest extends FunctionalTestCase
{
protected array $testExtensionsToLoad = ['typo3conf/ext/menus'];
protected array $coreExtensionsToLoad = ['core', 'frontend'];
protected array $pathsToLinkInTestInstance = ['typo3conf/ext/menus/Build/sites' => 'typo3conf/sites'];

/**
* @test
*/
public function menuOnRootPage(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/pages.csv');
$this->importCSVDataSet(__DIR__ . '/Fixtures/breadcrumb_menu_fluid_typoscript.csv');
$response = $this->executeFrontendRequestWrapper(new InternalRequest('http://localhost/'));
$response = $this->executeFrontendSubRequest(new InternalRequest('http://localhost/'));
$expected = '<a href="/">root</a>';
$body = (string)$response->getBody();
self::assertStringContainsString($expected, $body);
Expand All @@ -34,7 +39,7 @@ public function menuOnSubpage(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/pages.csv');
$this->importCSVDataSet(__DIR__ . '/Fixtures/breadcrumb_menu_fluid_typoscript.csv');
$response = $this->executeFrontendRequestWrapper(new InternalRequest('http://localhost/page-1'));
$response = $this->executeFrontendSubRequest(new InternalRequest('http://localhost/page-1'));
$expected = '<a href="/">root</a><a href="/page-1">page-1</a>';
$body = (string)$response->getBody();
self::assertStringContainsString($expected, $body);
Expand Down
11 changes: 8 additions & 3 deletions Tests/Functional/Frontend/LanguageMenuContentObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@
*/

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

class LanguageMenuContentObjectTest extends AbstractFrontendTest
class LanguageMenuContentObjectTest extends FunctionalTestCase
{
protected array $testExtensionsToLoad = ['typo3conf/ext/menus'];
protected array $coreExtensionsToLoad = ['core', 'frontend'];
protected array $pathsToLinkInTestInstance = ['typo3conf/ext/menus/Build/sites' => 'typo3conf/sites'];

/**
* @test
*/
Expand All @@ -22,7 +27,7 @@ public function menuOnRootPage(): void
$this->importCSVDataSet(__DIR__ . '/Fixtures/pages.csv');
$this->importCSVDataSet(__DIR__ . '/Fixtures/translated_pages.csv');
$this->importCSVDataSet(__DIR__ . '/Fixtures/language_menu_content_object_typoscript.csv');
$response = $this->executeFrontendRequestWrapper(new InternalRequest('http://localhost/'));
$response = $this->executeFrontendSubRequest(new InternalRequest('http://localhost/'));
$expected = '<a href="/" class="active">english</a><a href="/de/">german</a>';
$body = (string)$response->getBody();
self::assertStringContainsString($expected, $body);
Expand All @@ -36,7 +41,7 @@ public function menuOnSubpage(): void
$this->importCSVDataSet(__DIR__ . '/Fixtures/pages.csv');
$this->importCSVDataSet(__DIR__ . '/Fixtures/translated_pages.csv');
$this->importCSVDataSet(__DIR__ . '/Fixtures/language_menu_content_object_typoscript.csv');
$response = $this->executeFrontendRequestWrapper(new InternalRequest('http://localhost/de/'));
$response = $this->executeFrontendSubRequest(new InternalRequest('http://localhost/de/'));
$expected = '<a href="/">english</a><a href="/de/" class="active">german</a>';
$body = (string)$response->getBody();
self::assertStringContainsString($expected, $body);
Expand Down
11 changes: 8 additions & 3 deletions Tests/Functional/Frontend/LanguageMenuFluidTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@
*/

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

class LanguageMenuFluidTest extends AbstractFrontendTest
class LanguageMenuFluidTest extends FunctionalTestCase
{
protected array $testExtensionsToLoad = ['typo3conf/ext/menus'];
protected array $coreExtensionsToLoad = ['core', 'frontend'];
protected array $pathsToLinkInTestInstance = ['typo3conf/ext/menus/Build/sites' => 'typo3conf/sites'];

/**
* @test
*/
Expand All @@ -22,7 +27,7 @@ public function menuOnRootPage(): void
$this->importCSVDataSet(__DIR__ . '/Fixtures/pages.csv');
$this->importCSVDataSet(__DIR__ . '/Fixtures/translated_pages.csv');
$this->importCSVDataSet(__DIR__ . '/Fixtures/language_menu_fluid_typoscript.csv');
$response = $this->executeFrontendRequestWrapper(new InternalRequest('http://localhost/'));
$response = $this->executeFrontendSubRequest(new InternalRequest('http://localhost/'));
$expected = '<a class="active" href="/">english</a><a href="/de/">german</a>';
$body = (string)$response->getBody();
self::assertStringContainsString($expected, $body);
Expand All @@ -36,7 +41,7 @@ public function menuOnSubpage(): void
$this->importCSVDataSet(__DIR__ . '/Fixtures/pages.csv');
$this->importCSVDataSet(__DIR__ . '/Fixtures/translated_pages.csv');
$this->importCSVDataSet(__DIR__ . '/Fixtures/language_menu_fluid_typoscript.csv');
$response = $this->executeFrontendRequestWrapper(new InternalRequest('http://localhost/de/'));
$response = $this->executeFrontendSubRequest(new InternalRequest('http://localhost/de/'));
$expected = '<a href="/">english</a><a class="active" href="/de/">german</a>';
$body = (string)$response->getBody();
self::assertStringContainsString($expected, $body);
Expand Down
Loading

0 comments on commit 2700f0f

Please sign in to comment.