X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fconfig%2FConfigPhpTest.php;h=7bf9fe64933925d23c4f96362894c512ea918997;hb=a5a9cf23acd1248585173aa32757d9720b5f2d62;hp=0f849bd5b53c443089410faaff1c6398d4ee2bab;hpb=59404d7909b21682ec0782778452a8a70e38b25e;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/config/ConfigPhpTest.php b/tests/config/ConfigPhpTest.php index 0f849bd5..7bf9fe64 100644 --- a/tests/config/ConfigPhpTest.php +++ b/tests/config/ConfigPhpTest.php @@ -1,18 +1,21 @@ configIO = new ConfigPhp(); } @@ -22,7 +25,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 +40,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 +77,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 +86,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); } }