Test for disable_profiles option

This commit is contained in:
zanderwar 2017-11-03 08:32:38 +13:00
parent 2e01219e8f
commit 99112e6eef

View File

@ -9,6 +9,7 @@ use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\Control\Controller; use SilverStripe\Control\Controller;
use SilverStripe\Control\Director; use SilverStripe\Control\Director;
use SilverStripe\Control\HTTPRequest; use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\HTTPResponse_Exception;
use SilverStripe\Control\Session; use SilverStripe\Control\Session;
use SilverStripe\Core\Config\Config; use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\SapphireTest; use SilverStripe\Dev\SapphireTest;
@ -348,6 +349,21 @@ class BlogTest extends SapphireTest
); );
} }
public function testDisabledProfiles()
{
Config::modify()->set(BlogController::class, 'disable_profiles', true);
try {
$controller = BlogController::create();
$controller->setRequest(Controller::curr()->getRequest());
$controller->profile();
$this->fail('The "profile" action should throw a HTTPResponse_Exception when disable_profiles is enabled');
} catch (HTTPResponse_Exception $e) {
$this->assertEquals(404, $e->getResponse()->getStatusCode(), 'The response status code should be 404 Not Found');
}
}
/** /**
* Mock a request against a given controller * Mock a request against a given controller
* *