Compare commits

..

No commits in common. "4199faecb41cda7a0a4d67610d284545e8e6e212" and "010914b7bdd8bea95d8ca4035015e7c941e298ff" have entirely different histories.

5 changed files with 95 additions and 154 deletions

11
Jenkinsfile vendored
View File

@ -1,11 +0,0 @@
pipeline {
agent any
stages {
stage('Do nothing') {
steps {
sh '/bin/true'
}
}
}
}

View File

@ -30,12 +30,10 @@ class DatabaseConnection
$dbUser = $this->configController->getConfig(configKey: 'dbUser');
$dbPassword = $this->configController->getConfig(configKey: 'dbPassword');
if (!$this->configController->getConfig(configKey: 'test')) {
// TODO create config => encryption key
try {
$this->dbConnection = new PDO(
dsn: "mysql:host=$dbHost;port=$dbPort;charset=utf8mb4;dbname=$dbDatabase",
dsn : "mysql:host=$dbHost;port=$dbPort;charset=utf8mb4;dbname=$dbDatabase",
username: $dbUser,
password: $dbPassword
);
@ -123,7 +121,6 @@ class DatabaseConnection
exit(1);
}
}
}
/**
@ -139,7 +136,7 @@ class DatabaseConnection
}
/**
* @return PDO
* @return \PDO
*/
public function getConnection(): PDO
{

View File

@ -1,12 +1,10 @@
<?php
namespace Unit\Controller;
namespace App\Controller;
use App\Controller\DatabaseConnection;
use App\Repository\NameserverRepository;
use DI\Container;
use DI\ContainerBuilder;
use Exception;
use PHPUnit\Framework\TestCase;
use function DI\autowire;
@ -21,7 +19,7 @@ class BindApiTestController extends TestCase
/**
* @param int|string $dataName
*
* @throws Exception
* @throws \Exception
* @internal This method is not covered by the backward compatibility promise for PHPUnit
*/
public function __construct(?string $name = null, array $data = [], $dataName = '')

View File

@ -1,6 +1,6 @@
<?php
namespace Unit\Controller;
namespace App\Controller;
use PHPUnit\Framework\TestCase;

View File

@ -1,43 +0,0 @@
<?php
namespace Unit\Controller;
use App\Controller\ConfigController;
use App\Controller\DatabaseConnection;
use PDO;
use PDOException;
/**
* @covers \App\Controller\DatabaseConnection
* @covers \App\Controller\ConfigController
*/
class DatabaseConnectionTest extends BindApiTestController
{
private PDO $dbConnection;
public function testGetConnection()
{
$configController = new ConfigController(test: true);
$dbHost = $configController->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);
}
}