Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Optimize test setup #1382

Merged
merged 1 commit into from
Jun 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ tools:
php_cs_fixer:
enabled: false

php_hhvm:
enabled: true
config:
use_undeclared_constant: false

php_mess_detector:
enabled: true
config:
Expand Down
19 changes: 5 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ php:

jdk:
- oraclejdk8
- mysql-5.6

addons:
apt:
Expand All @@ -23,8 +22,9 @@ env:
- TYPO3_DATABASE_HOST="127.0.0.1"
- TYPO3_DATABASE_USERNAME="root"
- TYPO3_DATABASE_PASSWORD=""
- PHP_CS_FIXER_VERSION="v2.3.2"
matrix:
- TYPO3_VERSION="~8.7.0"
- TYPO3_VERSION="^8.7"
- TYPO3_VERSION="8.x-dev"

matrix:
Expand All @@ -33,30 +33,21 @@ matrix:
before_install:
- composer self-update
- composer --version
- composer global require friendsofphp/php-cs-fixer:v2.3.2
- composer global require namelesscoder/typo3-repository-client

# set root password
- mysql -u root -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('')"

# resources for solr
- sudo update-java-alternatives -s java-8-oracle

install:
- Build/Test/bootstrap.sh

script:
# test extension
- Build/Test/cibuild.sh

# test docker file
- Build/Test/cibuild_docker.sh

after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.unit.clover
- php ocular.phar code-coverage:upload --format=php-clover coverage.integration.clover
- Build/Test/publish_coverage.sh
- Build/Test/cleanup.sh
- Build/Release/ter_tag_uploader.sh

cache:
directories:
- $HOME/.composer/cache
Expand Down
8 changes: 6 additions & 2 deletions Build/Test/IntegrationTests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="true"
stopOnError="false"
stopOnFailure="false"
stopOnError="true"
stopOnFailure="true"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false">
Expand All @@ -22,4 +22,8 @@
<directory suffix=".php">../../Classes/</directory>
</whitelist>
</filter>

<logging>
<log type="coverage-clover" target="coverage.integration.clover"/>
</logging>
</phpunit>
7 changes: 5 additions & 2 deletions Build/Test/UnitTests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
convertWarningsToExceptions="false"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnError="true"
stopOnFailure="true"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false">
Expand All @@ -22,4 +22,7 @@
<directory suffix=".php">../../Classes/</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="coverage.unit.clover"/>
</logging>
</phpunit>
18 changes: 13 additions & 5 deletions Build/Test/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ EXTENSION_ROOTPATH="$SCRIPTPATH/../../"
SOLR_INSTALL_PATH="/opt/solr-tomcat/"

if [[ $* == *--local* ]]; then
echo -n "Choose a TYPO3 Version (e.g. dev-master,~8.7.0): "
echo -n "Choose a TYPO3 Version (e.g. dev-master,^8.7): "
read typo3Version
export TYPO3_VERSION=$typo3Version

Expand All @@ -24,10 +24,14 @@ if [[ $* == *--local* ]]; then
echo -n "Choose a database password: "
read typo3DbPassword
export TYPO3_DATABASE_PASSWORD=$typo3DbPassword

echo -n "Choose a php-cs-fixer version (v2.3.2): "
read phpCSFixerVersion
export PHP_CS_FIXER_VERSION=$phpCSFixerVersion
fi

if [ -z $TYPO3_VERSION ]; then
echo "Must set env var TYPO3_VERSION (e.g. dev-master or ~8.7.0)"
echo "Must set env var TYPO3_VERSION (e.g. dev-master or ^8.7)"
exit 1
fi

Expand All @@ -37,19 +41,23 @@ if [ $? -ne "0" ]; then
exit 1
fi

# Install build tools
composer global require friendsofphp/php-cs-fixer:"$PHP_CS_FIXER_VERSION"
composer global require scrutinizer/ocular:"1.3.1"
composer global require namelesscoder/typo3-repository-client

# Setup TYPO3 environment variables
export TYPO3_PATH_PACKAGES="${EXTENSION_ROOTPATH}.Build/vendor/"
export TYPO3_PATH_WEB="${EXTENSION_ROOTPATH}.Build/Web/"

echo "Using extension path $EXTENSION_ROOTPATH"
echo "Using package path $TYPO3_PATH_PACKAGES"
echo "Using web path $TYPO3_PATH_WEB"

# Install TYPO3 sources
composer require --dev typo3/cms="$TYPO3_VERSION"
composer require --dev --prefer-source typo3/testing-framework="1.0.1"

# Restore composer.json
git checkout composer.json

mkdir -p $TYPO3_PATH_WEB/uploads $TYPO3_PATH_WEB/typo3temp

# Setup Solr Using our install script
Expand Down
23 changes: 9 additions & 14 deletions Build/Test/cibuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ echo "PWD: $(pwd)"
export TYPO3_PATH_WEB="$(pwd)/.Build/Web/"
export TYPO3_PATH_PACKAGES="$(pwd)/.Build/vendor/"

if [ $TRAVIS ]; then
# Travis does not have composer's bin dir in $PATH
export PATH="$PATH:$HOME/.composer/vendor/bin"
fi
export TYPO3_BIN_DIR="$(pwd)/.Build/bin/"
export COMPOSER_BIN_DIR="$HOME/.composer/vendor/bin"

ls -l .Build/bin/
# Add TYPO3_BIN_DIR and COMPOSER_BIN_DIR to $PATH
export PATH="$TYPO3_BIN_DIR:$COMPOSER_BIN_DIR:$PATH"

echo "Run PHP Lint"
find . -name \*.php ! -path "./.Build/*" | parallel --gnu php -d display_errors=stderr -l {} > /dev/null \;
Expand All @@ -29,18 +28,14 @@ if [ $? -eq "0" ]; then
fi


