silverstripe-framework/tests/FakeController.php

26 lines
581 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();
$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->setRequest($request);
$this->setResponse(new SS_HTTPResponse());
2014-08-15 08:53:05 +02:00
$this->init();
}
}