Compare commits
No commits in common. "4199faecb41cda7a0a4d67610d284545e8e6e212" and "010914b7bdd8bea95d8ca4035015e7c941e298ff" have entirely different histories.
4199faecb4
...
010914b7bd
|
@ -1,11 +0,0 @@
|
||||||
pipeline {
|
|
||||||
agent any
|
|
||||||
|
|
||||||
stages {
|
|
||||||
stage('Do nothing') {
|
|
||||||
steps {
|
|
||||||
sh '/bin/true'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -30,12 +30,10 @@ class DatabaseConnection
|
||||||
$dbUser = $this->configController->getConfig(configKey: 'dbUser');
|
$dbUser = $this->configController->getConfig(configKey: 'dbUser');
|
||||||
$dbPassword = $this->configController->getConfig(configKey: 'dbPassword');
|
$dbPassword = $this->configController->getConfig(configKey: 'dbPassword');
|
||||||
|
|
||||||
|
|
||||||
if (!$this->configController->getConfig(configKey: 'test')) {
|
|
||||||
// TODO create config => encryption key
|
// TODO create config => encryption key
|
||||||
try {
|
try {
|
||||||
$this->dbConnection = new PDO(
|
$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,
|
username: $dbUser,
|
||||||
password: $dbPassword
|
password: $dbPassword
|
||||||
);
|
);
|
||||||
|
@ -123,7 +121,6 @@ class DatabaseConnection
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,7 +136,7 @@ class DatabaseConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return PDO
|
* @return \PDO
|
||||||
*/
|
*/
|
||||||
public function getConnection(): PDO
|
public function getConnection(): PDO
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Unit\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Controller\DatabaseConnection;
|
|
||||||
use App\Repository\NameserverRepository;
|
use App\Repository\NameserverRepository;
|
||||||
use DI\Container;
|
use DI\Container;
|
||||||
use DI\ContainerBuilder;
|
use DI\ContainerBuilder;
|
||||||
use Exception;
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use function DI\autowire;
|
use function DI\autowire;
|
||||||
|
|
||||||
|
@ -21,7 +19,7 @@ class BindApiTestController extends TestCase
|
||||||
/**
|
/**
|
||||||
* @param int|string $dataName
|
* @param int|string $dataName
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws \Exception
|
||||||
* @internal This method is not covered by the backward compatibility promise for PHPUnit
|
* @internal This method is not covered by the backward compatibility promise for PHPUnit
|
||||||
*/
|
*/
|
||||||
public function __construct(?string $name = null, array $data = [], $dataName = '')
|
public function __construct(?string $name = null, array $data = [], $dataName = '')
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Unit\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue