Skip to content

Commit

Permalink
test: Fix Test Cases
Browse files Browse the repository at this point in the history
  • Loading branch information
usernane committed Oct 28, 2024
1 parent c2e7da4 commit 6278b13
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions tests/webfiori/framework/test/session/SessionsManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ public function testDatabaseSession00() {
*/
public function testDatabaseSession01() {
$this->expectException(DatabaseException::class);
$this->expectExceptionMessage("1146 - Table 'testing_db.session_data' doesn't exist");
$conn = new ConnectionInfo('mysql', 'root', '123456', 'testing_db', '127.0.0.1');
$this->expectExceptionMessage("208 - [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'session_data'.");
$conn = new ConnectionInfo('mssql', 'sa', '1234567890@Eu', 'testing_db', 'localhost\SQLEXPRESS');
$conn->setName('sessions-connection');
App::getConfig()->addOrUpdateDBConnection($conn);
SessionsManager::setStorage(new DatabaseSessionStorage());
Expand All @@ -174,7 +174,7 @@ public function testDatabaseSession01() {
* @depends testInitSessionsDb
*/
public function testDatabaseSession02() {
$conn = new ConnectionInfo('mysql', 'root', '123456', 'testing_db', '127.0.0.1');
$conn = new ConnectionInfo('mssql', 'sa', '1234567890@Eu', 'testing_db', 'localhost\SQLEXPRESS');
$conn->setName('sessions-connection');
App::getConfig()->addOrUpdateDBConnection($conn);
SessionsManager::reset();
Expand Down Expand Up @@ -277,11 +277,12 @@ public function testDatabaseSession02() {
/**
* @test
* @depends testDatabaseSession02
* @depends testCloseDb00
*/
public function testDropDbTables00() {
$this->expectException(DatabaseException::class);
$this->expectExceptionMessage("1146 - Table 'testing_db.session_data' doesn't exist");
$conn = new ConnectionInfo('mysql', 'root', '123456', 'testing_db', '127.0.0.1');
$this->expectExceptionMessage("208 - [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'session_data'.");
$conn = new ConnectionInfo('mssql', 'sa', '1234567890@Eu', 'testing_db', 'localhost\SQLEXPRESS');
$conn->setName('sessions-connection');
App::getConfig()->addOrUpdateDBConnection($conn);
SessionsManager::reset();
Expand All @@ -308,22 +309,23 @@ public function testGetSessionIDFromRequest() {
* @depends testDatabaseSession01
*/
public function testInitSessionsDb() {
$conn = new ConnectionInfo('mysql', 'root', '123456', 'testing_db', '127.0.0.1');
$conn = new ConnectionInfo('mssql', 'sa', '1234567890@Eu', 'testing_db', 'localhost\SQLEXPRESS');
$conn->setName('sessions-connection');
App::getConfig()->addOrUpdateDBConnection($conn);
SessionsManager::reset();
$sto = new DatabaseSessionStorage();
$sto->getController()->createTables()->execute();
// $sto->getController()->table('session_data')->select()->execute();
// $sto->getController()->table('sessions')->select()->execute();
$sto->getController()->clear();
$sto->getController()->table('session_data')->selectCount()->execute();
$sto->getController()->table('sessions')->selectCount()->execute();
$this->assertTrue(true);
}
/**
* @test
* @depends testInitSessionsDb
*/
public function testDbSessions00() {
SessionsManager::start('hello', [
SessionsManager::start('hello-x', [

]);
$activeSesstion = SessionsManager::getActiveSession();
Expand All @@ -332,7 +334,7 @@ public function testDbSessions00() {
$this->assertTrue($activeSesstion->isRunning());

$this->assertNotNull($activeSesstion);
$this->assertEquals('hello', $activeSesstion->getName());
$this->assertEquals('hello-x', $activeSesstion->getName());
$this->assertEquals(7200, $activeSesstion->getDuration());
$this->assertEquals(SessionStatus::NEW, $activeSesstion->getStatus());

Expand Down

0 comments on commit 6278b13

Please sign in to comment.