Update unit tests

This commit is contained in:
Frédéric Guillot 2019-01-30 22:25:57 -08:00
parent 83deec2e36
commit 928f80d569
3 changed files with 13 additions and 7 deletions

View File

@ -46,17 +46,24 @@ class DatabaseAuthTest extends Base
$this->assertFalse($provider->isValidSession());
$this->assertEquals(2, $userModel->create(array('username' => 'foobar')));
$this->assertEquals(2, $userModel->create(array('username' => 'user1')));
$this->assertEquals(3, $userModel->create(array('username' => 'user2')));
$_SESSION['user'] = array('id' => 2);
$_SESSION['user'] = array('id' => 2, 'role' => 'app-user');
$this->assertTrue($provider->isValidSession());
$_SESSION['user'] = array('id' => 3);
$_SESSION['user'] = array('id' => 4, 'role' => 'app-user');
$this->assertFalse($provider->isValidSession());
$this->assertTrue($userModel->disable(2));
$_SESSION['user'] = array('id' => 2);
$_SESSION['user'] = array('id' => 2, 'role' => 'app-user');
$this->assertFalse($provider->isValidSession());
$_SESSION['user'] = array('id' => 3, 'role' => 'app-user');
$this->assertTrue($provider->isValidSession());
$_SESSION['user'] = array('id' => 3, 'role' => 'app-admin');
$this->assertFalse($provider->isValidSession());
}
}

View File

@ -56,7 +56,7 @@ class AuthenticationManagerTest extends Base
$authManager = new AuthenticationManager($this->container);
$authManager->register(new DatabaseAuth($this->container));
$_SESSION['user'] = array('id' => 1, 'username' => 'test');
$_SESSION['user'] = array('id' => 1, 'username' => 'test', 'role' => 'app-admin');
$this->assertTrue($this->container['userSession']->isLogged());
$this->assertTrue($authManager->checkCurrentSession());
@ -67,7 +67,7 @@ class AuthenticationManagerTest extends Base
$authManager = new AuthenticationManager($this->container);
$authManager->register(new DatabaseAuth($this->container));
$_SESSION['user'] = array('id' => 42, 'username' => 'test');
$_SESSION['user'] = array('id' => 42, 'username' => 'test', 'role' => 'app-admin');
$this->assertTrue($this->container['userSession']->isLogged());
$this->assertFalse($authManager->checkCurrentSession());

View File

@ -60,7 +60,6 @@ class AuthenticationMiddlewareTest extends Base
->expects($this->never())
->method('execute');
$this->setExpectedException('Kanboard\Core\Controller\AccessForbiddenException');
$this->middleware->execute();
}