TASK: Support tests for TYPO3 CMS 7.6

Check which version to run and switch TYPO3 bootstrapping.
Also allow tests to run with TYPO3 CMS 7.6 again.
This commit is contained in:
Daniel Siepmann 2018-03-13 11:28:40 +01:00
parent 75335e2bc1
commit 16bc22aa44
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
11 changed files with 73 additions and 16 deletions

View file

@ -13,6 +13,7 @@ language: php
php:
- 7.0
- 7.1
- 7.2
env:
global:
@ -24,6 +25,8 @@ env:
- typo3DatabaseHost="127.0.0.1"
- typo3DatabaseUsername="travis"
- typo3DatabasePassword=""
matrix:
- TYPO3_VERSION="~7.6"
matrix:
fast_finish: true

View file

@ -30,7 +30,7 @@ Then setup your system::
git clone git@github.com:codappix/search_core.git \
&& cd search_core \
&& export typo3DatabaseName="searchcoretest76" \
&& export typo3DatabaseName="searchcoretest87" \
&& export TYPO3_VERSION="~8.7" \
&& make install \
&& make unitTests \
@ -41,8 +41,8 @@ If all tests are okay, start your work.
If you are working with multiple TYPO3 versions make sure to export `typo3DatabaseName` and
`TYPO3_VERSION` in your environment like::
export typo3DatabaseName="searchcoretest62"
export TYPO3_VERSION="~6.2"
export typo3DatabaseName="searchcoretest76"
export TYPO3_VERSION="~7.6"
Also run the install command for each version before running any tests. Only this will make sure you
are testing against the actual TYPO3 Version and database scheme.

View file

@ -10,9 +10,18 @@ typo3DatabaseUsername ?= "dev"
typo3DatabasePassword ?= "dev"
typo3DatabaseHost ?= "127.0.0.1"
sourceOrDist=--prefer-dist
ifeq ($(TYPO3_VERSION),~7.6)
sourceOrDist=--prefer-source
endif
.PHONY: install
install: clean
COMPOSER_PROCESS_TIMEOUT=1000 composer require -vv --dev --prefer-dist typo3/cms="$(TYPO3_VERSION)"
if [ $(TYPO3_VERSION) = ~7.6 ]; then \
patch composer.json Tests/InstallPatches/composer.json.patch; \
fi
COMPOSER_PROCESS_TIMEOUT=1000 composer require -vv --dev $(sourceOrDist) typo3/cms="$(TYPO3_VERSION)"
git checkout composer.json
cgl:

View file

@ -0,0 +1,9 @@
<?php
$filePath = '.Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php';
if (getenv('TYPO3_VERSION') === '~7.6') {
$filePath = '.Build/vendor/typo3/cms/typo3/sysext/core/Build/FunctionalTestsBootstrap.php';
}
require_once dirname(dirname(__DIR__)) . '/' . $filePath;

View file

@ -1,8 +1,7 @@
<phpunit
backupGlobals="true"
backupStaticAttributes="false"
bootstrap="../../.Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
bootstrap="Bootstrap.php"
colors="true"
convertErrorsToExceptions="false"
convertWarningsToExceptions="false"

View file

@ -0,0 +1,14 @@
diff --git a/composer.json b/composer.json
index 83e5f47..e9fa296 100644
--- a/composer.json
+++ b/composer.json
@@ -21,8 +21,7 @@
"ruflin/elastica": "~3.2"
},
"require-dev": {
- "phpunit/phpunit": "~6.4.4",
- "typo3/testing-framework": "~1.1.5",
+ "phpunit/phpunit": "~5.7.0",
"squizlabs/php_codesniffer": "~3.1.1"
},
"config": {

9
Tests/Unit/Bootstrap.php Normal file
View file

@ -0,0 +1,9 @@
<?php
$filePath = '.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php';
if (getenv('TYPO3_VERSION') === '~7.6') {
$filePath = '.Build/vendor/typo3/cms/typo3/sysext/core/Build/UnitTestsBootstrap.php';
}
require_once dirname(dirname(__DIR__)) . '/' . $filePath;

View file

@ -1,7 +1,7 @@
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="../../.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php"
bootstrap="Bootstrap.php"
colors="true"
convertErrorsToExceptions="false"

View file

@ -17,7 +17,7 @@
},
"require": {
"php": ">=7.0.0",
"typo3/cms": "~8.7",
"typo3/cms": ">= 7.6.0 < 9.0.0",
"ruflin/elastica": "~3.2"
},
"require-dev": {

View file

@ -7,8 +7,8 @@ $EM_CONF[$_EXTKEY] = [
'clearCacheOnLoad' => 1,
'constraints' => [
'depends' => [
'typo3' => '8.7.0-8.7.99',
'php' => '7.1.0-7.99.99'
'typo3' => '7.6.0-8.7.99',
'php' => '7.0.0-7.2.99'
],
'conflicts' => [],
],
@ -18,7 +18,7 @@ $EM_CONF[$_EXTKEY] = [
],
],
'state' => 'beta',
'version' => '1.0.0',
'version' => '0.0.1',
'author' => 'Daniel Siepmann',
'author_email' => 'coding@daniel-siepmann.de',
];

View file

@ -37,14 +37,28 @@ call_user_func(
]
);
// Register different concrete implementations, depending on current TYPO3 version.
// This way we can provide working implementations for multiple TYPO3 versions.
$container = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class);
if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 8000000) {
$container->registerImplementation(
\Codappix\SearchCore\Compatibility\TypoScriptServiceInterface::class,
\TYPO3\CMS\Core\TypoScript\TypoScriptService::class
);
} else {
$container->registerImplementation(
\Codappix\SearchCore\Compatibility\TypoScriptServiceInterface::class,
\TYPO3\CMS\Extbase\Service\TypoScriptService::class
);
}
// API does make use of object manager, therefore use GLOBALS
$extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey]);
if ($extensionConfiguration === false
|| !isset($extensionConfiguration['disable.']['elasticsearch'])
|| $extensionConfiguration['disable.']['elasticsearch'] !== '1'
) {
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class)
->registerImplementation(
$container->registerImplementation(
\Codappix\SearchCore\Connection\ConnectionInterface::class,
\Codappix\SearchCore\Connection\Elasticsearch::class
);