Skip to content

Commit

Permalink
Merge pull request #36 from open-sausages/pulls/namespace-orm
Browse files Browse the repository at this point in the history
Update for SilverStripe\ORM namespace
  • Loading branch information
chillu authored Jul 1, 2016
2 parents e66772f + cbcd808 commit 3b06f5f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 15 deletions.
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ language: php

sudo: false

php:
php:
- 5.5

env:
Expand All @@ -15,18 +15,14 @@ matrix:
include:
- php: 5.6
env: DB=PGSQL CORE_RELEASE=master
- php: 5.5
- php: 5.6
env: DB=MYSQL CORE_RELEASE=master
- php: 5.3
env: DB=MYSQL CORE_RELEASE=3.2
- php: 5.3
env: DB=MYSQL CORE_RELEASE=3

before_script:
- phpenv rehash
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
- cd ~/builds/ss

script:
script:
- phpunit testsession/tests/unit/
2 changes: 2 additions & 0 deletions _config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use SilverStripe\ORM\DB;

// Determine whether there is a testsession currently running, and if so - setup the persistent details for it.
Injector::inst()->get('TestSessionEnvironment')->loadFromFile();

Expand Down
15 changes: 11 additions & 4 deletions code/TestSessionController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php

use SilverStripe\ORM\DB;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\FieldType\DBHTMLText;

/**
* Requires PHP's mycrypt extension in order to set the database name as an encrypted cookie.
*/
Expand Down Expand Up @@ -55,7 +60,7 @@ public function init()

public function Link($action = null)
{
return Controller::join_links(Director::baseUrl(), 'dev/testsession', $action);
return Controller::join_links(Director::baseURL(), 'dev/testsession', $action);
}

public function index()
Expand Down Expand Up @@ -104,11 +109,11 @@ public function start()
// Optionally import database
if (!empty($params['importDatabasePath']) || !empty($params['importDatabaseFilename'])) {
$absPath = '';

// by path
if (!empty($params['importDatabasePath'])) {
$absPath = $params['importDatabasePath'];

// by filename
} elseif (!empty($params['importDatabaseFilename'])) {
foreach ($this->getDatabaseTemplates() as $tAbsPath => $tFilename) {
Expand Down Expand Up @@ -137,6 +142,8 @@ public function start()

/**
* Set $_SESSION state for the current browser session.
*
* @param SS_HTTPRequest $request
*/
public function browsersessionstate($request)
{
Expand Down Expand Up @@ -252,7 +259,7 @@ public function DatabaseName()
* Updates an in-progress {@link TestSessionEnvironment} object with new details. This could be loading in new
* fixtures, setting the mocked date to another value etc.
*
* @return HTMLText Rendered Template
* @return DBHTMLText Rendered Template
* @throws LogicException
*/
public function set()
Expand Down
4 changes: 4 additions & 0 deletions code/TestSessionEnvironment.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

use SilverStripe\ORM\DB;
use SilverStripe\ORM\DatabaseAdmin;
use SilverStripe\ORM\Versioning\Versioned;

/**
* Responsible for starting and finalizing test sessions.
* Since these session span across multiple requests, session information is persisted
Expand Down
9 changes: 7 additions & 2 deletions code/TestSessionRequestFilter.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php

use SilverStripe\ORM\DataModel;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\DB;

/**
* Sets state previously initialized through {@link TestSessionController}.
*/
Expand All @@ -25,13 +30,13 @@ public function preRequest(SS_HTTPRequest $request, Session $session, DataModel

// Date and time
if (isset($testState->datetime)) {
SS_Datetime::set_mock_now($testState->datetime);
DBDatetime::set_mock_now($testState->datetime);
}

// Register mailer
if (isset($testState->mailer)) {
$mailer = $testState->mailer;
Email::set_mailer(new $mailer());
Injector::inst()->registerService(new $mailer(), 'Mailer');
Config::inst()->update("Email", "send_all_emails_to", null);
}

Expand Down
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
}
],
"require": {
"php": ">=5.3.2",
"composer/installers": "*",
"silverstripe/framework": ">=3.2.0"
"silverstripe/framework": "^4"
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"minimum-stability": "dev"
}

0 comments on commit 3b06f5f

Please sign in to comment.