From 81087ce15c6c6c94d482903820b63cdc1e7c397c Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Mon, 31 Oct 2016 15:07:22 +1300 Subject: [PATCH 1/5] BUG restore CMS build as required in framework tests --- .travis.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d1f4429f..22cc5cb47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,11 +32,6 @@ matrix: env: DB=MYSQL CMS_TEST=1 PHPUNIT_TEST=1 - php: 5.6 env: DB=MYSQL CMS_TEST=1 BEHAT_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 before_script: - printf "\n" | pecl install imagick @@ -50,6 +45,7 @@ before_script: - "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 [ \"$CMS_TEST\" = \"1\" ]; then php ./cms/tests/bootstrap/mysite.php; fi" - "if [ \"$NPM_TEST\" = \"1\" ] && [ `git log --format=format:%aE -1` = \"support@greenkeeper.io\" ]; then echo \"Removing npm-shrinkwrap.json\"; rm npm-shrinkwrap.json; fi" - "if [ \"$NPM_TEST\" = \"1\" ]; then nvm install $TRAVIS_NODE_VERSION && npm install; fi" - "if [ \"$BEHAT_TEST\" = \"1\" ]; then sh -e /etc/init.d/xvfb start; sleep 3; fi" @@ -60,7 +56,7 @@ 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 --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 [ \"$BEHAT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"1\" ]; then vendor/bin/behat @cms --config tests/behat/config.yml; fi" - "if [ \"$NPM_TEST\" = \"1\" ]; then npm run test; fi" - "if [ \"$NPM_TEST\" = \"1\" ]; then npm run lint; fi" - "if [ \"$NPM_TEST\" = \"1\" ]; then npm run build; fi" From 38fdafb474e8204077849e83267ee3308b701afe Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Tue, 1 Nov 2016 17:40:59 +1300 Subject: [PATCH 2/5] Fix tinymce breaking in non-typical install location --- src/Forms/HTMLEditor/TinyMCEConfig.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Forms/HTMLEditor/TinyMCEConfig.php b/src/Forms/HTMLEditor/TinyMCEConfig.php index 7f7940d07..e041c8705 100644 --- a/src/Forms/HTMLEditor/TinyMCEConfig.php +++ b/src/Forms/HTMLEditor/TinyMCEConfig.php @@ -21,10 +21,12 @@ class TinyMCEConfig extends HTMLEditorConfig { * - themes * - skins * + * If left blank defaults to ADMIN_THIRDPARTY_DIR . '/tinymce' + * * @config * @var string */ - private static $base_dir = 'framework/admin/thirdparty/tinymce'; + private static $base_dir = null; /** * TinyMCE JS settings @@ -366,7 +368,7 @@ class TinyMCEConfig extends HTMLEditorConfig { // https://www.tinymce.com/docs/api/class/tinymce.editormanager/#baseURL $tinyMCEBaseURL = Controller::join_links( Director::absoluteBaseURL(), - $this->config()->base_dir + $this->config()->get('base_dir') ?: ADMIN_THIRDPARTY_DIR . '/tinymce' ); $settings['baseURL'] = $tinyMCEBaseURL; From c0c219e178c13b2a6978656995014ead759403ca Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Tue, 1 Nov 2016 17:55:43 +1300 Subject: [PATCH 3/5] Fix invalid files_path --- tests/behat/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/behat/config.yml b/tests/behat/config.yml index 434f13af8..a19a0fa0d 100644 --- a/tests/behat/config.yml +++ b/tests/behat/config.yml @@ -11,7 +11,7 @@ default: extensions: SilverStripe\BehatExtension\MinkExtension: base_url: http://localhost:8080/ - files_path: %behat.paths.base%/tests/behat/features/files/ + files_path: %behat.paths.base%/features/files/ default_session: selenium2 javascript_session: selenium2 selenium2: From 6da36a9ed102080a3b6957b86f7554492b5a6129 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Wed, 2 Nov 2016 09:11:35 +1300 Subject: [PATCH 4/5] Fix some issues with tests --- tests/bootstrap/init.php | 4 ++++ tests/forms/HTMLEditorConfigTest.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/bootstrap/init.php b/tests/bootstrap/init.php index be75f5a90..59f0ed636 100644 --- a/tests/bootstrap/init.php +++ b/tests/bootstrap/init.php @@ -19,3 +19,7 @@ ini_set('display_errors', 1); if(!file_exists(BASE_PATH . '/assets')) { mkdir(BASE_PATH . '/assets', 02775); } + +if (empty($_SERVER['HTTP_HOST'])) { + $_SERVER['HTTP_HOST'] = 'localhost'; +} diff --git a/tests/forms/HTMLEditorConfigTest.php b/tests/forms/HTMLEditorConfigTest.php index 3cffa50be..156534c5f 100644 --- a/tests/forms/HTMLEditorConfigTest.php +++ b/tests/forms/HTMLEditorConfigTest.php @@ -76,7 +76,7 @@ class HTMLEditorConfigTest extends SapphireTest { // Plugin specified with standard location $this->assertContains('plugin4', array_keys($plugins)); $this->assertEquals( - 'http://mysite.com/subdir/framework/admin/thirdparty/tinymce/plugins/plugin4/plugin.min.js', + 'http://mysite.com/subdir/'.ADMIN_THIRDPARTY_DIR.'/tinymce/plugins/plugin4/plugin.min.js', $plugins['plugin4'] ); From d7cb38434e43c0cd3057ce5d77af052a35aa8a17 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Wed, 2 Nov 2016 10:54:09 +1300 Subject: [PATCH 5/5] Create separate cms-config.yml for cms behat tests within framework --- .travis.yml | 2 +- tests/behat/cms-config.yml | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/behat/cms-config.yml diff --git a/.travis.yml b/.travis.yml index 22cc5cb47..62541d457 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,7 +56,7 @@ 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 --config tests/behat/config.yml .; fi" - - "if [ \"$BEHAT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"1\" ]; then vendor/bin/behat @cms --config tests/behat/config.yml; fi" + - "if [ \"$BEHAT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"1\" ]; then vendor/bin/behat @cms --config tests/behat/cms-config.yml; fi" - "if [ \"$NPM_TEST\" = \"1\" ]; then npm run test; fi" - "if [ \"$NPM_TEST\" = \"1\" ]; then npm run lint; fi" - "if [ \"$NPM_TEST\" = \"1\" ]; then npm run build; fi" diff --git a/tests/behat/cms-config.yml b/tests/behat/cms-config.yml new file mode 100644 index 000000000..e65be9705 --- /dev/null +++ b/tests/behat/cms-config.yml @@ -0,0 +1,22 @@ +# Required to run cms tests as subdirectory within framework module +default: + context: + class: SilverStripe\Cms\Test\Behaviour\FeatureContext + formatter: + name: pretty + parameters: + snippets: false + + extensions: + SilverStripe\BehatExtension\MinkExtension: + base_url: http://localhost:8080/ + files_path: %behat.paths.base%/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: "cms/tests/behat/serve-bootstrap.php"