]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/config/ConfigManagerTest.php
Introduce a configuration manager (not plugged yet)
[github/shaarli/Shaarli.git] / tests / config / ConfigManagerTest.php
diff --git a/tests/config/ConfigManagerTest.php b/tests/config/ConfigManagerTest.php
new file mode 100644 (file)
index 0000000..1b6358f
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+
+/**
+ * Unit tests for Class ConfigManagerTest
+ *
+ * Note: it only test the manager with ConfigJson,
+ *  ConfigPhp is only a workaround to handle the transition to JSON type.
+ */
+class ConfigManagerTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var ConfigManager
+     */
+    protected $conf;
+
+    public function setUp()
+    {
+        ConfigManager::$CONFIG_FILE = 'tests/config/config';
+        $this->conf = ConfigManager::getInstance();
+    }
+
+    public function tearDown()
+    {
+        @unlink($this->conf->getConfigFile());
+    }
+
+    public function testSetWriteGet()
+    {
+        // This won't work with ConfigPhp.
+        $this->markTestIncomplete();
+
+        $this->conf->set('paramInt', 42);
+        $this->conf->set('paramString', 'value1');
+        $this->conf->set('paramBool', false);
+        $this->conf->set('paramArray', array('foo' => 'bar'));
+        $this->conf->set('paramNull', null);
+
+        $this->conf->write(true);
+        $this->conf->reload();
+
+        $this->assertEquals(42, $this->conf->get('paramInt'));
+        $this->assertEquals('value1', $this->conf->get('paramString'));
+        $this->assertFalse($this->conf->get('paramBool'));
+        $this->assertEquals(array('foo' => 'bar'), $this->conf->get('paramArray'));
+        $this->assertEquals(null, $this->conf->get('paramNull'));
+    }
+    
+}
\ No newline at end of file