From 431ecb105400f16831e5a3924bd15485c871a0ce Mon Sep 17 00:00:00 2001 From: Simon Erkelens Date: Sun, 15 Jul 2018 14:39:21 +1200 Subject: [PATCH] Up the testing by properly logging out --- tests/unit/HaveIBeenPwndPageControllerTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/unit/HaveIBeenPwndPageControllerTest.php b/tests/unit/HaveIBeenPwndPageControllerTest.php index 9f9ba46..475a9da 100644 --- a/tests/unit/HaveIBeenPwndPageControllerTest.php +++ b/tests/unit/HaveIBeenPwndPageControllerTest.php @@ -5,10 +5,13 @@ use Firesphere\HaveIBeenPwnd\Controllers\HaveIBeenPwndPageController; use Firesphere\HaveIBeenPwnd\Models\HaveIBeenPwndPage; use SilverStripe\Core\Injector\Injector; +use SilverStripe\Dev\Debug; use SilverStripe\Dev\SapphireTest; +use SilverStripe\Security\IdentityStore; use SilverStripe\Security\Security; if (class_exists(HaveIBeenPwndPageController::class)) { + class HaveIBeenPwndPageControllerTest extends SapphireTest { public function testClassExists() @@ -26,10 +29,14 @@ public function testCheckEmail() $controller = Injector::inst()->get(HaveIBeenPwndPageController::class, $page); + // Log out. Solidly I hope Security::setCurrentUser(null); + Injector::inst()->get(IdentityStore::class)->logOut(); $response = $controller->checkEmail(); + Debug::dump($response); + // If there's no user, it should just return itself $this->assertInstanceOf(HaveIBeenPwndPageController::class, $response); }