Compare commits
5 Commits
010914b7bd
...
4199faecb4
Author | SHA1 | Date |
---|---|---|
tracer | 4199faecb4 | |
tracer | 059e3934f9 | |
tracer | f45dd8fbc1 | |
tracer | c1a54aa23e | |
tracer | d2f733d8c2 |
|
@ -0,0 +1,11 @@
|
|||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('Do nothing') {
|
||||
steps {
|
||||
sh '/bin/true'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,10 +30,12 @@ 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
|
||||
);
|
||||
|
@ -121,6 +123,7 @@ class DatabaseConnection
|
|||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -136,7 +139,7 @@ class DatabaseConnection
|
|||
}
|
||||
|
||||
/**
|
||||
* @return \PDO
|
||||
* @return PDO
|
||||
*/
|
||||
public function getConnection(): PDO
|
||||
{
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
namespace Unit\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;
|
||||
|
||||
|
@ -19,7 +21,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 = '')
|
|
@ -0,0 +1,43 @@
|
|||
<?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);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
namespace Unit\Controller;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
Loading…
Reference in New Issue