From b862611433fe0592ffcf7cd5f1ce34b011e9c566 Mon Sep 17 00:00:00 2001 From: tracer Date: Sun, 6 Feb 2022 17:41:04 +0100 Subject: [PATCH] added Logger and config Signed-off-by: tracer --- tests/App/Repository/DomainRepositoryTest.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/App/Repository/DomainRepositoryTest.php b/tests/App/Repository/DomainRepositoryTest.php index d2bc9c1..f663067 100644 --- a/tests/App/Repository/DomainRepositoryTest.php +++ b/tests/App/Repository/DomainRepositoryTest.php @@ -26,7 +26,7 @@ class DomainRepositoryTest extends TestCase private string $localZonesDir; private string $namedConfLocalFile; - private $log; + private Logger $log; /** * @param int|string $dataName @@ -38,7 +38,7 @@ class DomainRepositoryTest extends TestCase { parent::__construct(name: $name, data: $data, dataName: $dataName); - $dateFormat = "Y:m:d H:i:s"; + $dateFormat = "Y-m-d H:i:s"; $output = "%datetime% %channel%.%level_name% %message%\n"; // %context% %extra% $formatter = new LineFormatter(format: $output, dateFormat: $dateFormat); @@ -61,6 +61,13 @@ class DomainRepositoryTest extends TestCase $containerBuilder = new ContainerBuilder(); $containerBuilder->addDefinitions([ DatabaseConnection::class => autowire()->constructorParameter(parameter: 'config', value: $config), + DomainController::class => autowire() + ->constructorParameter(parameter: 'config', value: $config) + ->constructorParameter(parameter: 'log', value: $this->log), + DomainRepository::class => autowire() + ->constructorParameter(parameter: 'config', value: $config) + ->constructorParameter(parameter: 'log', value: $this->log), + ]); $this->container = $containerBuilder->build(); @@ -89,7 +96,9 @@ class DomainRepositoryTest extends TestCase $this->domainRepository->insert(domain: $domain); $this->domainController->createZoneFile(domain: $domain); + // now get the persisted domain with id $domainTest = $this->domainRepository->findByName(name: 'inserttest.org'); + $this->assertIsNotBool(actual: $domainTest); $this->assertEquals(expected: 'inserttest.org', actual: $domainTest->getName()); @@ -111,7 +120,7 @@ class DomainRepositoryTest extends TestCase // clean up - $this->domainRepository->delete(id: $domainTest->getId()); + $this->domainRepository->delete(domain: $domainTest); } @@ -132,7 +141,7 @@ class DomainRepositoryTest extends TestCase // domain is valid and created // now delete and check for cleanup - $this->domainRepository->delete(id: $domainTest->getId()); + $this->domainRepository->delete(domain: $domainTest); $this->domainController->deleteZone(domain: $domainTest);