Skip to content

Commit

Permalink
Move element type report unit tests to behat test
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill committed Jul 12, 2018
1 parent bb1a0ec commit 5c72f0a
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[{*.yml,package.json,*.scss,*.js}]
[*.{yml,scss,js,feature}]
indent_size = 2

# The indent size used in the package.json file cannot be changed:
Expand Down
23 changes: 22 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
language: php

before_install:
- sudo apt-get update
- sudo apt-get install chromium-chromedriver

env:
global:
- COMPOSER_ROOT_VERSION=3.0.x-dev
- DISPLAY=":99"
- XVFBARGS=":99 -ac -screen 0 1024x768x16"
- SS_BASE_URL="http://localhost:8080/"
- SS_ENVIRONMENT_TYPE="dev"

matrix:
include:
Expand All @@ -14,24 +22,37 @@ matrix:
env: DB=MYSQL RECIPE_VERSION=1.2.x-dev PHPUNIT_TEST=1
- php: 7.1
env: DB=MYSQL RECIPE_VERSION=4.2.x-dev PHPUNIT_COVERAGE_TEST=1
- php: 7.2
env: DB=MYSQL RECIPE_VERSION=4.2.x-dev BEHAT_TEST=1
- php: 7.2
env: DB=MYSQL RECIPE_VERSION=4.x-dev PHPUNIT_TEST=1

before_script:
# Extra $PATH
- export PATH=/usr/lib/chromium-browser/:$PATH

# Init PHP
- phpenv rehash
- phpenv config-rm xdebug.ini

# Install composer dependencies
- composer validate
- composer require silverstripe/recipe-cms $RECIPE_VERSION --no-update
- composer require silverstripe/recipe-cms:$RECIPE_VERSION silverstripe/recipe-testing:^1 --no-update
- if [[ $DB == PGSQL ]]; then composer require silverstripe/postgresql:2.0.x-dev --no-update; fi
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile

# Behat bootstrapping
- 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 ]]; 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 tests/; fi
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src/ tests/ ; fi
- if [[ $BEHAT_TEST ]]; then vendor/bin/behat @silverstripe-elemental; fi

after_success:
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi
32 changes: 32 additions & 0 deletions behat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Run silverstripe-elemental behat tests with this command
# Note that silverstripe-elemental behat tests require CMS module
# ========================================================================= #
# chromedriver
# vendor/bin/behat @silverstripe-elemental
# ========================================================================= #
default:
suites:
silverstripe-elemental:
paths:
- %paths.modules.silverstripe-elemental%/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\LoginContext
-
SilverStripe\BehatExtension\Context\FixtureContext:
- %paths.modules.silverstripe-elemental%/tests/Behat/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
browser_name: chrome
SilverStripe\BehatExtension\Extension:
bootstrap_file: vendor/silverstripe/cms/tests/behat/serve-bootstrap.php
screenshot_path: %paths.base%/artifacts/screenshots
retry_seconds: 4 # default is 2
17 changes: 17 additions & 0 deletions tests/Behat/features/block-types-report.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Feature: View types of elements in a report
As a CMS user
I want to view a report of element types in the CMS
So that I can see which elements I have available and how many are used

@javascript
Scenario: I can view the types of elements used
Given I am logged in with "ADMIN" permissions
And I go to "/admin/reports"
Then I should see text matching "Content block types"

When I go to "/admin/reports/show/DNADesign-Elemental-Reports-ElementTypeReport"
Then I should see text matching "Content block types"
# See: Content element, bundled by default with elemental
And I should see text matching "HTML text block"
# Ensure BaseElement is ignored
And I should not see text matching "Base element class"
67 changes: 0 additions & 67 deletions tests/Reports/ElementTypeReportTest.php

This file was deleted.

0 comments on commit 5c72f0a

Please sign in to comment.