Skip to content

Commit

Permalink
[TASK] Make tests compatible with TYPO3 8
Browse files Browse the repository at this point in the history
  • Loading branch information
astehlik committed Nov 4, 2019
1 parent fa20c6c commit 149c792
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 69 deletions.
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
- >
Expand Down
20 changes: 11 additions & 9 deletions Tests/Functional/CacheOptimizerDataHandlerGridelementsTest.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
<?php

namespace Tx\Cacheopt\Tests\Functional;

/* *
* This script belongs to the TYPO3 Extension "cacheopt". *
* *
* It is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License, either version 3 of the *
* License, or (at your option) any later version. *
* *
* The TYPO3 project - inspiring people to share! *
* */
/* *
* This script belongs to the TYPO3 Extension "cacheopt". *
* *
* It is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License, either version 3 of the *
* License, or (at your option) any later version. *
* *
* The TYPO3 project - inspiring people to share! *
* */

/**
* Functional tests for the data handler cache optimizer.
*/
class CacheOptimizerDataHandlerGridelementsTest extends CacheOptimizerTestAbstract
{
const CONTENT_UID_REFERENCED = 21111;

const PAGE_UID_REFERENCING_CONTENT = 221;

public function setUp()
Expand Down
19 changes: 10 additions & 9 deletions Tests/Functional/CacheOptimizerDataHandlerTest.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?php

namespace Tx\Cacheopt\Tests\Functional;

/* *
* This script belongs to the TYPO3 Extension "cacheopt". *
* *
* It is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License, either version 3 of the *
* License, or (at your option) any later version. *
* *
* The TYPO3 project - inspiring people to share! *
* */
/* *
* This script belongs to the TYPO3 Extension "cacheopt". *
* *
* It is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License, either version 3 of the *
* License, or (at your option) any later version. *
* *
* The TYPO3 project - inspiring people to share! *
* */

/**
* Functional tests for the data handler cache optimizer.
Expand Down
50 changes: 37 additions & 13 deletions Tests/Functional/CacheOptimizerTestAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@
* The TYPO3 project - inspiring people to share! *
* */

use FilesystemIterator;
use DirectoryIterator;
use Nimut\TestingFramework\TestCase\FunctionalTestCase;
use RecursiveDirectoryIterator;
use RuntimeException;
use SplFileInfo;
use stdClass;
use Tx\Cacheopt\Tests\Functional\Fixtures\NonCacheClearingFrontendController;
use TYPO3\CMS\Core\Charset\CharsetConverter;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\CMS\Lang\LanguageService;

Expand Down Expand Up @@ -209,17 +208,27 @@ protected function fillPageCache($pageUid)
*/
protected function getPageCacheRecords($pageUid)
{
$row = $this->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];
}

/**
Expand All @@ -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 */
Expand All @@ -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
);
}

/**
Expand All @@ -257,4 +273,12 @@ private function createDataHandler()
}
return $dataHandler;
}

/**
* @return bool
*/
private function isTypo3Version8()
{
return VersionNumberUtility::convertVersionNumberToInteger(TYPO3_branch) >= 8000000;
}
}
35 changes: 35 additions & 0 deletions Tests/Functional/Fixtures/Database/menu_content/typo3_7.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<dataset>
<tt_content>
<uid>91</uid>
<pid>133</pid>
<tstamp>1401292114</tstamp>
<crdate>1401292114</crdate>
<cruser_id>1</cruser_id>
<sorting>256</sorting>
<CType>menu</CType>
<header>menu</header>
<media>0</media>
<colPos>0</colPos>
<pages>132,139</pages>
<menu_type>0</menu_type>
<sectionIndex>1</sectionIndex>
<filelink_sorting/>
</tt_content>
<tt_content>
<uid>97</uid>
<pid>139</pid>
<tstamp>1401292114</tstamp>
<crdate>1401292114</crdate>
<cruser_id>1</cruser_id>
<sorting>256</sorting>
<CType>menu</CType>
<header>menu</header>
<media>0</media>
<colPos>0</colPos>
<pages>132</pages>
<menu_type>0</menu_type>
<sectionIndex>1</sectionIndex>
<filelink_sorting/>
</tt_content>
</dataset>
33 changes: 33 additions & 0 deletions Tests/Functional/Fixtures/Database/menu_content/typo3_8.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<dataset>
<tt_content>
<uid>91</uid>
<pid>133</pid>
<tstamp>1401292114</tstamp>
<crdate>1401292114</crdate>
<cruser_id>1</cruser_id>
<sorting>256</sorting>
<CType>menu_pages</CType>
<header>menu</header>
<media>0</media>
<colPos>0</colPos>
<pages>132,139</pages>
<sectionIndex>1</sectionIndex>
<filelink_sorting/>
</tt_content>
<tt_content>
<uid>97</uid>
<pid>139</pid>
<tstamp>1401292114</tstamp>
<crdate>1401292114</crdate>
<cruser_id>1</cruser_id>
<sorting>256</sorting>
<CType>menu_pages</CType>
<header>menu</header>
<media>0</media>
<colPos>0</colPos>
<pages>132</pages>
<sectionIndex>1</sectionIndex>
<filelink_sorting/>
</tt_content>
</dataset>
32 changes: 0 additions & 32 deletions Tests/Functional/Fixtures/Database/tt_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,6 @@
<sectionIndex>1</sectionIndex>
<filelink_sorting/>
</tt_content>
<tt_content>
<uid>91</uid>
<pid>133</pid>
<tstamp>1401292114</tstamp>
<crdate>1401292114</crdate>
<cruser_id>1</cruser_id>
<sorting>256</sorting>
<CType>menu</CType>
<header>menu</header>
<media>0</media>
<colPos>0</colPos>
<pages>132,139</pages>
<menu_type>0</menu_type>
<sectionIndex>1</sectionIndex>
<filelink_sorting/>
</tt_content>
<tt_content>
<uid>92</uid>
<pid>134</pid>
Expand Down Expand Up @@ -125,20 +109,4 @@
<sectionIndex>1</sectionIndex>
<filelink_sorting/>
</tt_content>
<tt_content>
<uid>97</uid>
<pid>139</pid>
<tstamp>1401292114</tstamp>
<crdate>1401292114</crdate>
<cruser_id>1</cruser_id>
<sorting>256</sorting>
<CType>menu</CType>
<header>menu</header>
<media>0</media>
<colPos>0</colPos>
<pages>132</pages>
<menu_type>0</menu_type>
<sectionIndex>1</sectionIndex>
<filelink_sorting/>
</tt_content>
</dataset>
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'author_email' => '[email protected]',
'author_company' => 'Intera GmbH',
'constraints' => [
'depends' => ['typo3' => '6.2.1-7.6.99'],
'depends' => ['typo3' => '6.2.1-8.7.99'],
'conflicts' => [],
'suggests' => [],
],
Expand Down

0 comments on commit 149c792

Please sign in to comment.