|
@@ -28,7 +28,7 @@ class LoginControllerTest extends TestCase
|
|
/** @test */
|
|
/** @test */
|
|
public function it_login_with_correct_data()
|
|
public function it_login_with_correct_data()
|
|
{
|
|
{
|
|
- $this->database()->query("INSERT INTO `users` (`email`, `username`, `password`, `is_admin`, `user_code`) VALUES ('admin@example.com', 'admin', ?, 1, ?)", [password_hash('admin', PASSWORD_DEFAULT), humanRandomString(5)]);
|
|
|
|
|
|
+ $this->createAdminUser();
|
|
|
|
|
|
$response = $this->get(route('login.show'));
|
|
$response = $this->get(route('login.show'));
|
|
$form = $this->getCrawler($response)
|
|
$form = $this->getCrawler($response)
|
|
@@ -57,10 +57,49 @@ class LoginControllerTest extends TestCase
|
|
/** @test */
|
|
/** @test */
|
|
public function it_show_register_when_enabled()
|
|
public function it_show_register_when_enabled()
|
|
{
|
|
{
|
|
- $this->database()->query("INSERT INTO `settings`(`key`, `value`) VALUES ('register_enabled', 'on')");
|
|
|
|
|
|
+ $this->updateSetting('register_enabled', 'on');
|
|
|
|
|
|
$response = $this->get(route('login.show'));
|
|
$response = $this->get(route('login.show'));
|
|
$this->assertSame(200, $response->getStatusCode());
|
|
$this->assertSame(200, $response->getStatusCode());
|
|
$this->assertStringContainsString('Register', $this->getCrawler($response)->text());
|
|
$this->assertStringContainsString('Register', $this->getCrawler($response)->text());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /** @test */
|
|
|
|
+ public function it_redirect_to_home_if_logged_in()
|
|
|
|
+ {
|
|
|
|
+ $this->createAdminUser();
|
|
|
|
+
|
|
|
|
+ $response = $this->get(route('login.show'));
|
|
|
|
+ $form = $this->getCrawler($response)
|
|
|
|
+ ->selectButton('Login')
|
|
|
|
+ ->form([
|
|
|
|
+ 'username' => 'admin@example.com',
|
|
|
|
+ 'password' => 'admin',
|
|
|
|
+ ], 'POST');
|
|
|
|
+
|
|
|
|
+ $this->submitForm($form);
|
|
|
|
+
|
|
|
|
+ $response = $this->get(route('login'));
|
|
|
|
+ $this->assertSame(302, $response->getStatusCode());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /** @test */
|
|
|
|
+ public function it_set_the_remember_token()
|
|
|
|
+ {
|
|
|
|
+ $this->createAdminUser();
|
|
|
|
+
|
|
|
|
+ $response = $this->get(route('login.show'));
|
|
|
|
+ $form = $this->getCrawler($response)
|
|
|
|
+ ->selectButton('Login')
|
|
|
|
+ ->form([
|
|
|
|
+ 'username' => 'admin@example.com',
|
|
|
|
+ 'password' => 'admin',
|
|
|
|
+ 'remember' => 'on',
|
|
|
|
+ ], 'POST');
|
|
|
|
+
|
|
|
|
+ $response = $this->submitForm($form);
|
|
|
|
+ dd($response->getHeaders());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|