Commit Graph

57 Commits

Author SHA1 Message Date
Ingo Schommer
808d6aa87a Tie test session files to browser session 2014-03-02 11:44:58 +13:00
Ingo Schommer
40dd841eb3 API Persist state directly on disk
In memory state can get out of date between CLI and web requests,
leading to hard to debug errors. The performance impact of this
should be low, given the size of the JSON file.
2014-03-01 20:16:20 +13:00
Ingo Schommer
c247392da0 API Replace TestSessionDatabaseState with JSON persistence, store PHP session 2014-03-01 14:32:22 +13:00
Ingo Schommer
2f85acdd18 Removed inst(), its duplicating Injector functionality 2014-03-01 11:06:48 +13:00
Ingo Schommer
8eaeeb39d1 Removed reflexive behat dependency, not actually needed 2014-03-01 10:33:40 +13:00
Ingo Schommer
adc3ac5c38 Merge pull request #10 from silverstripe-labs/pulls/php-session-state
Allow setting PHP session state
2014-02-27 15:10:25 +13:00
Ingo Schommer
6b13c782c3 Clarified warning 2014-02-27 15:10:18 +13:00
Ingo Schommer
2c12cde90a Make 'database' state optional 2014-02-27 14:47:22 +13:00
Ingo Schommer
add47cb625 Allow requireDefaultRecords population 2014-02-26 16:41:21 +13:00
madmatt
962e8214f2 FIX: Properly extend onBeforeStartTestSession so extensions can modify the $state array 2014-02-26 16:41:16 +13:00
Ingo Schommer
54a8e673a6 Allow setting PHP session state 2014-02-26 13:34:38 +13:00
Ingo Schommer
e198f738b4 Merge pull request #9 from madmatt/pulls/resque-event
Add Resque_Event::listen() call to register the testsession state switcher with the silverstripe-resque module.
2014-02-16 09:57:09 +13:00
Matt
bdc3d6a835 Add Resque_Event::listen() call to register the testsession state switcher
with the silverstripe-resque module.
2014-02-12 13:47:40 +13:00
Ingo Schommer
9b72ee0554 Doc tweaks around new test file 2014-02-09 18:48:25 +13:00
Ingo Schommer
3a4cb71808 Using instance reference for TestSessionEnv 2014-02-09 18:48:25 +13:00
Ingo Schommer
cd5ac2c752 Removed security token docs, no longer needed 2014-02-09 18:48:25 +13:00
madmatt
42be37db53 Refactor testsession module to use file-based session state storage.
This is a major refactoring of the testsession module to use a persistent file
storage instead of using $_SESSION storage. The primary reason for this is for
out-of-band tests (e.g. simplifying Behat tests, and testing modules like
silverstripe-resque (https://github.com/stojg/silverstripe-resque)). Testing
the silverstripe-resque module without this is impossible as the PHP code
running the job has been started and loaded into memory long before you started
a testsession.

By default, this will create a TESTS_RUNNING.json file in your webroot, which
means that tests need to be run as a user who has permission to create files
there. In practice, this means your webroot needs to be owned by your webserver
user. The reason we store the file here is that it will show up as a changed
file in version control, so it’s more prominent if developers can’t figure out
why there are issues with database content.

API CHANGES:
- Add persistent file storage (using webroot/TESTS_RUNNING.json) as a base.
- Update TestSessionController to use new TestSessionEnvironment class.
- Moved extension points from TestSessionController to TestSessionEnvironment.
- Moved loadFixtureIntoDb from TestSessionController to TestSessionEnvironment.
- Moved setState from TestSessionController to TestSessionEnvironment.
  - Deprecated the use of TestSessionController::setState()

FIXES:
- Fixes TestSessionRequestFilter to use new TestSessionEnvironment instead of
  $_SESSION.

MINOR:
- Renamed TestSesssionRequestFilter.php to fix spelling error (three ’S’s)
  - Class did not need renaming, just the file itself.
2014-02-09 18:48:25 +13:00
Ingo Schommer
1f67061901 Merge pull request #8 from mateusz/php53
Fix syntax to work with php 5.3, in line with required dependency.
2014-02-07 11:41:13 +13:00
Mateusz Uzdowski
bb289936cf Fix syntax to work with php 5.3, in line with required dependency. 2014-02-07 11:39:36 +13:00
Ingo Schommer
20efb0c6fa Allow extension of init() 2013-12-18 16:07:37 +01:00
Ingo Schommer
bfb6ee04c8 Added onRegister hook 2013-12-16 23:48:24 +01:00
Ingo Schommer
356446d4cb Load test data from database dumps 2013-12-12 14:18:18 +01:00
Ingo Schommer
89a429c6a5 Don't require authentication for "test" environments
We use testsession to build up test state e.g. for checking
logins, so having an admin logged-in to operate the testsession
controller is counterproductive.
2013-12-12 01:08:29 +01:00
Ingo Schommer
de47ef0ed1 Remvoed auto-create of database, it overrides the form choice 2013-12-11 00:43:00 +01:00
Ingo Schommer
8b09514256 Support for empty mock times (default to 00:00:00) 2013-12-10 19:34:39 +01:00
Ingo Schommer
72b48f4c38 API State setting within session, make tmpdb optional
- Allow limited state setting when session is already in progress
- Allow test sessions without a test database
- Denote an “in progress” session through a “testsession.started” session flag rather than the usage of a temporary database
2013-12-10 19:34:37 +01:00
Ingo Schommer
c901abe83c Better default styles, made form extensible 2013-12-10 19:34:35 +01:00
Ingo Schommer
dca76e9ba3 Fixed var_export return value in state viewer 2013-12-10 16:50:07 +01:00
Ingo Schommer
d8debeba08 Extension hooks 2013-12-09 13:29:46 +01:00
Ingo Schommer
3dbaf8f92a TestSessionDatabaseState for shared state between processes 2013-12-09 01:41:44 +01:00
Sean Harvey
c43a26a998 Merge pull request #3 from chillu/pulls/stub-code-writer
NEW Write PHP code for later inclusion
2013-11-27 12:30:53 -08:00
Ingo Schommer
81d39c2350 NEW Write PHP code for later inclusion
Useful for out-of-process stubs with Behat+Selenium
2013-11-27 19:29:44 +01:00
Ingo Schommer
dbe10da069 Hide testing state by default to avoid perceptual diffs
The perceptual diff extension in Behat defaults to taking
a screenshot of every browser step, including the
"started testsession" one. A simple way to avoid this view
changing is hiding the variable state behind a click event.
The state info is mostly used for manual testing via
dev/tests/startsession anyway.
2013-11-07 12:25:29 +01:00
Ingo Schommer
babd24f4b9 API Don't create fixtures by default
Use @database-defaults in specific scenarios or features to enforce creation.
2013-09-14 18:53:53 +02:00
Will Rossiter
18cc924245 Merge pull request #2 from simonwelsh/patch-1
Create LICENSE
2013-09-02 02:16:36 -07:00
Simon Welsh
2f9426539f Create LICENSE 2013-09-02 21:14:48 +12:00
Ingo Schommer
f65bef86ed Set temp database on current request
Was relying on cookie to set on NEXT request, which was too late
since some of the following init logic relied on DB queries.
This happened to work if your non-test DB was already set up,
but failed on fresh checkouts.
2013-08-13 13:58:50 +02:00
Ingo Schommer
9e2bcbcde7 Fixed framework dependency version
Wasn't matching 3.1.0-rc1 tag. Now possible thanks to Sam's work which has recently been merged into the composer project.
2013-08-13 12:25:14 +02:00
Ingo Schommer
2a8376e1e1 Create test DB if 'database' GET param is set, but no matching DB is found 2013-08-07 13:56:36 +02:00
Ingo Schommer
77e29d47c7 Using 3.1 compatible Config API for setup
Avoids deprecation notices when testing against master
2013-06-19 12:12:11 +02:00
Ingo Schommer
2015b89474 Merge pull request #1 from sminnee/testsession-status-output
NEW: Add status code comment to testsession/start output.
2013-06-07 00:28:38 -07:00
Sam Minnee
25c7abb32d FIX: Add workaround for Cookie bug.
This patch adds a workaround for the Cookie bug, so that we don't need 3.1+ in
order to test.
2013-06-07 11:36:55 +12:00
Sam Minnee
89d6b036b4 NEW: Add status code comment to testsession/start output.
testsession/start now includes a comment of the form <!-- SUCCESS: DBNAME=DatabaseName -->,
which can be used by behat and other consumers to validate that the tesession was actually
started.

It's included the database name in its output, which is a small piece of information
disclosure, but not a big deal compared to the generally dev-only nature of this module.

It requires a fix to Cookie::set(), to ensure that set cookies also apperar immediately
in $_COOKIE.  Otherwise the call to DB::get_alternative_database_name() after it is set
won't return a value.
2013-06-07 11:22:18 +12:00
Ingo Schommer
bded32a90b Merge remote-tracking branch 'origin/0.1'
Conflicts:
	composer.json
2013-06-04 15:01:30 +02:00
Ingo Schommer
9a8d24c116 Check for Security.token before setting test session state
Otherwise we'll get into a catch22 if it's not set:
The manifest includes this _config.php, which in turn
throws a fatal exception on the token not existing.
It would be recreated a couple of lines further down in Core.php
when the ConfigManifest is pushed, but never gets this far.
2013-06-04 15:00:54 +02:00
Ingo Schommer
cfae50d585 Trying better composer constraints 2013-05-07 12:47:29 +03:00
Ingo Schommer
a22ca3d860 More compatible requirements 2013-05-07 12:15:47 +03:00
Sam Minnee
e6606dbbd3 FIX: Allow pre-release versions of SS3.1 to work with silverstripe/testsession 2013-05-06 17:35:45 +12:00
Ingo Schommer
fce1e57184 Upped version dependency to 3.1 2013-04-09 09:53:45 +02:00
Ingo Schommer
d843933655 Limiting version dependency to 3.0 2013-04-09 09:53:01 +02:00