test: add testLogInNonExistingUser
This commit is contained in:
parent
27d66368ee
commit
1e42674c29
1 changed files with 15 additions and 1 deletions
|
@ -9,7 +9,7 @@ use wishthis\{Database, User};
|
||||||
|
|
||||||
final class LogInTest extends TestCase
|
final class LogInTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testLogIn(): void
|
public static function setUpBeforeClass(): void
|
||||||
{
|
{
|
||||||
\define('DEFAULT_LOCALE', 'en_GB');
|
\define('DEFAULT_LOCALE', 'en_GB');
|
||||||
\define('ROOT', \dirname(__DIR__));
|
\define('ROOT', \dirname(__DIR__));
|
||||||
|
@ -18,7 +18,10 @@ final class LogInTest extends TestCase
|
||||||
require __DIR__ . '/../src/classes/wishthis/Database.php';
|
require __DIR__ . '/../src/classes/wishthis/Database.php';
|
||||||
require __DIR__ . '/../src/functions/gettext.php';
|
require __DIR__ . '/../src/functions/gettext.php';
|
||||||
require __DIR__ . '/../src/config/config.php';
|
require __DIR__ . '/../src/config/config.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testLogInExistingUser(): void
|
||||||
|
{
|
||||||
$user = User::getCurrent();
|
$user = User::getCurrent();
|
||||||
$userEmpty = new User();
|
$userEmpty = new User();
|
||||||
$userEmail = 'email@domain.tld';
|
$userEmail = 'email@domain.tld';
|
||||||
|
@ -44,4 +47,15 @@ final class LogInTest extends TestCase
|
||||||
$this->assertTrue($userLoginSuccessful);
|
$this->assertTrue($userLoginSuccessful);
|
||||||
$this->assertEquals($userEmail, $_SESSION['user']->getEmail());
|
$this->assertEquals($userEmail, $_SESSION['user']->getEmail());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLogInNonExistingUser(): void
|
||||||
|
{
|
||||||
|
$user = new User();
|
||||||
|
$userEmail = 'thisemail@shouldnt.exist';
|
||||||
|
$userPassword = '1234isnotarealpassword';
|
||||||
|
|
||||||
|
$userLoginSuccessful = $user->logIn($userEmail, $userPassword);
|
||||||
|
|
||||||
|
$this->assertFalse($userLoginSuccessful);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue