silverstripe-framework/tests/FakeController.php

25 lines
554 B
PHP
Raw Normal View History

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