Skip to content

Commit

Permalink
[TASK] Update tests
Browse files Browse the repository at this point in the history
- Use nimut testing framework.
- Rename tests to be auto discoverable by phpunit.
- Fix minor bugs in test extension in Fixtures folder.
- Adapt travis and scrutinizer configurations.
- Update README to include travis and scrutinizer links.
  • Loading branch information
chetan-thapliyal committed Jan 9, 2018
1 parent ab4c1de commit 7da262e
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 44 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Build files
.Build
24 changes: 23 additions & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,26 @@ filter:
tools:
external_code_coverage:
timeout: 700
runs: 1
runs: 1
php_cpd:
enabled: true
php_code_sniffer:
enabled: true
config:
standard: TYPO3CMS
php_cs_fixer:
enabled: true
php_hhvm:
enabled: true
config:
use_undeclared_constant: false
php_mess_detector:
enabled: true
config:
controversial_rules:
superglobals: false
php_pdepend:
enabled: true
php_analyzer:
enabled: true
sensiolabs_security_checker: true
63 changes: 47 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,80 @@
language: php

php:
- 5.3
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2

env:
- TYPO3_VERSION=^7.6 COVERAGE=1 FUNCTIONAL=1
- TYPO3_VERSION=^6.2 COVERAGE=1 FUNCTIONAL=1
- TYPO3_VERSION=^7.6 COVERAGE=0 FUNCTIONAL=0
- TYPO3_VERSION=^8.7 COVERAGE=0 FUNCTIONAL=0
- TYPO3_VERSION=dev-master COVERAGE=0 FUNCTIONAL=0

matrix:
exclude:
- env: TYPO3_VERSION=^6.2
php: 7.0
- env: TYPO3_VERSION=^6.2
php: 7.1
- env: TYPO3_VERSION=^6.2
- env: TYPO3_VERSION=dev-master COVERAGE=0 FUNCTIONAL=0
php: 5.5
- env: TYPO3_VERSION=dev-master COVERAGE=0 FUNCTIONAL=0
php: 5.6
- env: TYPO3_VERSION=^8.7 COVERAGE=0 FUNCTIONAL=0
php: 5.5
- env: TYPO3_VERSION=^6.2
- env: TYPO3_VERSION=^8.7 COVERAGE=0 FUNCTIONAL=0
php: 5.6
- env: TYPO3_VERSION=^7.6
php: 5.3
include:
- env: TYPO3_VERSION=^7.6 COVERAGE=1 FUNCTIONAL=1
php: 7.1
- env: TYPO3_VERSION=^8.7 COVERAGE=0 FUNCTIONAL=1
php: 7.1
- env: TYPO3_VERSION=dev-master COVERAGE=0 FUNCTIONAL=1
php: 7.1
allow_failures:
- env: TYPO3_VERSION=dev-master COVERAGE=0 FUNCTIONAL=1
- env: TYPO3_VERSION=dev-master COVERAGE=0 FUNCTIONAL=0
- php: 7.2

notifications:
email:
# recipients:
# - [email protected]
on_success: never
on_failure: never

sudo: false

addons:
apt:
packages:
- parallel

cache:
directories:
- $HOME/.composer/cache

before_install:
- composer self-update
- composer --version

before_script:
# Installs TYPO3
- composer require --dev typo3/cms=$TYPO3_VERSION;
- export "TYPO3_PATH_WEB"=$PWD/.Build/Web;
# Restore composer.json
- git checkout composer.json;
- export "TYPO3_PATH_WEB"=$PWD/.Build/Web;
# Locating UnitTests.xml
- export "UNIT_XML"='.Build/vendor/nimut/testing-framework/res/Configuration/UnitTests.xml'
# Location FunctionalTests.xml
- export "FUNCTIONAL_XML"='.Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTests.xml'

script:
# Execute unit tests
- >
echo "Running unit tests";
if [[ "$COVERAGE" == "1" ]]; then
.Build/bin/phpunit --coverage-clover=ut-coverage.clover --colors -c Tests/phpunit.xml
.Build/bin/phpunit --whitelist Classes/ --coverage-clover=ut-coverage.clover --colors -c $UNIT_XML Tests/Unit
else
.Build/bin/phpunit --colors -c Tests/phpunit.xml
.Build/bin/phpunit --colors -c $UNIT_XML Tests/Unit
fi
# Execute functional tests, if enabled
Expand All @@ -60,9 +87,9 @@ script:
export typo3DatabasePassword="";
if [[ "$COVERAGE" == "1" ]]; then
.Build/bin/phpunit --coverage-clover=ft-coverage.clover --colors -c Tests/functional.xml
.Build/bin/phpunit --whitelist Classes/ --coverage-clover=ft-coverage.clover --colors -c $FUNCTIONAL_XML Tests/Functional
else
.Build/bin/phpunit -c Tests/functional.xml
.Build/bin/phpunit --colors -c $FUNCTIONAL_XML Tests/Functional
fi
fi
Expand All @@ -73,3 +100,7 @@ script:
wget https://scrutinizer-ci.com/ocular.phar
find . -wholename '*-coverage.clover' -o -name '*-coverage.clover' | xargs -i php ocular.phar code-coverage:upload --format=php-clover {}
fi
- >
echo "Running php lint";
find . -name \*.php ! -path "./.Build/*" | parallel --gnu php -d display_errors=stderr -l {} > /dev/null \;
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ TYPO3 dispatcher for database related operations.

