Skip to content

Commit

Permalink
Up the testing by properly logging out
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Erkelens committed Jul 15, 2018
1 parent 630946a commit 431ecb1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/unit/HaveIBeenPwndPageControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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);
}
Expand Down

0 comments on commit 431ecb1

Please sign in to comment.