diff --git a/.travis.yml b/.travis.yml index 47a763504..326498b9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,13 +27,13 @@ matrix: env: DB=MYSQL PDO=1 PHPUNIT_TEST=1 - php: 5.6 env: DB=MYSQL BEHAT_TEST=1 + - php: 5.6 + env: NPM_TEST=1 + allow_failures: - php: 5.6 env: DB=MYSQL CMS_TEST=1 PHPUNIT_TEST=1 - php: 5.6 env: DB=MYSQL CMS_TEST=1 BEHAT_TEST=1 - - php: 5.6 - env: NPM_TEST=1 - allow_failures: - php: 7.0 env: DB=MYSQL PDO=1 PHPUNIT_TEST=1 @@ -42,17 +42,22 @@ before_script: - composer self-update || true - phpenv rehash - phpenv config-rm xdebug.ini - - "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" + - "export DISPLAY=\":99\"" + - "export XVFBARGS=\":99 -ac -screen 0 1024x768x16\"" + - "if [ \"$na\" = \"\" ]; then composer install --prefer-dist; fi" + - "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" + - "if [ \"$CMS_TEST\" = \"1\" ]; then COMPOSER_ROOT_VERSION=4.0.x-dev composer require silverstripe/cms:4.0.x-dev silverstripe/siteconfig:4.0.x-dev silverstripe/reports:4.0.x-dev --prefer-dist; fi" - "if [ \"$NPM_TEST\" = \"1\" ]; then nvm install $TRAVIS_NODE_VERSION && npm install; fi" - - "if [ \"$BEHAT_TEST\" = \"1\" ]; then php ~/travis-support/travis_setup_selenium.php; 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\" ] && [ \"$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 [ \"$BEHAT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"\" ]; then vendor/bin/behat --config tests/behat/config.yml .; fi" + - "if [ \"$BEHAT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"1\" ]; then vendor/bin/behat @cms --config cms/tests/behat/behat.yml; fi" - "if [ \"$NPM_TEST\" = \"1\" ]; then npm run test; fi" after_failure: diff --git a/composer.json b/composer.json index dd7c5bb01..b55f07134 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,11 @@ "embed/embed": "^2.6" }, "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": { diff --git a/tests/behat/config.yml b/tests/behat/config.yml new file mode 100644 index 000000000..434f13af8 --- /dev/null +++ b/tests/behat/config.yml @@ -0,0 +1,23 @@ +default: + context: + class: SilverStripe\Framework\Test\Behaviour\FeatureContext + filters: + tags: "~@todo" + formatter: + name: pretty + parameters: + snippets: false + + extensions: + SilverStripe\BehatExtension\MinkExtension: + base_url: http://localhost:8080/ + files_path: %behat.paths.base%/tests/behat/features/files/ + default_session: selenium2 + javascript_session: selenium2 + selenium2: + browser: firefox + + SilverStripe\BehatExtension\Extension: + screenshot_path: %behat.paths.base%/artifacts/screenshots + framework_path: "../.." + bootstrap_file: "tests/behat/serve-bootstrap.php" diff --git a/tests/behat/serve-bootstrap.php b/tests/behat/serve-bootstrap.php new file mode 100644 index 000000000..700c813f3 --- /dev/null +++ b/tests/behat/serve-bootstrap.php @@ -0,0 +1,47 @@ +