PHPackages                             silverstripe/testsession - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. silverstripe/testsession

ActiveSilverstripe-vendormodule[Testing &amp; Quality](/categories/testing)

silverstripe/testsession
========================

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

2.4.1(3y ago)3606.7k↓18.1%20[2 PRs](https://github.com/silverstripe/silverstripe-testsession/pulls)2BSD-3-ClausePHPCI passing

Since Aug 13Pushed 9mo ago14 watchersCompare

[ Source](https://github.com/silverstripe/silverstripe-testsession)[ Packagist](https://packagist.org/packages/silverstripe/testsession)[ Docs](http://silverstripe.org)[ RSS](/packages/silverstripe-testsession/feed)WikiDiscussions 4 Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (35)Used By (2)

Browser Test Session Module
===========================

[](#browser-test-session-module)

[![CI](https://github.com/silverstripe/silverstripe-testsession/actions/workflows/ci.yml/badge.svg)](https://github.com/silverstripe/silverstripe-testsession/actions/workflows/ci.yml)

Overview
--------

[](#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.*

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.

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-.json`. The `` 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.

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.

The module also serves as an initializer for the [Silverstripe Behat Extension](https://github.com/silverstripe-labs/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.

Setup
-----

[](#setup)

Simply require the module in a Silverstripe webroot (3.0 or newer):

```
composer require --dev silverstripe/behat-extension

```

Usage
-----

[](#usage)

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

Commands:

- `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=`: 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":

- `fixture`: Loads a YAML fixture in the format generally accepted by `SapphireTest`(see [fixture format docs](http://doc.silverstripe.org/en/developer_guides/testing/fixtures/)). 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:

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

```

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance41

Moderate activity, may be stable

Popularity43

Moderate usage in the ecosystem

Community35

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~141 days

Recently: every ~231 days

Total

32

Last Release

284d ago

Major Versions

0.2.x-dev → 2.0.0-alpha12016-07-01

1.x-dev → 2.3.12022-04-13

2.x-dev → 3.x-dev2024-06-17

3.x-dev → 4.x-dev2025-08-07

PHP version history (3 changes)0.1.x-devPHP &gt;=5.3.2

3.x-devPHP ^8.1

4.x-devPHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/654636?v=4)[Aaron Carlino](/maintainers/unclecheese)[@unclecheese](https://github.com/unclecheese)

![](https://www.gravatar.com/avatar/b0cba8b534e20e6ab4fff555a97b237a18436ebca1446fc0b29c8a8b504038b9?d=identicon)[GuySartorelli](/maintainers/GuySartorelli)

![](https://avatars.githubusercontent.com/u/111025?v=4)[Ingo Schommer](/maintainers/chillu)[@chillu](https://github.com/chillu)

![](https://www.gravatar.com/avatar/a25bc04c5720a36869d5a39c6449dde7eb43e19b7c8e666d5f632d6a9ab440b1?d=identicon)[emteknetnz](/maintainers/emteknetnz)

![](https://www.gravatar.com/avatar/afbb3dcc9ef29c1a6eedd6addcae5fce9ab1271915a85a4c349301b71237368d?d=identicon)[silverstripe-machine01](/maintainers/silverstripe-machine01)

![](https://www.gravatar.com/avatar/be6648e60fbab6f70bfc34dd8c14259562d28a47510a934ea9c01fe98633f3c2?d=identicon)[sminnee](/maintainers/sminnee)

![](https://avatars.githubusercontent.com/u/1168676?v=4)[Maxime Rainville](/maintainers/maxime-rainville)[@maxime-rainville](https://github.com/maxime-rainville)

---

Top Contributors

[![chillu](https://avatars.githubusercontent.com/u/111025?v=4)](https://github.com/chillu "chillu (75 commits)")[![emteknetnz](https://avatars.githubusercontent.com/u/4809037?v=4)](https://github.com/emteknetnz "emteknetnz (25 commits)")[![GuySartorelli](https://avatars.githubusercontent.com/u/36352093?v=4)](https://github.com/GuySartorelli "GuySartorelli (21 commits)")[![dhensby](https://avatars.githubusercontent.com/u/563596?v=4)](https://github.com/dhensby "dhensby (10 commits)")[![dnsl48](https://avatars.githubusercontent.com/u/9313746?v=4)](https://github.com/dnsl48 "dnsl48 (7 commits)")[![madmatt](https://avatars.githubusercontent.com/u/893117?v=4)](https://github.com/madmatt "madmatt (3 commits)")[![flamerohr](https://avatars.githubusercontent.com/u/1064889?v=4)](https://github.com/flamerohr "flamerohr (3 commits)")[![maxime-rainville](https://avatars.githubusercontent.com/u/1168676?v=4)](https://github.com/maxime-rainville "maxime-rainville (3 commits)")[![wilr](https://avatars.githubusercontent.com/u/101629?v=4)](https://github.com/wilr "wilr (3 commits)")[![halkyon](https://avatars.githubusercontent.com/u/138450?v=4)](https://github.com/halkyon "halkyon (2 commits)")[![mateusz](https://avatars.githubusercontent.com/u/118653?v=4)](https://github.com/mateusz "mateusz (2 commits)")[![igor-silverstripe](https://avatars.githubusercontent.com/u/6666311?v=4)](https://github.com/igor-silverstripe "igor-silverstripe (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")[![IgorNadj](https://avatars.githubusercontent.com/u/667652?v=4)](https://github.com/IgorNadj "IgorNadj (1 commits)")[![blueo](https://avatars.githubusercontent.com/u/948122?v=4)](https://github.com/blueo "blueo (1 commits)")[![lozcalver](https://avatars.githubusercontent.com/u/1655548?v=4)](https://github.com/lozcalver "lozcalver (1 commits)")[![phillprice](https://avatars.githubusercontent.com/u/320214?v=4)](https://github.com/phillprice "phillprice (1 commits)")[![pjayme](https://avatars.githubusercontent.com/u/27745093?v=4)](https://github.com/pjayme "pjayme (1 commits)")[![sabina-talipova](https://avatars.githubusercontent.com/u/87288324?v=4)](https://github.com/sabina-talipova "sabina-talipova (1 commits)")[![simonwelsh](https://avatars.githubusercontent.com/u/125915?v=4)](https://github.com/simonwelsh "simonwelsh (1 commits)")

---

Tags

testingsilverstripe

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/silverstripe-testsession/health.svg)

```
[![Health](https://phpackages.com/badges/silverstripe-testsession/health.svg)](https://phpackages.com/packages/silverstripe-testsession)
```

###  Alternatives

[silverstripe/framework

The SilverStripe framework

7213.5M2.5k](/packages/silverstripe-framework)[silverstripe/frameworktest

Aids core and module developers in testing their code against a set of sample data and behaviour.

17304.6k23](/packages/silverstripe-frameworktest)[silverleague/ideannotator

Generate PHP DocBlock annotations for DataObject and DataExtension databasefields and relation methods

4768.0k43](/packages/silverleague-ideannotator)[sheadawson/silverstripe-userswitcher

During testing, allows Admins to quickly switch to act as a different user in the system

164.6k](/packages/sheadawson-silverstripe-userswitcher)[dnadesign/silverstripe-populate

Populate your database through YAML files

25102.3k2](/packages/dnadesign-silverstripe-populate)[liip/drupalconnectormodule

The DrupalConnector Module is an abstraction layer to the Drupal 7 API of global functions in order to use them in an OOD setup.

121.7k3](/packages/liip-drupalconnectormodule)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
