From e0816304f062418b67c334759f67f936279087b2 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Fri, 3 Feb 2017 17:40:10 +0100 Subject: [PATCH] [BUGFIX] Load an existing config file in the unit tests The unit tests still do not pass completely as they cannot connect to any DB on Travis yet. This will be part of a separate PR. (And unit tests should not connect to a real database.) --- core/tests/AdminTest.php | 1 + core/tests/ListManagerTest.php | 2 +- core/tests/ListModelTest.php | 2 +- core/tests/PassTest.php | 1 + core/tests/ServicesTest.php | 7 +------ core/tests/SubscriberManagerTest.php | 1 + core/tests/SubscriberModelTest.php | 2 +- core/tests/phpunit-bootstrap.php | 2 +- 8 files changed, 8 insertions(+), 10 deletions(-) diff --git a/core/tests/AdminTest.php b/core/tests/AdminTest.php index e047d07f..6950c32b 100644 --- a/core/tests/AdminTest.php +++ b/core/tests/AdminTest.php @@ -29,6 +29,7 @@ public function setUp() // Load the service config file, which is in YAML format $loader->load('../services.yml'); // Get objects from container + $this->container->setParameter('config.configfile', __DIR__ . '/../../config.ini.dist'); $this->config = $this->container->get('Config'); $this->admin = $this->container->get('Admin'); diff --git a/core/tests/ListManagerTest.php b/core/tests/ListManagerTest.php index e6306999..c0f9496e 100644 --- a/core/tests/ListManagerTest.php +++ b/core/tests/ListManagerTest.php @@ -27,7 +27,7 @@ public function setUp() // Load the service config file, which is in YAML format $loader->load('../services.yml'); // Set necessary config class parameter - $this->container->setParameter('config.configfile', '/var/www/pl4/config.ini'); + $this->container->setParameter('config.configfile', __DIR__ . '/../../config.ini.dist'); // Get objects from container $this->scrEntity = $this->container->get('SubscriberEntity'); $this->listManager = $this->container->get('ListManager'); diff --git a/core/tests/ListModelTest.php b/core/tests/ListModelTest.php index 322d676e..fa05553e 100644 --- a/core/tests/ListModelTest.php +++ b/core/tests/ListModelTest.php @@ -26,7 +26,7 @@ public function setUp() // Load the service config file, which is in YAML format $loader->load('../services.yml'); // Set necessary config class parameter - $this->container->setParameter('config.configfile', '/var/www/pl4/config.ini'); + $this->container->setParameter('config.configfile', __DIR__ . '/../../config.ini.dist'); // Get objects from container $this->listModel = $this->container->get('ListModel'); } diff --git a/core/tests/PassTest.php b/core/tests/PassTest.php index a0dc4f94..0062d90a 100644 --- a/core/tests/PassTest.php +++ b/core/tests/PassTest.php @@ -20,6 +20,7 @@ public function setUp() $loader = new YamlFileLoader($this->container, new FileLocator(__DIR__)); // Load the service config file, which is in YAML format $loader->load('../services.yml'); + $this->container->setParameter('config.configfile', __DIR__ . '/../../config.ini.dist'); // Get objects from container $this->pass = $this->container->get('Pass'); // Set default pwd for testing diff --git a/core/tests/ServicesTest.php b/core/tests/ServicesTest.php index 918e037e..5bbc0877 100644 --- a/core/tests/ServicesTest.php +++ b/core/tests/ServicesTest.php @@ -27,20 +27,15 @@ public function setUp() $loader = new YamlFileLoader($this->container, new FileLocator(__DIR__)); // Load the service config file, which is in YAML format $loader->load('../services.yml'); + $this->container->setParameter('config.configfile', __DIR__ . '/../../config.ini.dist'); } public function testConfigService() { - // Set service parameters - $this->container->setParameter('config.configfile', '/var/www/pl4/config.ini'); - $config = $this->container->get('Config'); } public function testPhplistService() { - // Set service parameters - $this->container->setParameter('config.configfile', '/var/www/pl4/config.ini'); - $config = $this->container->get('phpList'); } } diff --git a/core/tests/SubscriberManagerTest.php b/core/tests/SubscriberManagerTest.php index 186e3398..bfb8fb54 100644 --- a/core/tests/SubscriberManagerTest.php +++ b/core/tests/SubscriberManagerTest.php @@ -45,6 +45,7 @@ public function setUp() $loader = new YamlFileLoader($this->container, new FileLocator(__DIR__)); // Load the service config file, which is in YAML format $loader->load('../services.yml'); + $this->container->setParameter('config.configfile', __DIR__ . '/../../config.ini.dist'); $this->subscriberManager = $this->container->get('SubscriberManager'); } diff --git a/core/tests/SubscriberModelTest.php b/core/tests/SubscriberModelTest.php index a9e29754..1a5c10ec 100644 --- a/core/tests/SubscriberModelTest.php +++ b/core/tests/SubscriberModelTest.php @@ -29,7 +29,7 @@ public function setUp() $this->plainPass = 'easypassword'; // Instantiate config object - $this->configFile = dirname(__FILE__) . '/../../config.ini'; + $this->configFile = __DIR__ . '/../../config.ini.dist'; $this->config = new Config($this->configFile); // Instantiate remaining classes diff --git a/core/tests/phpunit-bootstrap.php b/core/tests/phpunit-bootstrap.php index 638b5c22..5c14296e 100644 --- a/core/tests/phpunit-bootstrap.php +++ b/core/tests/phpunit-bootstrap.php @@ -1,6 +1,6 @@