Skip to content

Commit

Permalink
more test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrich Schmidt committed Dec 29, 2019
1 parent c26a22a commit 58fb459
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions ulicms/tests/api/UsersApiTest.php
Expand Up @@ -26,17 +26,30 @@ public function setUp() {
$user->save();
$this->testUser = $user;

$user = new User();
$user->setUsername("testuser2");
$user->setLastname("Muster");
$user->setFirstname("Max");
$user->setEmail("max@muster.de");
$user->setPassword("topsecret");
$user->setLocked(true);
$user->setGroup($this->testGroup);
$user->save();

$user = new User();
$user->setUsername("testuser3");
$user->setLastname("Muster");
$user->setFirstname("Max");
$user->setPassword("oldpassword");
$user->save();

require_once getLanguageFilePath("en");
}

public function tearDown() {
unset($_SESSION["login_id"]);
unset($_SESSION["logged_in"]);
unset($_REQUEST["error"]);

$this->testGroup->delete();
$this->testUser->delete();
Expand Down Expand Up @@ -100,12 +113,32 @@ public function testLoggedInFalse() {
$this->assertFalse(logged_in());
}

public function testValidateLoginTrue() {
public function testValidateLoginIsValid() {
$this->assertTrue(is_array(validate_login("testuser1", "topsecret")));
}

public function testValidateLoginNull() {
public function testValidateLoginIsLocked() {
$this->assertNull(validate_login("testuser2", "topsecret"));

$this->assertEquals(
"Your Account is locked. " .
"Please contact your system administrator if you think, " .
"that this is an error.", $_REQUEST["error"]
);
}

public function testValidateLoginWrongPassword() {
$this->assertNull(validate_login("testuser1", "dasfalschepassword"));
$this->assertEquals(
"Username oder password incorrect!", $_REQUEST["error"]
);
}

public function testValidateLoginNonExistingUser() {
$this->assertNull(validate_login("ich_existiere_nicht", "dasfalschepassword"));
$this->assertEquals(
"Username oder password incorrect!", $_REQUEST["error"]
);
}

public function testGetUsersOnlineUserIsOnline() {
Expand Down

0 comments on commit 58fb459

Please sign in to comment.