Merge branch '2.2' into 2.3

This commit is contained in:
Steve Boyd 2022-07-25 11:46:22 +12:00
commit 8535a680ca
6 changed files with 50 additions and 14 deletions

16
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,16 @@
name: CI
on:
push:
pull_request:
workflow_dispatch:
# Every Monday at 2:30pm UTC
schedule:
- cron: '30 14 * * 1'
jobs:
ci:
name: CI
# Only run cron on the silverstripe account
if: (github.event_name == 'schedule' && startsWith(github.repository, 'silverstripe/')) || (github.event_name != 'schedule')
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1

17
.github/workflows/keepalive.yml vendored Normal file
View File

@ -0,0 +1,17 @@
name: Keepalive
on:
workflow_dispatch:
# The 4th of every month at 10:50am UTC
schedule:
- cron: '50 10 4 * *'
jobs:
keepalive:
name: Keepalive
# Only run cron on the silverstripe account
if: (github.event_name == 'schedule' && startsWith(github.repository, 'silverstripe/')) || (github.event_name != 'schedule')
runs-on: ubuntu-latest
steps:
- name: Keepalive
uses: silverstripe/gha-keepalive@v1

View File

@ -1,6 +1,6 @@
# Browser Test Session Module # Browser Test Session Module
[![Build Status](https://travis-ci.org/silverstripe-labs/silverstripe-testsession.svg)](https://travis-ci.org/silverstripe-labs/silverstripe-testsession) [![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
@ -47,7 +47,7 @@ and interact with it through other URL endpoints.
Commands: Commands:
* `dev/testsession`: Shows options for starting a test session * `dev/testsession`: Shows options for starting a test session
* `dev/testsession/start`: Sets up test state, most commonly a test database will be constructed, * `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. 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/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/loadfixture?fixture=<path>`: Loads a fixture into an existing test state.
@ -59,15 +59,15 @@ While you can use the interface to set the test session state,
it can be useful to set them programmatically through query parameters it can be useful to set them programmatically through query parameters
on "dev/testsession/start": on "dev/testsession/start":
* `fixture`: Loads a YAML fixture in the format generally accepted by `SapphireTest` * `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/)). (see [fixture format docs](http://doc.silverstripe.org/en/developer_guides/testing/fixtures/)).
The path should be relative to the webroot. The path should be relative to the webroot.
* `createDatabase`: Create a temporary database. * `createDatabase`: Create a temporary database.
* `importDatabasePath`: Absolute path to a database dump to load into a newly created 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` * `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) * `requireDefaultRecords`: Include default records as defined on the model classes (in PHP)
* `database`: Set an alternative database name in the current * `database`: Set an alternative database name in the current
browser session as a cookie. Does not actually create the database, browser session as a cookie. Does not actually create the database,
that's usually handled by `SapphireTest::create_temp_db()`. that's usually handled by `SapphireTest::create_temp_db()`.
Note: The database names are limited to a specific naming convention as a security measure: 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. The "ss_tmpdb" prefix and a random sequence of seven digits.
@ -76,9 +76,9 @@ on "dev/testsession/start":
* `datetime`: Sets a simulated date used for all framework operations. * `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"). 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, * `globalTestSession`: Activate test session independently of the current browser session,
effectively setting the site into test session mode for all users across different browsers. 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 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 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. a global session somewhere else, that non-global session will take priority in that browser.
Example usage with parameters: Example usage with parameters:

View File

@ -19,10 +19,10 @@
"silverstripe/framework": "^4@dev", "silverstripe/framework": "^4@dev",
"silverstripe/vendor-plugin": "^1.3" "silverstripe/vendor-plugin": "^1.3"
}, },
"require-dev": {
"squizlabs/php_codesniffer": "^3.5"
},
"extra": { "extra": {
"branch-alias": {
"2.x-dev": "2.2.x-dev"
},
"expose": [ "expose": [
"client" "client"
] ]

View File

@ -2,6 +2,8 @@
<ruleset name="SilverStripe"> <ruleset name="SilverStripe">
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description> <description>CodeSniffer ruleset for SilverStripe coding conventions.</description>
<file>src</file>
<!-- base rules are PSR-2 --> <!-- base rules are PSR-2 -->
<rule ref="PSR2" > <rule ref="PSR2" >
<!-- Current exclusions --> <!-- Current exclusions -->

View File

@ -545,10 +545,11 @@ class TestSessionEnvironment
/** /**
* Ensure that there is a connection to the database * Ensure that there is a connection to the database
* *
* @param mixed $state * @param mixed $state
*/ */
public function connectToDatabase($state = null) { public function connectToDatabase($state = null)
{
if ($state == null) { if ($state == null) {
$state = $this->getState(); $state = $this->getState();
} }