mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
NEW: Don’t set up SilverStripe project for test run
The SilverStripe project structure complicates the travis test run, and the goal of this branch is to prevent it from being necessary. - Unit tests can be run simply with PHPUnit. - Behat test can be run with the silverstripe/serve module Note that initially this commit doesn’t cater to the behat tests. As part of this, we allow dev packages to be installed when testing These settings don’t affect projects that use framework, only when framework’s composer install / require calls are used themselves. Since SS4 is pre-stable, these are important. They can probably be removed once SS4 stable (and stable versions of support packages) have been released.
This commit is contained in:
parent
6b640f81f2
commit
9dd5ebee8c
3
.gitignore
vendored
3
.gitignore
vendored
@ -10,3 +10,6 @@ node_modules/
|
||||
coverage/
|
||||
/**/*.js.map
|
||||
/**/*.css.map
|
||||
vendor/
|
||||
composer.lock
|
||||
silverstripe-cache/
|
||||
|
19
.travis.yml
19
.travis.yml
@ -10,8 +10,6 @@ addons:
|
||||
env:
|
||||
global:
|
||||
- TRAVIS_NODE_VERSION="4"
|
||||
- CORE_RELEASE=master
|
||||
- CORE_RELEASE_VERSION=4.0
|
||||
- ARTIFACTS_REGION=us-east-1
|
||||
- ARTIFACTS_BUCKET=silverstripe-travis-artifacts
|
||||
- secure: "jVR0iLTuvVfA6jKX5+A3AdUEs8Ps+r3SbL0zGR687K8IoSp3a/+JLH12zFCEexOuxwCtOhlMq8zoZsptCEduCDq+0payk5k6GjNVywFaWjJCV573JScdaHAtoumoHMUvua+Pxds0qKAD2XEYAcOR4Qu7S4HLJV6E1QqHg9PRW5s=" # Encrypted ARTIFACTS_KEY
|
||||
@ -44,21 +42,16 @@ before_script:
|
||||
- composer self-update || true
|
||||
- phpenv rehash
|
||||
- phpenv config-rm xdebug.ini
|
||||
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
|
||||
- "if [ \"$PHPUNIT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss; fi"
|
||||
- "if [ \"$BEHAT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require silverstripe/behat-extension; fi"
|
||||
- "if [ \"$PHPUNIT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"1\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require silverstripe/cms:$CORE_RELEASE_VERSION.x-dev; fi"
|
||||
- "if [ \"$BEHAT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"1\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require silverstripe/behat-extension,silverstripe/cms:$CORE_RELEASE_VERSION.x-dev; fi"
|
||||
- "if [ \"$PHPUNIT_TEST\" = \"1\" ]; then composer install; fi"
|
||||
- "if [ \"$DB\" = \"PGSQL\" ]; then composer require silverstripe/postgresql:^2.0; fi"
|
||||
- "if [ \"$DB\" = \"SQLITE\" ]; then composer require silverstripe/sqlite3:^2.0; fi"
|
||||
- "if [ \"$NPM_TEST\" = \"1\" ]; then nvm install $TRAVIS_NODE_VERSION && npm install; fi"
|
||||
- "if [ \"$NPM_TEST\" = \"\" ]; then cd ~/builds/ss; fi"
|
||||
- "if [ \"$NPM_TEST\" = \"\" ] && [ \"$BEHAT_TEST\" = \"1\" ]; then php ~/travis-support/travis_setup_selenium.php; fi"
|
||||
- "if [ \"$NPM_TEST\" = \"\" ] && [ \"$BEHAT_TEST\" = \"1\" ]; then php ~/travis-support/travis_setup_php54_webserver.php; fi"
|
||||
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then php ~/travis-support/travis_setup_selenium.php; fi"
|
||||
|
||||
script:
|
||||
- "if [ \"$PHPUNIT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"\" ]; then vendor/bin/phpunit framework/tests; fi"
|
||||
- "if [ \"$PHPUNIT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"\" ]; then vendor/bin/phpunit framework/admin/tests; fi"
|
||||
- "if [ \"$BEHAT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"\" ]; then vendor/bin/behat @framework; fi"
|
||||
- "if [ \"$PHPUNIT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"\" ]; then vendor/bin/phpunit; fi"
|
||||
- "if [ \"$PHPUNIT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"1\" ]; then vendor/bin/phpunit cms/tests; fi"
|
||||
- "if [ \"$BEHAT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"\" ]; then vendor/bin/behat @framework; fi"
|
||||
- "if [ \"$BEHAT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"1\" ]; then vendor/bin/behat @cms; fi"
|
||||
- "if [ \"$NPM_TEST\" = \"1\" ]; then npm run test; fi"
|
||||
|
||||
|
@ -54,5 +54,7 @@
|
||||
"include-path": [
|
||||
"thirdparty/",
|
||||
"thirdparty/HTML_BBCodeParser2/"
|
||||
]
|
||||
],
|
||||
"min-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
|
35
phpunit.xml.dist
Normal file
35
phpunit.xml.dist
Normal file
@ -0,0 +1,35 @@
|
||||
<!--
|
||||
PHPUnit configuration for SilverStripe
|
||||
|
||||
Requires PHPUnit 3.5+
|
||||
|
||||
Usage:
|
||||
- "phpunit": Runs all tests in all folders
|
||||
- "phpunit framework/tests/": Run all tests of the framework module
|
||||
- "phpunit framework/tests/filesystem": Run all filesystem tests within the framework module
|
||||
- "phpunit framework/tests/filesystem/FolderTest.php": Run a single test
|
||||
- "phpunit <dash><dash>coverage-html assets/": Generate coverage report (replace <dash> with "-", requires xdebug)
|
||||
|
||||
More information:
|
||||
- http://www.phpunit.de/manual/current/en/textui.html
|
||||
- http://doc.silverstripe.org/framework/en/topics/testing/#configuration
|
||||
|
||||
It is safe to remove this file for normal website operation.
|
||||
-->
|
||||
<phpunit bootstrap="tests/bootstrap.php" colors="true">
|
||||
|
||||
<testsuite name="Default">
|
||||
<directory>tests</directory>
|
||||
<directory>admin/tests</directory>
|
||||
</testsuite>
|
||||
|
||||
<listeners>
|
||||
<listener class="SilverStripe\Dev\TestListener" />
|
||||
</listeners>
|
||||
|
||||
<groups>
|
||||
<exclude>
|
||||
<group>sanitychecks</group>
|
||||
</exclude>
|
||||
</groups>
|
||||
</phpunit>
|
@ -21,8 +21,6 @@ $frameworkDir = basename($frameworkPath);
|
||||
$_SERVER['SCRIPT_FILENAME'] = $frameworkPath . DIRECTORY_SEPARATOR . 'cli-script.php';
|
||||
$_SERVER['SCRIPT_NAME'] = '.' . DIRECTORY_SEPARATOR . $frameworkDir . DIRECTORY_SEPARATOR . 'cli-script.php';
|
||||
|
||||
if(!defined('BASE_PATH')) define('BASE_PATH', dirname($frameworkPath));
|
||||
|
||||
// Copied from cli-script.php, to enable same behaviour through phpunit runner.
|
||||
if(isset($_SERVER['argv'][2])) {
|
||||
$args = array_slice($_SERVER['argv'],2);
|
||||
@ -40,6 +38,53 @@ if(isset($_SERVER['argv'][2])) {
|
||||
$_REQUEST = array_merge($_REQUEST, $_GET);
|
||||
}
|
||||
|
||||
// DATABASE BOOTSTRAP
|
||||
|
||||
if (!defined('SS_ENVIRONMENT_TYPE')) {
|
||||
define('SS_ENVIRONMENT_TYPE', 'dev');
|
||||
}
|
||||
|
||||
if (!defined('SS_DATABASE_CLASS') && !defined('SS_DATABASE_USERNAME')) {
|
||||
// The default settings let us define the database config via environment vars
|
||||
// Database connection, including PDO and legacy ORM support
|
||||
switch(getenv('DB')) {
|
||||
case "PGSQL";
|
||||
define('SS_DATABASE_CLASS', getenv('PDO') ? 'PostgrePDODatabase' : 'PostgreSQLDatabase');
|
||||
define('SS_DATABASE_USERNAME', 'postgres');
|
||||
define('SS_DATABASE_PASSWORD', '');
|
||||
break;
|
||||
|
||||
case "SQLITE":
|
||||
define('SS_DATABASE_CLASS', getenv('PDO') ? 'SQLite3PDODatabase' : 'SQLite3Database');
|
||||
define('SS_DATABASE_USERNAME', 'root');
|
||||
define('SS_DATABASE_PASSWORD', '');
|
||||
define('SS_SQLITE_DATABASE_PATH', ':memory:');
|
||||
break;
|
||||
|
||||
default:
|
||||
define('SS_DATABASE_CLASS', getenv('PDO') ? 'MySQLPDODatabase' : 'MySQLDatabase');
|
||||
define('SS_DATABASE_USERNAME', 'root');
|
||||
define('SS_DATABASE_PASSWORD', '');
|
||||
}
|
||||
|
||||
define('SS_DATABASE_SERVER', '127.0.0.1');
|
||||
define('SS_DATABASE_CHOOSE_NAME', true);
|
||||
}
|
||||
|
||||
// Ensure Director::protocolAndHost() works
|
||||
if (empty($_SERVER['HTTP_HOST'])) {
|
||||
$_SERVER['HTTP_HOST'] = 'localhost';
|
||||
}
|
||||
|
||||
// Default database settings
|
||||
global $project;
|
||||
$project = 'mysite';
|
||||
|
||||
global $database;
|
||||
$database = '';
|
||||
|
||||
require_once(__DIR__ . '/../conf/ConfigureFromEnv.php');
|
||||
|
||||
// Connect to database
|
||||
require_once $frameworkPath . '/Core/Core.php';
|
||||
require_once $frameworkPath . '/tests/FakeController.php';
|
||||
|
Loading…
Reference in New Issue
Block a user