2017 © Pedro Peláez
 

silverstripe-vendormodule testsession

Support module for browser-based test sessions, e.g. for Behat behaviour testing

image

silverstripe/testsession

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  • Friday, June 8, 2018
  • by tractorcow
  • Repository
  • 18 Watchers
  • 3 Stars
  • 87,313 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 14 Forks
  • 1 Open issues
  • 23 Versions
  • 11 % Grown

The README.md

Browser Test Session Module

Build Status, (*1)

Overview

IMPORTANT: This module is intended for development and testing, it poses a security risk if used on production servers. It's completely possible to allow any user to become an admin, or do other nefarious things, if this is installed on a live site., (*2)

This module starts a testing session in a browser, in order to test a SilverStripe application in a clean state. Usually the session is started on a fresh database with only default records loaded. Further data can be loaded from YAML fixtures or database dumps., (*3)

The session is persisted in a file which is generated upon starting the session. As long as this file exists, the test session is considered in progress, both in web browsers and command-line execution. By default, the file is stored in the webroot under assets/TESTS_RUNNING-<id>.json. The <id> value is a random token stored in the browser session, in order to make the test session specific to the executing browser, and allow multiple people using their own test session in the same webroot., (*4)

The module also keeps some metadata about the session state in the database, so that it may be available for the clients as well. E.g. the silverstripe-behat-extension may use it through this module APIs, allowing us to introduce some grey-box testing techniques., (*5)

The module also serves as an initializer for the SilverStripe Behat Extension. It is required for Behat because the Behat CLI test runner needs to persist test configuration just for the tested browser connection, available on arbitary URL endpoints. For example, we're setting up a test mailer which writes every email into a temporary database table for inspection by the CLI-based process., (*6)

Setup

Simply require the module in a SilverStripe webroot (3.0 or newer):, (*7)

composer require --dev silverstripe/behat-extension

Usage

You start a test session by manually requesting a certain URL, and interact with it through other URL endpoints., (*8)

Commands:, (*9)

  • dev/testsession: Shows options for starting a test session
  • dev/testsession/start: Sets up test state, most commonly a test database will be constructed, and your browser session will be amended to use this database. See "Parameters" documentation below.
  • dev/testsession/end: Removes the test state, and resets to the original database.
  • dev/testsession/loadfixture?fixture=<path>: Loads a fixture into an existing test state.
  • dev/testsession/clear: Empties the test state.
  • dev/testsession/browsersessionstate: Set or unset browser session state (different from test session state). Use query parameters to define states.

While you can use the interface to set the test session state, it can be useful to set them programmatically through query parameters on "dev/testsession/start":, (*10)

  • fixture: Loads a YAML fixture in the format generally accepted by SapphireTest (see fixture format docs). The path should be relative to the webroot.
  • createDatabase: Create a temporary database.
  • importDatabasePath: Absolute path to a database dump to load into a newly created temporary database.
  • importDatabaseFilename: File name for a database dump to load, relative to TestSessionController.database_templates_path
  • requireDefaultRecords: Include default records as defined on the model classes (in PHP)
  • database: Set an alternative database name in the current browser session as a cookie. Does not actually create the database, that's usually handled by SapphireTest::create_temp_db(). Note: The database names are limited to a specific naming convention as a security measure: The "ss_tmpdb" prefix and a random sequence of seven digits. This avoids the user gaining access to other production databases available on the same connection.
  • mailer: Subclass of Mailer, typically used to record emails instead of actually sending them.
  • datetime: Sets a simulated date used for all framework operations. Format as "yyyy-MM-dd HH:mm:ss" (Example: "2012-12-31 18:40:59").
  • globalTestSession: Activate test session independently of the current browser session, effectively setting the site into test session mode for all users across different browsers. Only available in "dev" mode. For example, create a global test session in Chrome, then you can share the session data in Firefox. But if you have started a non-global session in a browser before starting a global session somewhere else, that non-global session will take priority in that browser.

Example usage with parameters:, (*11)

dev/testsession/start?database=ss_tmpdb_1234567&fixture=cms/tests/controller/CMSMainTest.yml

The Versions

08/06 2018

dev-master

9999999-dev http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

20/03 2018

2.x-dev

2.9999999.9999999.9999999-dev http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

07/03 2018

2.0.x-dev

2.0.9999999.9999999-dev http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

07/03 2018

2.1.0

2.1.0.0 http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

27/10 2017

2.0.0-rc1

2.0.0.0-RC1 http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

27/10 2017

2.0.0

2.0.0.0 http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

03/07 2017

2.0.0-beta1

2.0.0.0-beta1 http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

27/06 2017

2.0.0-alpha9

2.0.0.0-alpha9 http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

22/06 2017

2.0.0-alpha8

2.0.0.0-alpha8 http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

13/05 2017

2.0.0-alpha7

2.0.0.0-alpha7 http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

26/04 2017

2.0.0-alpha6

2.0.0.0-alpha6 http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

27/02 2017

2.0.0-alpha5

2.0.0.0-alpha5 http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

27/02 2017

2.0.0-alpha4

2.0.0.0-alpha4 http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

16/09 2016

2.0.0-alpha3

2.0.0.0-alpha3 http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

12/09 2016

2.0.0-alpha2

2.0.0.0-alpha2 http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

01/07 2016

2.0.0-alpha1

2.0.0.0-alpha1 http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

27/06 2016

1.x-dev

1.9999999.9999999.9999999-dev http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

19/10 2015

0.2.x-dev

0.2.9999999.9999999-dev http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

21/07 2015

0.2.1

0.2.1.0 http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

21/07 2014

0.2.0

0.2.0.0 http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

06/05 2014

dev-experiments/bootstrap

dev-experiments/bootstrap http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

19/02 2014

dev-pulls/extendedState

dev-pulls/extendedState http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe

13/08 2013

0.1.x-dev

0.1.9999999.9999999-dev http://silverstripe.org

Support module for browser-based test sessions, e.g. for Behat behaviour testing

  Sources   Download

BSD-3-Clause

The Requires

 

testing silverstripe