]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/config/ConfigPhpTest.php
Optimize and cleanup imports
[github/shaarli/Shaarli.git] / tests / config / ConfigPhpTest.php
index 0f849bd5b53c443089410faaff1c6398d4ee2bab..67d878cee31cc88a61cf0cad4b92eb8d08e2b044 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-require_once 'application/config/ConfigPhp.php';
+namespace Shaarli\Config;
 
 /**
  * Class ConfigPhpTest
  */
-class ConfigPhpTest extends PHPUnit_Framework_TestCase
+class ConfigPhpTest extends \PHPUnit\Framework\TestCase
 {
     /**
      * @var ConfigPhp
@@ -22,7 +21,7 @@ class ConfigPhpTest extends PHPUnit_Framework_TestCase
      */
     public function testRead()
     {
-        $conf = $this->configIO->read('tests/config/php/configOK');
+        $conf = $this->configIO->read('tests/utils/config/configPhp.php');
         $this->assertEquals('root', $conf['login']);
         $this->assertEquals('lala', $conf['redirector']);
         $this->assertEquals('data/datastore.php', $conf['config']['DATASTORE']);
@@ -37,12 +36,26 @@ class ConfigPhpTest extends PHPUnit_Framework_TestCase
         $this->assertEquals(array(), $this->configIO->read('nope'));
     }
 
+    /**
+     * Read an empty existent config file -> array with blank default values.
+     */
+    public function testReadEmpty()
+    {
+        $dataFile = 'tests/utils/config/emptyConfigPhp.php';
+        $conf = $this->configIO->read($dataFile);
+        $this->assertEmpty($conf['login']);
+        $this->assertEmpty($conf['title']);
+        $this->assertEmpty($conf['titleLink']);
+        $this->assertEmpty($conf['config']);
+        $this->assertEmpty($conf['plugins']);
+    }
+
     /**
      * Write a new config file.
      */
     public function testWriteNew()
     {
-        $dataFile = 'tests/config/php/configWrite';
+        $dataFile = 'tests/utils/config/configWrite.php';
         $data = array(
             'login' => 'root',
             'redirector' => 'lala',
@@ -60,8 +73,8 @@ $GLOBALS[\'redirector\'] = \'lala\';
 $GLOBALS[\'config\'][\'DATASTORE\'] = \'data/datastore.php\';
 $GLOBALS[\'plugins\'][\'WALLABAG_VERSION\'] = \'1\';
 ';
-        $this->assertEquals($expected, file_get_contents($dataFile .'.php'));
-        unlink($dataFile .'.php');
+        $this->assertEquals($expected, file_get_contents($dataFile));
+        unlink($dataFile);
     }
 
     /**
@@ -69,14 +82,14 @@ $GLOBALS[\'plugins\'][\'WALLABAG_VERSION\'] = \'1\';
      */
     public function testOverwrite()
     {
-        $source = 'tests/config/php/configOK.php';
-        $dest = 'tests/config/php/configOverwrite';
-        copy($source, $dest . '.php');
+        $source = 'tests/utils/config/configPhp.php';
+        $dest = 'tests/utils/config/configOverwrite.php';
+        copy($source, $dest);
         $conf = $this->configIO->read($dest);
         $conf['redirector'] = 'blabla';
         $this->configIO->write($dest, $conf);
         $conf = $this->configIO->read($dest);
         $this->assertEquals('blabla', $conf['redirector']);
-        unlink($dest .'.php');
+        unlink($dest);
     }
 }