## Build information
[![Build Status](https://travis-ci.org/AOEpeople/t3deploy.svg?branch=master)](https://travis-ci.org/AOEpeople/t3deploy)
[![Code Coverage](https://scrutinizer-ci.com/g/AOEpeople/t3deploy/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/AOEpeople/t3deploy/?branch=master)

## Usage

Expand Down
16 changes: 8 additions & 8 deletions Tests/Fixtures/testextension/ext_tables.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
CREATE TABLE tx_testextension (
id int(11) NOT NULL auto_increment,
identifier varchar(250) NOT NULL default '',
tag varchar(250) NOT NULL default '',
PRIMARY KEY (`id`),
KEY `cache_id` (`identifier`)
KEY `cache_tag` (`tag`)
id int(11) NOT NULL auto_increment,
identifier varchar(250) NOT NULL default '',
tag varchar(250) NOT NULL default '',
PRIMARY KEY (`id`),
KEY `cache_id` (`identifier`),
KEY `cache_tag` (`tag`)
) ENGINE=InnoDB;

CREATE TABLE pages (
tx_testextension_field varchar(64) NOT NULL default '',
alias varchar(33) NOT NULL default ''
tx_testextension_field varchar(64) NOT NULL default '',
alias varchar(33) NOT NULL default ''
);
16 changes: 8 additions & 8 deletions Tests/Fixtures/testextension/ext_tables_fixture.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
CREATE TABLE pages (
tx_testextension_field_test varchar(64) NOT NULL default '',
alias varchar(255) NOT NULL default ''
tx_testextension_field_test varchar(64) NOT NULL default '',
alias varchar(255) NOT NULL default ''
);

CREATE TABLE tx_testextension_test (
id int(11) NOT NULL auto_increment,
identifier varchar(250) NOT NULL default '',
tag varchar(250) NOT NULL default '',
PRIMARY KEY (`id`),
KEY `cache_id` (`identifier`)
KEY `cache_tag` (`tag`)
id int(11) NOT NULL auto_increment,
identifier varchar(250) NOT NULL default '',
tag varchar(250) NOT NULL default '',
PRIMARY KEY (`id`),
KEY `cache_id` (`identifier`),
KEY `cache_tag` (`tag`)
) ENGINE=InnoDB;
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
/***************************************************************
* Copyright notice
*
* (c) 2016 AOE GmbH <[email protected]>
* (c) 2018 AOE GmbH <[email protected]>
* All rights reserved
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use TYPO3\CMS\Core\Tests\FunctionalTestCase;
use Nimut\TestingFramework\TestCase\FunctionalTestCase;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand All @@ -17,7 +17,7 @@
* @package t3deploy
* @author Oliver Hader <[email protected]>
*/
class tx_t3deploy_tests_databaseController_testcase extends FunctionalTestCase
class DatabaseControllerTest extends FunctionalTestCase
{
/**
* @var array
Expand Down Expand Up @@ -49,7 +49,7 @@ public function setUp()
);

$expectedSchemaServiceMock->expects($this->any())->method('getTablesDefinitionString')->with(true)->willReturn(
file_get_contents(PATH_tx_t3deploy . 'tests/fixtures/testextension/ext_tables_fixture.sql')
file_get_contents(PATH_tx_t3deploy . 'Tests/Fixtures/testextension/ext_tables_fixture.sql')
);

$this->controller = new tx_t3deploy_databaseController();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
/***************************************************************
* Copyright notice
*
* (c) 2016 AOE GmbH <[email protected]>
* (c) 2018 AOE GmbH <[email protected]>
* All rights reserved
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use TYPO3\CMS\Core\Tests\UnitTestCase;
use Nimut\TestingFramework\TestCase\UnitTestCase;

/**
* Test case for class tx_t3deploy_dispatch.
*
* @package t3deploy
* @author Oliver Hader <[email protected]>
*/
class tx_t3deploy_tests_dispatch_testcase extends UnitTestCase
class DispatchTest extends UnitTestCase
{
const ClassPrefix = 'tx_t3deploy_';
const ClassSuffix = 'Controller';
Expand Down
2 changes: 1 addition & 1 deletion Tests/functional.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">../classes</directory>
<directory suffix=".php">../Classes</directory>
</whitelist>
</filter>
</phpunit>
4 changes: 2 additions & 2 deletions Tests/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
>
<testsuites>
<testsuite name="t3deploy">
<directory suffix="_testcase.php">../tests/Unit/</directory>
<directory suffix="_testcase.php">../Tests/Unit/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">../classes</directory>
<directory suffix=".php">../Classes</directory>
</whitelist>
</filter>
</phpunit>
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
"email": "[email protected]"
}
],
"require": {
"typo3/cms-core": ">=7.6.0,<8.7.99"
},
"require-dev": {
"typo3/cms": "^7.6",
"phpunit/phpunit": "^4.8"
"nimut/testing-framework": "^2.0.0"
},
"replace": {
"t3deploy": "*"
Expand Down

0 comments on commit 7da262e

Please sign in to comment.