silverstripe-framework/tests/FakeController.php
Sean Harvey 0ee3a683a5 Better support for overloading start and destroy methods in Session
Move functionality from static start and destroy functions into instance
methods, allowing these to be overloaded. This works the same way as
calling Session::set() which then in turn calls inst_set()

Additionally use Injector to create the default Session instance to
allow the class to be swapped out.
2014-06-20 10:35:53 +12:00

25 lines
561 B
PHP

<?php
// Fake a current controller. Way harder than it should be
class FakeController extends Controller {
public function __construct() {
parent::__construct();
$session = Injector::inst()->create('Session', isset($_SESSION) ? $_SESSION : array());
$this->setSession($session);
$this->pushCurrent();
$this->request = new SS_HTTPRequest(
(isset($_SERVER['X-HTTP-Method-Override']))
? $_SERVER['X-HTTP-Method-Override']
: $_SERVER['REQUEST_METHOD'],
'/'
);
$this->response = new SS_HTTPResponse();
$this->init();
}
}