diff --git a/tests/Unit/Controller/DatabaseConnectionTest.php b/tests/Unit/Controller/DatabaseConnectionTest.php new file mode 100644 index 0000000..0a68253 --- /dev/null +++ b/tests/Unit/Controller/DatabaseConnectionTest.php @@ -0,0 +1,43 @@ +getConfig(configKey: 'dbHost'); + $dbPort = $configController->getConfig(configKey: 'dbPort'); + $dbDatabase = $configController->getConfig(configKey: 'dbDatabase'); + $dbUser = $configController->getConfig(configKey: 'dbUser'); + $dbPassword = $configController->getConfig(configKey: 'dbPassword'); + + try { + $this->dbConnection = new PDO( + dsn: "mysql:host=$dbHost;port=$dbPort;charset=utf8mb4;dbname=$dbDatabase", + username: $dbUser, + password: $dbPassword + ); + } catch (PDOException $e) { + $this->fail(message: $e->getMessage()); + } + + $databaseConnection = new DatabaseConnection(configController: $configController); + + self::assertEquals(expected: $databaseConnection->getConnection(), actual: $this->dbConnection); + } +}