diff --git a/.travis.yml b/.travis.yml index e94706d0d..70e8be4a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,6 @@ language: php dist: trusty -before_install: - - sudo apt-get update - - sudo apt-get install chromium-chromedriver - cache: directories: - $HOME/.composer/cache/files @@ -14,15 +10,10 @@ addons: apt: packages: - tidy - firefox: "31.0" env: global: - COMPOSER_ROOT_VERSION=4.2.x-dev - - DISPLAY=":99" - - XVFBARGS=":99 -ac -screen 0 1024x768x16" - - SS_BASE_URL="http://localhost:8080/" - - SS_ENVIRONMENT_TYPE="dev" matrix: fast_finish: true @@ -52,18 +43,10 @@ matrix: - DB=MYSQL - PDO=1 - PHPUNIT_TEST=framework - - php: 7.0 - env: - - DB=MYSQL - - BEHAT_TEST=framework - php: 7.0 env: - DB=MYSQL - PHPUNIT_TEST=cms - - php: 7.0 - env: - - DB=MYSQL - - BEHAT_TEST=cms allow_failures: - php: nightly env: @@ -74,7 +57,6 @@ matrix: before_script: # Extra $PATH - export PATH=~/.composer/vendor/bin:$PATH - - export PATH=/usr/lib/chromium-browser/:$PATH # Init PHP - pecl channel-update pecl.php.net @@ -88,26 +70,17 @@ before_script: - if [[ $DB == PGSQL ]]; then composer require silverstripe/postgresql:2.0.x-dev --no-update; fi - if [[ $DB == SQLITE ]]; then composer require silverstripe/sqlite3:2.0.x-dev --no-update; fi - composer require silverstripe/recipe-testing:^1 silverstripe/recipe-core:4.2.x-dev silverstripe/admin:1.2.x-dev silverstripe/versioned:1.2.x-dev --no-update - - if [[ $PHPUNIT_TEST == cms ]] || [[ $BEHAT_TEST == cms ]]; then composer require silverstripe/recipe-cms:4.2.x-dev --no-update; fi + - if [[ $PHPUNIT_TEST == cms ]]; then composer require silverstripe/recipe-cms:4.2.x-dev --no-update; fi - if [[ $PHPCS_TEST ]]; then composer global require squizlabs/php_codesniffer:^3 --prefer-dist --no-interaction --no-progress --no-suggest -o; fi - - composer install --prefer-source --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile + - composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile # Log constants to CI for debugging purposes - php ./tests/dump_constants.php -# Start behat services - - if [[ $BEHAT_TEST ]]; then mkdir artifacts; fi - - if [[ $BEHAT_TEST ]]; then cp composer.lock artifacts/; fi - - if [[ $BEHAT_TEST ]]; then sh -e /etc/init.d/xvfb start; sleep 3; fi - - if [[ $BEHAT_TEST ]]; then (chromedriver > artifacts/chromedriver.log 2>&1 &); fi - - if [[ $BEHAT_TEST == framework ]]; then (vendor/bin/serve --bootstrap-file tests/behat/serve-bootstrap.php &> artifacts/serve.log &); fi - - if [[ $BEHAT_TEST == cms ]]; then (vendor/bin/serve --bootstrap-file vendor/silverstripe/cms/tests/behat/serve-bootstrap.php &> artifacts/serve.log &); fi script: - if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit --testsuite $PHPUNIT_TEST; fi - if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --testsuite $PHPUNIT_COVERAGE_TEST --coverage-clover=coverage.xml; fi - - if [[ $BEHAT_TEST == framework ]]; then vendor/bin/behat @framework; fi - - if [[ $BEHAT_TEST == cms ]]; then vendor/bin/behat @cms; fi - if [[ $PHPCS_TEST ]]; then composer run-script lint; fi - if [[ $PHPCS_TEST ]]; then composer run-script php-peg; fi - if [[ $PHPCS_TEST ]]; then git diff-files --quiet -w --relative=src; fi @@ -116,5 +89,3 @@ script: after_success: - if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi -after_failure: - - if [[ $BEHAT_TEST ]]; then php ./tests/behat/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/ --artifacts-path ./artifacts/; fi diff --git a/behat.yml b/behat.yml deleted file mode 100644 index f6d329195..000000000 --- a/behat.yml +++ /dev/null @@ -1,34 +0,0 @@ -# Run framework behat tests with this command (installed with silverstripe/installer) -# Note that framework behat tests require CMS module -# ========================================================================= # -# vendor/bin/selenium-server-standalone -Dwebdriver.firefox.bin="/Applications/Firefox31.app/Contents/MacOS/firefox-bin" -# vendor/bin/serve --bootstrap-file vendor/silverstripe/framework/tests/behat/serve-bootstrap.php -# vendor/bin/behat @framework -# ========================================================================= # -default: - suites: - framework: - paths: - - %paths.modules.framework%/tests/behat/features - contexts: - - SilverStripe\Framework\Tests\Behaviour\FeatureContext - - SilverStripe\Framework\Tests\Behaviour\CmsFormsContext - - SilverStripe\Framework\Tests\Behaviour\CmsUiContext - - SilverStripe\BehatExtension\Context\BasicContext - - SilverStripe\BehatExtension\Context\EmailContext - - SilverStripe\BehatExtension\Context\LoginContext - - - SilverStripe\BehatExtension\Context\FixtureContext: - - %paths.modules.framework%/tests/behat/features/files/ - - extensions: - SilverStripe\BehatExtension\MinkExtension: - default_session: facebook_web_driver - javascript_session: facebook_web_driver - facebook_web_driver: - browser: chrome - wd_host: "http://127.0.0.1:9515" #chromedriver port - - SilverStripe\BehatExtension\Extension: - screenshot_path: %paths.base%/artifacts/screenshots - bootstrap_file: "tests/behat/serve-bootstrap.php" diff --git a/tests/behat/README.md b/tests/behat/README.md deleted file mode 100644 index e072aec9f..000000000 --- a/tests/behat/README.md +++ /dev/null @@ -1 +0,0 @@ -See https://github.com/silverstripe-labs/silverstripe-behat-extension \ No newline at end of file diff --git a/tests/behat/_manifest_exclude b/tests/behat/_manifest_exclude deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/behat/features/files/document.pdf b/tests/behat/features/files/document.pdf deleted file mode 100644 index c01805e89..000000000 Binary files a/tests/behat/features/files/document.pdf and /dev/null differ diff --git a/tests/behat/features/files/file1.jpg b/tests/behat/features/files/file1.jpg deleted file mode 100644 index beb5a91b0..000000000 Binary files a/tests/behat/features/files/file1.jpg and /dev/null differ diff --git a/tests/behat/features/files/file2.jpg b/tests/behat/features/files/file2.jpg deleted file mode 100644 index fc834a452..000000000 Binary files a/tests/behat/features/files/file2.jpg and /dev/null differ diff --git a/tests/behat/features/files/testfile.jpg b/tests/behat/features/files/testfile.jpg deleted file mode 100644 index 7aee322fe..000000000 Binary files a/tests/behat/features/files/testfile.jpg and /dev/null differ diff --git a/tests/behat/features/login.feature b/tests/behat/features/login.feature deleted file mode 100644 index e9ba96832..000000000 --- a/tests/behat/features/login.feature +++ /dev/null @@ -1,35 +0,0 @@ -@retry -Feature: Log in - As an site owner - I want to access to the CMS to be secure - So that only my team can make content changes - - Scenario: Bad login - Given I log in with "bad@example.com" and "badpassword" - Then I should see "The provided details don't seem to be correct" - - Scenario: Valid login - Given I am logged in with "ADMIN" permissions - When I go to "/admin/" - Then I should see the CMS - - Scenario: /admin/ redirect for not logged in user - # disable automatic redirection so we can use the profiler - When I go to "/admin/" - And I should see a log-in form - - Scenario: Logout without token - Given I am logged in with "ADMIN" permissions - When I go to "/Security/logout" - Then I should see a log-out form - When I press the "Log out" button - And I go to "/admin/" - Then I should see a log-in form - - Scenario: Log in as someone else - Given I am logged in with "ADMIN" permissions - When I go to "/Security/login" - Then the response should contain "Log in as someone else" - - When I press the "Log in as someone else" button - Then I should see a log-in form diff --git a/tests/behat/features/lostpassword.feature b/tests/behat/features/lostpassword.feature deleted file mode 100644 index 3467472df..000000000 --- a/tests/behat/features/lostpassword.feature +++ /dev/null @@ -1,22 +0,0 @@ -@retry -Feature: Lost Password - As a site owner - I want to be able to reset my password - Using my email - - Background: - Given a "member" "Admin" with "Email"="admin@example.org" - - Scenario: I can request a password reset by email - Given I go to "Security/login" - When I follow "I've lost my password" - And I fill in "admin@example.org" for "Email" - And I press the "Send me the password reset link" button - Then I should see "A reset link has been sent to 'admin@example.org'" - And there should be an email to "admin@example.org" titled "Your password reset link" - When I click on the "password reset link" link in the email to "admin@example.org" - Then I should see "Please enter a new password" - When I fill in "newpassword" for "New Password" - And I fill in "newpassword" for "Confirm New Password" - And I press the "Change Password" button - Then the password for "admin@example.org" should be "newpassword" diff --git a/tests/behat/features/manage-users.feature b/tests/behat/features/manage-users.feature deleted file mode 100644 index d03fd677e..000000000 --- a/tests/behat/features/manage-users.feature +++ /dev/null @@ -1,74 +0,0 @@ -@javascript @retry -Feature: Manage users - As a site administrator - I want to create and manage user accounts on my site - So that I can control access to the CMS - - Background: - Given a "member" "ADMIN" belonging to "ADMIN group" with "Email"="admin@example.org" - And the "member" "ADMIN" belonging to "ADMIN group2" - And a "member" "Staff" belonging to "Staff group" with "Email"="staffmember@example.org" - And the "group" "ADMIN group" has permissions "Full administrative rights" - And the "group" "ADMIN group2" has permissions "Full administrative rights" - And I am logged in with "ADMIN" permissions - And I go to "/admin/security" - - - Scenario: I cannot remove my admin access, but can remove myself from an admin group - When I click the "Groups" CMS tab - And I click "ADMIN group" in the "#Root_Groups" element - And I should see the "Unlink" button in the "Members" gridfield for the "ADMIN" row - Then I click "Groups" in the ".breadcrumbs-wrapper" element - And I click the "Groups" CMS tab - And I click "ADMIN group2" in the "#Root_Groups" element - And I should see the "Unlink" button in the "Members" gridfield for the "ADMIN" row - Then I click the "Unlink" button in the "Members" gridfield for the "ADMIN" row - And I should not see the "Unlink" button in the "Members" gridfield for the "ADMIN" row - Then I click "Groups" in the ".breadcrumbs-wrapper" element - And I click the "Groups" CMS tab - And I click "ADMIN group" in the "#Root_Groups" element - And I should not see the "Unlink" button in the "Members" gridfield for the "ADMIN" row - - Scenario: I can list all users regardless of group - When I click the "Users" CMS tab - Then I should see "admin@example.org" in the "#Root_Users" element - And I should see "staffmember@example.org" in the "#Root_Users" element - - Scenario: I can list all users in a specific group - When I click the "Groups" CMS tab - # TODO Please check how performant this is - And I click "ADMIN group" in the "#Root_Groups" element - Then I should see "admin@example.org" in the "#Root_Members" element - And I should not see "staffmember@example.org" in the "#Root_Members" element - - Scenario: I can add a user to the system - When I click the "Users" CMS tab - And I press the "Add Member" button - And I fill in the following: - | First Name | John | - | Surname | Doe | - | Email | john.doe@example.org | - And I press the "Create" button - Then I should see a "Saved member" message - - When I go to "admin/security/" - Then I should see "john.doe@example.org" in the "#Root_Users" element - - Scenario: I can edit an existing user and add him to an existing group - When I click the "Users" CMS tab - And I click "staffmember@example.org" in the "#Root_Users" element - And I select "ADMIN group" from "Groups" - And I press the "Apply changes" button - Then I should see a "Saved Member" message - - When I go to "admin/security" - And I click the "Groups" CMS tab - And I click "ADMIN group" in the "#Root_Groups" element - Then I should see "staffmember@example.org" - - Scenario: I can delete an existing user - When I click the "Users" CMS tab - And I click "staffmember@example.org" in the "#Root_Users" element - And I press the "Delete" button, confirming the dialog - Then I should see "admin@example.org" - And I should not see "staffmember@example.org" diff --git a/tests/behat/features/profile.feature b/tests/behat/features/profile.feature deleted file mode 100644 index ffa28f367..000000000 --- a/tests/behat/features/profile.feature +++ /dev/null @@ -1,62 +0,0 @@ -@retry -Feature: Manage my own settings - As a CMS user - I want to be able to change personal settings - In order to streamline my CMS experience - - Background: - Given a "member" "Joe" belonging to "Admin group" with "Email"="joe@example.org" and "Password"="secret" - And the "group" "Admin group" has permissions "Full administrative rights" - And the "member" "Joe" belonging to "Admin group2" - And the "group" "Admin group2" has permissions "Full administrative rights" - And I log in with "joe@example.org" and "secret" - And I go to "admin/myprofile" - - Scenario: I cannot remove all my admin groups - When I click the "Admin group" option in the "DirectGroups" listbox - And I click the "Admin group2" option in the "DirectGroups" listbox - And I press the "Save" button - Then I should see "Cannot remove all admin groups from your profile" in the "#Form_EditForm" element - - Scenario: I can remove one of my admin groups - When I click the "Admin group" option in the "DirectGroups" listbox - And I press the "Save" button - Then I should see a "Saved" notice - And I should not see "Cannot remove all admin groups from your profile" in the "#Form_EditForm" element - - Scenario: I can edit my personal details - Given I fill in "First Name" with "Jack" - And I fill in "Surname" with "Johnson" - And I fill in "Email" with "jack@example.org" - When I press the "Save" button - Given I go to "admin/myprofile" - Then I should not see "Joe" - Then I should see "Jack" - And I should see "Johnson" - - Scenario: I can't reset the password without the original - Given I follow "Change Password" - And I fill in "Current Password" with "idontknow" - And I fill in "New Password" with "newsecret" - And I fill in "Confirm Password" with "newsecret" - And I press the "Save" button - Then I should see "The current password you have entered is not correct." - - Scenario: I can change my password - Given I follow "Change Password" - And I fill in "Current Password" with "secret" - And I fill in "New Password" with "newsecret" - And I fill in "Confirm Password" with "newsecret" - And I press the "Save" button - And I am not logged in - When I log in with "joe@example.org" and "newsecret" - And I go to "admin/myprofile" - Then I should see the CMS - - Scenario: I can change the interface language - And I select "German (Germany)" from "Interface Language" - And I press the "Save" button - Then I should see "Sprache" - - # TODO Date/time format - Difficult because its not exposed anywhere in the CMS? - # TODO Group modification as ADMIN user diff --git a/tests/behat/features/reauthenticate.feature b/tests/behat/features/reauthenticate.feature deleted file mode 100644 index 236c2d851..000000000 --- a/tests/behat/features/reauthenticate.feature +++ /dev/null @@ -1,37 +0,0 @@ -@modal @retry -Feature: Reauthenticate - As a content editor - I want to be able to log in through a CMS popup when my session expires - So that I can avoid losing unsaved work - - Background: - And I am logged in with "ADMIN" permissions - And I go to "/admin/security" - And I am not in an iframe - And I click the "Users" CMS tab - And my session expires - - Scenario: Reauthenticate with correct login - When I press the "Add Member" button - And I switch to the "login-dialog-iframe" iframe - Then I should see "Your session has timed out due to inactivity" in the ".cms-security__container" element - When I fill in "Password" with "Secret!123" - And I press the "Let me back in" button - And I am not in an iframe - And I go to "/admin/security" - When I press the "Add Member" button - Then I should see "Create" in the "#Form_ItemEditForm_action_doSave" element - - Scenario: Reauthenticate with wrong login - When I press the "Add Member" button - And I switch to the "login-dialog-iframe" iframe - Then I should see "Your session has timed out due to inactivity" in the ".cms-security__container" element - When I fill in "Password" with "wrong password" - And I press the "Let me back in" button - Then I should see "The provided details don't seem to be correct. Please try again." - When I fill in "Password" with "Secret!123" - And I press the "Let me back in" button - And I am not in an iframe - And I go to "/admin/security" - When I press the "Add Member" button - Then I should see "Create" in the "#Form_ItemEditForm_action_doSave" element diff --git a/tests/behat/features/security-permissions.feature b/tests/behat/features/security-permissions.feature deleted file mode 100644 index ba57b25e0..000000000 --- a/tests/behat/features/security-permissions.feature +++ /dev/null @@ -1,85 +0,0 @@ -@javascript @retry -Feature: Manage Security Permissions for Groups - As a site administrator - I want to control my user's security permissions in an intuitive way - So that I can easily control access to the CMS - - Background: - Given a "group" "test group" - And a "member" "ADMIN" belonging to "ADMIN group" with "Email"="admin@example.org" - And the "group" "ADMIN group" has permissions "Full administrative rights" - And I am logged in with "ADMIN" permissions - And I go to "/admin/security" - And I click the "Groups" CMS tab - And I click on "test group" in the "Groups" table - And I click the "Permissions" CMS tab - - Scenario: I can see sub-permissions being properly set and restored when using "Access to all CMS sections" - When I check "Access to all CMS sections" - Then the "Access to 'Security' section" checkbox should be checked - And the "Access to 'Security' section" field should be disabled - - When I uncheck "Access to all CMS sections" - Then the "Access to 'Security' section" checkbox should not be checked - And the "Access to 'Security' section" field should be enabled - - When I check "Access to 'Security' section" - And I check "Access to all CMS sections" - When I uncheck "Access to all CMS sections" - Then the "Access to 'Security' section" checkbox should be checked - - # Save so the driver can reset without having to deal with the popup alert. - Then I press the "Apply changes" button - - Scenario: I can see sub-permissions being properly set and restored when using "Full administrative rights" - When I check "Access to 'Security' section" - And I check "Full administrative rights" - Then the "Access to all CMS sections" checkbox should be checked - And the "Access to all CMS sections" field should be disabled - And the "Access to 'Security' section" checkbox should be checked - And the "Access to 'Security' section" field should be disabled - - And I uncheck "Full administrative rights" - Then the "Access to all CMS sections" checkbox should not be checked - And the "Access to all CMS sections" field should be enabled - And the "Access to 'Security' section" checkbox should be checked - And the "Access to 'Security' section" field should be enabled - - # Save so the driver can reset without having to deal with the popup alert. - Then I press the "Apply changes" button - - Scenario: I can see sub-permissions being handled properly between reloads when using "Full administrative rights" - When I check "Full administrative rights" - And I press the "Apply changes" button - And I click the "Permissions" CMS tab - Then the "Full administrative rights" checkbox should be checked - And the "Access to 'Security' section" checkbox should be checked - And the "Access to 'Security' section" field should be disabled - - When I uncheck "Full administrative rights" - Then the "Access to 'Security' section" checkbox should not be checked - And the "Access to 'Security' section" field should be enabled - - When I press the "Apply changes" button - And I click the "Permissions" CMS tab - Then the "Full administrative rights" checkbox should not be checked - And the "Access to 'Security' section" checkbox should not be checked - And the "Access to 'Security' section" field should be enabled - - Scenario: I can see sub-permissions being handled properly between reloads when using "Access to all CMS sections" - When I check "Access to all CMS sections" - And I press the "Apply changes" button - And I click the "Permissions" CMS tab - Then the "Access to all CMS sections" checkbox should be checked - And the "Access to 'Security' section" checkbox should be checked - And the "Access to 'Security' section" field should be disabled - - When I uncheck "Access to all CMS sections" - Then the "Access to 'Security' section" checkbox should not be checked - And the "Access to 'Security' section" field should be enabled - - When I press the "Apply changes" button - And I click the "Permissions" CMS tab - Then the "Access to all CMS sections" checkbox should not be checked - And the "Access to 'Security' section" checkbox should not be checked - And the "Access to 'Security' section" field should be enabled diff --git a/tests/behat/travis-upload-artifacts.php b/tests/behat/travis-upload-artifacts.php deleted file mode 100644 index d5d1b2569..000000000 --- a/tests/behat/travis-upload-artifacts.php +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env php - 0) { - die($returnVar); - } -} - -/** - * Check if an env variable is set - * - * @param $envs - * @return bool - */ -function checkenv($envs) -{ - if ($envs) { - foreach (explode(',', $envs) as $env) { - if (!getenv($env)) { - return false; - } - } - } - return true; -} - -$opts = getopt('', array( - 'artifacts-path:', - 'target-path:', - 'if-env:', - 'artifacts-base-url:', -)); - -// --if-env=BEHAT_TEST means that this script will only be executed if the given environment var is set -if (empty($opts['if-env'])) { - echo "--if-env option is mandatory"; - exit(0); -} -if (!checkenv($opts['if-env'])) { - echo "Apache skipped; {$opts['if-env']} wasn't set.\n"; - exit(0); -} - -if (isset($opts['artifacts-path'])) { - $artifactsPath = $opts['artifacts-path']; -} elseif (is_dir(__DIR__ . '/artifacts/')) { - $artifactsPath = __DIR__ . '/artifacts/'; -} elseif (is_dir('~/artifacts/')) { - $artifactsPath = '~/artifacts/'; -} else { - $artifactsPath = null; -} - -$targetPath = $opts['target-path']; -$baseUrl = $opts['artifacts-base-url']; - -if (!$artifactsPath || !is_dir($artifactsPath)) { - echo "No artifacts found, skipped\n"; - exit(0); -} - -echo "Installing artifacts script to ~/bin/artifacts\n"; -run("curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/master/install | bash"); - -echo "Creating {$artifactsPath}index.html...\n"; - -$html = ''; - -file_put_contents("{$artifactsPath}index.html", $html); - -run("~/bin/artifacts upload --permissions public-read --target-paths $targetPath $artifactsPath"); - -$fullPath = str_replace('//', '/', "$baseUrl/$targetPath/index.html"); -$fullPath = str_replace('https:/s3', 'https://s3', $fullPath); -echo "Uploaded artifacts to $fullPath\n";