From 149c7929aa7a4d4127ffd72d72efffad715a56df Mon Sep 17 00:00:00 2001 From: Alexander Stehlik Date: Mon, 4 Nov 2019 21:34:09 +0100 Subject: [PATCH] [TASK] Make tests compatible with TYPO3 8 --- .travis.yml | 8 +-- ...heOptimizerDataHandlerGridelementsTest.php | 20 ++++---- .../CacheOptimizerDataHandlerTest.php | 19 +++---- .../Functional/CacheOptimizerTestAbstract.php | 50 ++++++++++++++----- .../Database/menu_content/typo3_7.xml | 35 +++++++++++++ .../Database/menu_content/typo3_8.xml | 33 ++++++++++++ .../Fixtures/Database/tt_content.xml | 32 ------------ composer.json | 11 +++- ext_emconf.php | 2 +- 9 files changed, 141 insertions(+), 69 deletions(-) create mode 100644 Tests/Functional/Fixtures/Database/menu_content/typo3_7.xml create mode 100644 Tests/Functional/Fixtures/Database/menu_content/typo3_8.xml diff --git a/.travis.yml b/.travis.yml index 59c6902..7aea6ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,10 @@ matrix: env: TYPO3_VERSION=^7.6 - php: 7.1 env: TYPO3_VERSION=^7.6 + - php: 7.2 + env: TYPO3_VERSION=^8.7 + - php: 7.3 + env: TYPO3_VERSION=^8.7 cache: directories: @@ -30,10 +34,8 @@ before_install: before_script: # First we install all required packages as dist versions. - - composer require typo3/cms=$TYPO3_VERSION --prefer-dist + - composer require typo3/cms=$TYPO3_VERSION --prefer-dist - export TYPO3_PATH_WEB="$PWD/.Build/Web" - - mkdir -p $TYPO3_PATH_WEB/typo3conf/ext - - ln -s $PWD $TYPO3_PATH_WEB/typo3conf/ext/cacheopt script: - > diff --git a/Tests/Functional/CacheOptimizerDataHandlerGridelementsTest.php b/Tests/Functional/CacheOptimizerDataHandlerGridelementsTest.php index e5162ab..999af95 100644 --- a/Tests/Functional/CacheOptimizerDataHandlerGridelementsTest.php +++ b/Tests/Functional/CacheOptimizerDataHandlerGridelementsTest.php @@ -1,15 +1,16 @@ getDatabaseConnection()->selectSingleRow( - 'cf_cache_pages.id', - 'cf_cache_pages, cf_cache_pages_tags', - 'cf_cache_pages.identifier=cf_cache_pages_tags.identifier AND tag=\'pageId_' . $pageUid . '\'' + $tagRow = $this->getDatabaseConnection()->selectSingleRow( + 'identifier', + 'cf_cache_pages_tags', + 'tag=\'pageId_' . $pageUid . '\'' ); - if (!$row) { + if (!$tagRow) { return []; } - return [$row]; + $cacheRow = $this->getDatabaseConnection()->selectSingleRow( + 'id', + 'cf_cache_pages', + 'cf_cache_pages.identifier=\'pageId_' . $tagRow['identifier'] . '\'' + ); + + if (!$cacheRow) { + return []; + } + + return [$cacheRow]; } /** @@ -228,10 +237,7 @@ protected function getPageCacheRecords($pageUid) protected function loadDatabaseFixtures() { $fixtureDir = ORIGINAL_ROOT . 'typo3conf/ext/cacheopt/Tests/Functional/Fixtures/Database/'; - $iteratorMode = FilesystemIterator::UNIX_PATHS - | FilesystemIterator::SKIP_DOTS - | FilesystemIterator::CURRENT_AS_FILEINFO; - $iterator = new RecursiveDirectoryIterator($fixtureDir, $iteratorMode); + $iterator = new DirectoryIterator($fixtureDir); while ($iterator->valid()) { /** @var $entry SplFileInfo */ @@ -244,6 +250,16 @@ protected function loadDatabaseFixtures() $this->importDataSet($entry->getPathname()); $iterator->next(); } + + $versionSuffix = 7; + if ($this->isTypo3Version8()) { + $versionSuffix = 8; + } + + $filename = sprintf('typo3_%d.xml', $versionSuffix); + $this->importDataSet( + ORIGINAL_ROOT . 'typo3conf/ext/cacheopt/Tests/Functional/Fixtures/Database/menu_content/' . $filename + ); } /** @@ -257,4 +273,12 @@ private function createDataHandler() } return $dataHandler; } + + /** + * @return bool + */ + private function isTypo3Version8() + { + return VersionNumberUtility::convertVersionNumberToInteger(TYPO3_branch) >= 8000000; + } } diff --git a/Tests/Functional/Fixtures/Database/menu_content/typo3_7.xml b/Tests/Functional/Fixtures/Database/menu_content/typo3_7.xml new file mode 100644 index 0000000..7bfe6ee --- /dev/null +++ b/Tests/Functional/Fixtures/Database/menu_content/typo3_7.xml @@ -0,0 +1,35 @@ + + + + 91 + 133 + 1401292114 + 1401292114 + 1 + 256 + menu +
menu
+ 0 + 0 + 132,139 + 0 + 1 + +
+ + 97 + 139 + 1401292114 + 1401292114 + 1 + 256 + menu +
menu
+ 0 + 0 + 132 + 0 + 1 + +
+
diff --git a/Tests/Functional/Fixtures/Database/menu_content/typo3_8.xml b/Tests/Functional/Fixtures/Database/menu_content/typo3_8.xml new file mode 100644 index 0000000..c56cc81 --- /dev/null +++ b/Tests/Functional/Fixtures/Database/menu_content/typo3_8.xml @@ -0,0 +1,33 @@ + + + + 91 + 133 + 1401292114 + 1401292114 + 1 + 256 + menu_pages +
menu
+ 0 + 0 + 132,139 + 1 + +
+ + 97 + 139 + 1401292114 + 1401292114 + 1 + 256 + menu_pages +
menu
+ 0 + 0 + 132 + 1 + +
+
diff --git a/Tests/Functional/Fixtures/Database/tt_content.xml b/Tests/Functional/Fixtures/Database/tt_content.xml index e88c80e..b71bc1f 100644 --- a/Tests/Functional/Fixtures/Database/tt_content.xml +++ b/Tests/Functional/Fixtures/Database/tt_content.xml @@ -42,22 +42,6 @@ 1 - - 91 - 133 - 1401292114 - 1401292114 - 1 - 256 - menu -
menu
- 0 - 0 - 132,139 - 0 - 1 - -
92 134 @@ -125,20 +109,4 @@ 1 - - 97 - 139 - 1401292114 - 1401292114 - 1 - 256 - menu -
menu
- 0 - 0 - 132 - 0 - 1 - -
diff --git a/composer.json b/composer.json index ed1a0a4..0ff19dc 100644 --- a/composer.json +++ b/composer.json @@ -13,13 +13,14 @@ "license": "GPL-3.0+", "require": { "php": ">=5.6", - "typo3/cms-core": "^6.2 || ^7.6" + "typo3/cms-core": "^6.2 || ^7.6 || ^8.7", + "typo3/cms": "^6.2" }, "require-dev": { "typo3-ter/gridelements": "*", "squizlabs/php_codesniffer": "^3.1", "de-swebhosting/php-codestyle": "dev-master", - "nimut/testing-framework": "^2.0" + "nimut/testing-framework": "^2.0 || ^4.1" }, "autoload": { "psr-4": { @@ -40,6 +41,12 @@ "vendor-dir": ".Build/vendor", "bin-dir": ".Build/bin" }, + "scripts": { + "post-autoload-dump": [ + "mkdir -p .Build/Web/typo3conf/ext/", + "[ -L .Build/Web/typo3conf/ext/cacheopt ] || ln -snvf ../../../../. .Build/Web/typo3conf/ext/cacheopt" + ] + }, "extra": { "typo3/cms": { "cms-package-dir": "{$vendor-dir}/typo3/cms", diff --git a/ext_emconf.php b/ext_emconf.php index e426046..1f10ec2 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -13,7 +13,7 @@ 'author_email' => 'astehlik.deleteme@intera.de', 'author_company' => 'Intera GmbH', 'constraints' => [ - 'depends' => ['typo3' => '6.2.1-7.6.99'], + 'depends' => ['typo3' => '6.2.1-8.7.99'], 'conflicts' => [], 'suggests' => [], ],