UNIT_BOOTSTRAP=".Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php"

echo "Run unit tests"
.Build/bin/phpunit --colors -c Build/Test/UnitTests.xml --coverage-clover=coverage.unit.clover --bootstrap=$UNIT_BOOTSTRAP
UNIT_BOOTSTRAP=".Build/vendor/nimut/testing-framework/res/Configuration/UnitTestsBootstrap.php"
.Build/bin/phpunit --colors -c Build/Test/UnitTests.xml --bootstrap=$UNIT_BOOTSTRAP
if [ $? -ne "0" ]; then
echo "Error during running the unit tests please check and fix them"
exit 1
fi


echo "Run integration tests"

#
# Map the travis and shell variable names to the expected
# casing of the TYPO3 core.
Expand Down Expand Up @@ -73,6 +68,6 @@ else
exit 1
fi

INTEGRATION_BOOTSTRAP=".Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"

.Build/bin/phpunit --colors -c Build/Test/IntegrationTests.xml --coverage-clover=coverage.integration.clover --bootstrap=$INTEGRATION_BOOTSTRAP
echo "Run integration tests"
INTEGRATION_BOOTSTRAP=".Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTestsBootstrap.php"
.Build/bin/phpunit --colors -c Build/Test/IntegrationTests.xml --bootstrap=$INTEGRATION_BOOTSTRAP
11 changes: 11 additions & 0 deletions Build/Test/publish_coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -e

export TYPO3_BIN_DIR="$(pwd)/.Build/bin/"
export COMPOSER_BIN_DIR="$HOME/.composer/vendor/bin"

# Add TYPO3_BIN_DIR and COMPOSER_BIN_DIR to $PATH
export PATH="$TYPO3_BIN_DIR:$COMPOSER_BIN_DIR:$PATH"

ocular code-coverage:upload --format=php-clover coverage.unit.clover
ocular code-coverage:upload --format=php-clover coverage.functional.clover
Original file line number Diff line number Diff line change
Expand Up @@ -469,15 +469,15 @@
<uid>1</uid>
<pid>2</pid>
<CType>text</CType>
<bodytext>Our awesome new sock products prices starting at 10</bodytext>
<bodytext>Our awesome new sock products prices starting at 10 euro</bodytext>
<colPos>0</colPos>
</tt_content>

<tt_content>
<uid>2</uid>
<pid>3</pid>
<CType>text</CType>
<bodytext>Our awesome men jeans products prices starting at 50</bodytext>
<bodytext>Our awesome men jeans products prices starting at 50 euro</bodytext>
<colPos>0</colPos>
</tt_content>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,15 +482,15 @@
<uid>1</uid>
<pid>2</pid>
<CType>text</CType>
<bodytext>Our awesome new sock products prices starting at 10</bodytext>
<bodytext>Our awesome new sock products prices starting at 10 euro</bodytext>
<colPos>0</colPos>
</tt_content>

<tt_content>
<uid>2</uid>
<pid>3</pid>
<CType>text</CType>
<bodytext>Our awesome men jeans products prices starting at 50</bodytext>
<bodytext>Our awesome men jeans products prices starting at 50 euro</bodytext>
<colPos>0</colPos>
</tt_content>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,15 +519,15 @@
<uid>1</uid>
<pid>2</pid>
<CType>text</CType>
<bodytext>Our awesome new sock products prices starting at 10</bodytext>
<bodytext>Our awesome new sock products prices starting at 10 euro</bodytext>
<colPos>0</colPos>
</tt_content>

<tt_content>
<uid>2</uid>
<pid>3</pid>
<CType>text</CType>
<bodytext>Our awesome men jeans products prices starting at 50</bodytext>
<bodytext>Our awesome men jeans products prices starting at 50 euro</bodytext>
<colPos>0</colPos>
</tt_content>

Expand Down
4 changes: 2 additions & 2 deletions Tests/Integration/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase as TYPO3IntegrationTest;
use Nimut\TestingFramework\TestCase\FunctionalTestCase;
use TYPO3\CMS\Core\TimeTracker\TimeTracker;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
Expand All @@ -47,7 +47,7 @@
*
* @author Timo Schmidt
*/
abstract class IntegrationTest extends TYPO3IntegrationTest
abstract class IntegrationTest extends FunctionalTestCase
{

/**
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/UnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use \TYPO3\TestingFramework\Core\Unit\UnitTestCase as TYPO3UnitTest;
use Nimut\TestingFramework\TestCase\UnitTestCase;

/**
* Base class for all unit tests in the solr project
*
* @author Timo Schmidt
*/
abstract class UnitTest extends TYPO3UnitTest
abstract class UnitTest extends UnitTestCase
{

/**
Expand Down
8 changes: 3 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"typo3/cms": ">=8.7.0"
},
"require-dev": {
"phpunit/phpunit": ">=4.8.0 <6.0.0"
"phpunit/phpunit": "^5.6",
"nimut/testing-framework": "^1.1"
},
"replace": {
"solr": "self.version",
Expand All @@ -42,10 +43,7 @@
},
"autoload-dev": {
"psr-4": {
"ApacheSolrForTypo3\\Solr\\Tests\\": "Tests/",
"TYPO3\\CMS\\Core\\Tests\\": ".Build/vendor/typo3/cms/typo3/sysext/core/Tests/",
"TYPO3\\CMS\\Components\\TestingFramework\\Core\\": ".Build/vendor/typo3/cms/components/testing_framework/core/",
"TYPO3\\CMS\\Components\\TestingFramework\\Fluid\\": ".Build/vendor/typo3/cms/components/testing_framework/fluid/"
"ApacheSolrForTypo3\\Solr\\Tests\\": "Tests/"
}
},
"config": {
Expand Down