Skip to content

Commit

Permalink
Updated tests to adapt to new behavior of BaseController which now do…
Browse files Browse the repository at this point in the history
…es not always store current uri in session for login or logout redirection
  • Loading branch information
rotimi committed Feb 21, 2025
1 parent 851fa7c commit 80a97fa
Showing 1 changed file with 4 additions and 42 deletions.
46 changes: 4 additions & 42 deletions tests/AllRoutesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -492,44 +492,6 @@ public function testBaseControllerActionLoginStatus() {
);

$this->assertNonErrorLayoutIsPresentInResponseBody($response_body);

///////////////////////////////////////////////////////////////////////
// Now login, the successful login will redirect to
// /base-controller/action-login-status
///////////////////////////////////////////////////////////////////////
$response2 = $client->request('POST', "http://{$web_server_host}:{$web_server_port}/base-controller/action-login", [
'form_params' => [
'username' => 'admin',
'password' => 'admin',
]
]);

// Should contain the /base-controller/action-login-status page
$response_body2 = ((string)$response2->getBody());

// Test that the auth info is present in the response
self::assertStringContainsString('You are still logged in.', $response_body2);
self::assertStringContainsString('Login Status: ', $response_body2);
self::assertStringContainsString("Logged in Person's Username: admin<br />", $response_body2);
self::assertStringContainsString("Logged in User's Data: ", $response_body2);

// Test that the logged-in section of the
// /base-controller/action-login-status is present in this response
self::assertStringContainsString(
'<a href="/base-controller/action-login-status">Check Login Status</a>',
$response_body2
);
self::assertStringContainsString(
'<form action="/base-controller/action-logout/1" method="post">',
$response_body2
);
self::assertStringContainsString(
'<input type="submit" value="Logout">',
$response_body2
);
self::assertStringContainsString('</form>', $response_body2);

$this->assertNonErrorLayoutIsPresentInResponseBody($response_body2);
}

public function testBaseControllerActionLogout() {
Expand Down Expand Up @@ -562,7 +524,7 @@ public function testBaseControllerActionLogout() {

///////////////////////////////////////////////////////////////////////
// Now login, the successful login will redirect to
// /base-controller/action-login-status
// /base-controller/action-index
///////////////////////////////////////////////////////////////////////
$response2 = $client->request('POST', "http://{$web_server_host}:{$web_server_port}/base-controller/action-login", [
'form_params' => [
Expand All @@ -574,9 +536,9 @@ public function testBaseControllerActionLogout() {
// Should contain the /base-controller/action-login-status page
$response_body2 = ((string)$response2->getBody());

// Test that the auth info is present in the response
self::assertStringContainsString('You are still logged in.', $response_body2);
self::assertStringContainsString("Logged in Person's Username: admin<br />", $response_body2);
// Test that index page was returned
self::assertStringContainsString('<h4><strong>Below are the default links that are available in your application:</strong></h4>', $response_body2);
self::assertStringContainsString('<h4><strong>A little bit about Controllers and MVC:</strong></h4>', $response_body2);

////////////////////////////////////////////////////////////////////////
// Now go to /base-controller/action-logout/1 which should log the user
Expand Down

0 comments on commit 80a97fa

Please sign in to comment.