NEW: Simplified travis run

Travis no longer relies on travis-support or special project structures.
Instead, behat and silverstripe-serve are provided as dev dependencies
and used within a normal composer install structure.

tests/fixtures/Page.php should be copied into the project root before
a test run. .travis.yml does this.
This commit is contained in:
Sam Minnee 2016-10-25 11:56:30 +13:00
parent a8cb4a516f
commit added2129f
4 changed files with 75 additions and 16 deletions

7
.gitignore vendored
View File

@ -1,5 +1,12 @@
.sass-cache
.DS_Store
node_modules
framework
siteconfig
reports
testsession
silverstripe-cache
vendor
/**/*.js.map
/**/*.css.map

View File

@ -30,7 +30,7 @@ matrix:
- php: 5.6
env: DB=MYSQL PDO=1 PHPUNIT_TEST=1
- php: 5.6
env: DB=MYSQL BEHAT_TEST=1 PHPUNIT_TEST=1
env: DB=MYSQL BEHAT_TEST=1
- php: 5.6
env: NPM_TEST=1
- php: 7.0
@ -40,18 +40,22 @@ 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 [ \"$BEHAT_TEST\" = \"\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss; fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require 'silverstripe/behat-extension:~2.0-dev'; fi"
- cd ~/builds/ss
- php ~/travis-support/travis_setup_selenium.php --if-env BEHAT_TEST
- php ~/travis-support/travis_setup_php54_webserver.php --if-env BEHAT_TEST
- "if [ \"$NPM_TEST\" = \"1\" ]; then (cd cms && nvm install $TRAVIS_NODE_VERSION && npm install --silent); fi"
- composer install --prefer-dist
- "if [ \"$DB\" = \"PGSQL\" ]; then composer require silverstripe/postgresql:2.0.x-dev --prefer-dist; fi"
- "if [ \"$DB\" = \"SQLITE\" ]; then composer require silverstripe/sqlite3:2.0.x-dev --prefer-dist; fi"
- "php ./tests/bootstrap/mysite.php"
- "export DISPLAY=\":99\""
- "export XVFBARGS=\":99 -ac -screen 0 1024x768x16\""
- "export COMPOSER_ROOT_VERSION=4.0.x-dev"
- "if [ \"$NPM_TEST\" = \"1\" ]; then (nvm install $TRAVIS_NODE_VERSION && npm install --silent); fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then sh -e /etc/init.d/xvfb start; sleep 3; fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then (vendor/bin/selenium-server-standalone > selenium.log 2>&1 &); fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then (vendor/bin/serve --bootstrap-file tests/behat/serve-bootstrap.php &> serve.log &); fi"
script:
- "if [ \"PHPUNIT_TEST\" = \"1\" ]; then vendor/bin/phpunit cms/tests; fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then vendor/bin/behat @cms; fi"
- "if [ \"$NPM_TEST\" = \"1\" ]; then (cd cms && nvm use 4 && npm run lint); fi"
- "if [ \"$PHPUNIT_TEST\" = \"1\" ]; then vendor/bin/phpunit tests flush=1; fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then vendor/bin/behat .; fi"
- "if [ \"$NPM_TEST\" = \"1\" ]; then (nvm use 4 && npm run lint); fi"
after_failure:
- php ~/travis-support/travis_upload_artifacts.php --if-env BEHAT_TEST,ARTIFACTS_BUCKET,ARTIFACTS_KEY,ARTIFACTS_SECRET --target-path $TRAVIS_REPO_SLUG/$TRAVIS_BUILD_ID/$TRAVIS_JOB_ID --artifacts-base-url https://s3.amazonaws.com/$ARTIFACTS_BUCKET/

View File

@ -18,12 +18,16 @@
"require": {
"php": ">=5.5.0",
"composer/installers": "*",
"silverstripe/framework": "^4.0",
"silverstripe/reports": "^4.0",
"silverstripe/siteconfig": "^4.0"
"silverstripe/framework": "^4.0@dev",
"silverstripe/reports": "^4.0@dev",
"silverstripe/siteconfig": "^4.0@dev"
},
"require-dev": {
"phpunit/PHPUnit": "~4.8"
"phpunit/PHPUnit": "~4.8",
"silverstripe/behat-extension": "^2.1.0",
"silverstripe/serve": "dev-master",
"silverstripe/testsession": "^2.0.0-alpha3",
"se/selenium-server-standalone": "2.41.0"
},
"extra": {
"branch-alias": {
@ -36,5 +40,5 @@
},
"classmap": ["tests/behat/"]
},
"minimum-stability": "dev"
"minimum-stability": "stable"
}

44
phpunit.xml.dist Normal file
View File

@ -0,0 +1,44 @@
<!--
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>
</testsuite>
<listeners>
<listener class="SilverStripe\Dev\TestListener" />
</listeners>
<groups>
<exclude>
<group>sanitychecks</group>
</exclude>
</groups>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">.</directory>
<exclude>
<directory suffix=".php">tests/</directory>
</exclude>
</whitelist>
</filter>
</phpunit>