mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #1661 from sminnee/simpler-test-run
Simplify the test run so as to not need a regular SS project structure
This commit is contained in:
commit
062c8205c1
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1,5 +1,6 @@
|
||||
docs/ export-ignore
|
||||
javascript/src/ export ignore
|
||||
behat.yml export ignore
|
||||
|
||||
# Hide diffs
|
||||
javascript/dist/ -diff
|
||||
|
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,5 +1,12 @@
|
||||
.sass-cache
|
||||
.DS_Store
|
||||
node_modules
|
||||
framework
|
||||
siteconfig
|
||||
reports
|
||||
testsession
|
||||
silverstripe-cache
|
||||
vendor
|
||||
/**/*.js.map
|
||||
/**/*.css.map
|
||||
|
||||
|
26
.travis.yml
26
.travis.yml
@ -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/
|
||||
|
@ -9,8 +9,12 @@ use SilverStripe\Assets\File;
|
||||
* - CMS_DIR: Path relative to webroot, e.g. "cms"
|
||||
* - CMS_PATH: Absolute filepath, e.g. "/var/www/my-webroot/cms"
|
||||
*/
|
||||
define('CMS_DIR', 'cms');
|
||||
define('CMS_PATH', BASE_PATH . '/' . CMS_DIR);
|
||||
define('CMS_PATH', realpath(__DIR__));
|
||||
if(strpos(CMS_PATH, BASE_PATH) === 0) {
|
||||
define('CMS_DIR', trim(substr(CMS_PATH, strlen(BASE_PATH)), '/'));
|
||||
} else {
|
||||
throw new Exception("Path error: CMS_PATH " . CMS_PATH . " not within BASE_PATH " . BASE_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the default internal shortcodes.
|
||||
|
@ -2,11 +2,15 @@ default:
|
||||
context:
|
||||
class: SilverStripe\Cms\Test\Behaviour\FeatureContext
|
||||
extensions:
|
||||
SilverStripe\BehatExtension\Extension: ~
|
||||
SilverStripe\BehatExtension\Extension:
|
||||
framework_path: framework
|
||||
bootstrap_file: "tests/behat/serve-bootstrap.php"
|
||||
Behat\MinkExtension\Extension:
|
||||
# Adjust this to your local environment
|
||||
base_url: http://localhost/
|
||||
files_path: %behat.paths.features%/files/
|
||||
# Designed to run using the below
|
||||
# `vendor/bin/serve --bootstrap-file tests/behat/serve-bootstrap.php`
|
||||
# `vendor/bin/selenium-server-standalone -Dwebdriver.firefox.bin="/Applications/Firefox31.app/Contents/MacOS/firefox-bin"`
|
||||
base_url: http://localhost:8080/
|
||||
files_path: %behat.paths.base%/framework/tests/behat/features/files/
|
||||
default_session: selenium2
|
||||
javascript_session: selenium2
|
||||
selenium2:
|
@ -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
44
phpunit.xml.dist
Normal 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>
|
BIN
tests/behat/features/files/document.pdf
Normal file
BIN
tests/behat/features/files/document.pdf
Normal file
Binary file not shown.
BIN
tests/behat/features/files/file1.jpg
Normal file
BIN
tests/behat/features/files/file1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
tests/behat/features/files/file2.jpg
Normal file
BIN
tests/behat/features/files/file2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
BIN
tests/behat/features/files/testfile.jpg
Normal file
BIN
tests/behat/features/files/testfile.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
@ -72,18 +72,3 @@ Feature: Insert an image into a page
|
||||
And the "Content" HTML field should contain "My alt"
|
||||
# Required to avoid "unsaved changed" browser dialog
|
||||
Then I press the "Save draft" button
|
||||
|
||||
# TODO This needs to support using drag handles, as we no longer have 'Width' or 'Height' input fields
|
||||
@todo
|
||||
Scenario: I can edit dimensions of an existing image
|
||||
Given the "page" "About us" contains "<img src=assets/folder1/3d0ef6ec37/file1.jpg>"
|
||||
And I reload the current page
|
||||
When I highlight "<img src=assets/folder1/3d0ef6ec37/file1.jpg>" in the "Content" HTML field
|
||||
And I press the "Insert Media" HTML field button
|
||||
Then I should see "file1.jpg"
|
||||
When I fill in "Width" with "10"
|
||||
When I fill in "Height" with "20"
|
||||
And I press the "Insert" button
|
||||
Then the "Content" HTML field should contain "<img src=assets/folder1/3d0ef6ec37/file1.jpg width=10 height=20>"
|
||||
# Required to avoid "unsaved changed" browser dialog
|
||||
Then I press the "Save draft" button
|
||||
|
7
tests/behat/serve-bootstrap.php
Normal file
7
tests/behat/serve-bootstrap.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../bootstrap/init.php';
|
||||
require FRAMEWORK_PATH . '/tests/bootstrap/init.php';
|
||||
require FRAMEWORK_PATH . '/tests/bootstrap/environment.php';
|
||||
require __DIR__ . '/../bootstrap/mysite.php';
|
||||
require FRAMEWORK_PATH . '/tests/bootstrap/mysite.php';
|
10
tests/bootstrap.php
Normal file
10
tests/bootstrap.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/bootstrap/init.php';
|
||||
require FRAMEWORK_PATH . '/tests/bootstrap/init.php';
|
||||
require FRAMEWORK_PATH . '/tests/bootstrap/cli.php';
|
||||
require FRAMEWORK_PATH . '/tests/bootstrap/environment.php';
|
||||
require __DIR__ . '/bootstrap/mysite.php';
|
||||
require FRAMEWORK_PATH . '/tests/bootstrap/mysite.php';
|
||||
require FRAMEWORK_PATH . '/tests/bootstrap/phpunit.php';
|
||||
|
12
tests/bootstrap/fixtures/Page.php.fixture
Normal file
12
tests/bootstrap/fixtures/Page.php.fixture
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\CMS\Controllers\ContentController;
|
||||
|
||||
class Page extends SiteTree
|
||||
{
|
||||
}
|
||||
|
||||
class Page_Controller extends ContentController
|
||||
{
|
||||
}
|
0
tests/bootstrap/fixtures/_manifest_exclude
Normal file
0
tests/bootstrap/fixtures/_manifest_exclude
Normal file
12
tests/bootstrap/init.php
Normal file
12
tests/bootstrap/init.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
if(!defined('FRAMEWORK_PATH')) {
|
||||
echo "FRAMEWORK_PATH hasn't been defined. This probably means that framework/Core/Constants.php hasn't been " .
|
||||
"included by Composer's autoloader.\n" .
|
||||
"Make sure the you are running your tests via vendor/bin/phpunit and your autoloader is up to date.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (empty($_SERVER['HTTP_HOST'])) {
|
||||
$_SERVER['HTTP_HOST'] = 'localhost';
|
||||
}
|
14
tests/bootstrap/mysite.php
Normal file
14
tests/bootstrap/mysite.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
// Mock mysite if not installed with silverstripe/installer
|
||||
if (defined('BASE_PATH')) {
|
||||
$projectPath = BASE_PATH . '/mysite';
|
||||
} else {
|
||||
$projectPath = getcwd() . '/mysite';
|
||||
}
|
||||
if (!is_dir($projectPath)) {
|
||||
mkdir($projectPath, 02775);
|
||||
mkdir($projectPath.'/code', 02775);
|
||||
mkdir($projectPath.'/_config', 02775);
|
||||
copy(__DIR__.'/fixtures/Page.php.fixture', $projectPath . '/code/Page.php');
|
||||
}
|
@ -15,7 +15,7 @@ use SilverStripe\Dev\TestOnly;
|
||||
|
||||
class SilverStripeNavigatorTest extends SapphireTest {
|
||||
|
||||
protected static $fixture_file = 'cms/tests/controller/CMSMainTest.yml';
|
||||
protected static $fixture_file = 'CMSMainTest.yml';
|
||||
|
||||
public function testGetItems() {
|
||||
$page = $this->objFromFixture('Page', 'page1');
|
||||
|
@ -13,6 +13,12 @@ class RedirectorPageTest extends FunctionalTest {
|
||||
protected static $use_draft_site = true;
|
||||
protected $autoFollowRedirection = false;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
Director::config()->update('alternate_base_url', 'http://www.mysite.com/');
|
||||
}
|
||||
|
||||
public function testGoodRedirectors() {
|
||||
/* For good redirectors, the final destination URL will be returned */
|
||||
$this->assertEquals("http://www.google.com", $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage','goodexternal')->Link());
|
||||
|
Loading…
Reference in New Issue
Block a user