]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/config/ConfigManagerTest.php
Optimize and cleanup imports
[github/shaarli/Shaarli.git] / tests / config / ConfigManagerTest.php
index 436e3d673850245ecd16c027716df25e94edc5ca..33830bc94bcc3584380b1a18259e4cf9ec101980 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+namespace Shaarli\Config;
 
 /**
  * Unit tests for Class ConfigManagerTest
@@ -6,7 +7,7 @@
  * 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
+class ConfigManagerTest extends \PHPUnit\Framework\TestCase
 {
     /**
      * @var ConfigManager
@@ -80,10 +81,22 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('testSetWriteGetNested', $this->conf->get('foo.bar.key.stuff'));
     }
 
+    public function testSetDeleteNested()
+    {
+        $this->conf->set('foo.bar.key.stuff', 'testSetDeleteNested');
+        $this->assertTrue($this->conf->exists('foo.bar'));
+        $this->assertTrue($this->conf->exists('foo.bar.key.stuff'));
+        $this->assertEquals('testSetDeleteNested', $this->conf->get('foo.bar.key.stuff'));
+
+        $this->conf->remove('foo.bar');
+        $this->assertFalse($this->conf->exists('foo.bar.key.stuff'));
+        $this->assertFalse($this->conf->exists('foo.bar'));
+    }
+
     /**
      * Set with an empty key.
      *
-     * @expectedException Exception
+     * @expectedException \Exception
      * @expectedExceptionMessageRegExp #^Invalid setting key parameter. String expected, got.*#
      */
     public function testSetEmptyKey()
@@ -94,7 +107,7 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase
     /**
      * Set with an array key.
      *
-     * @expectedException Exception
+     * @expectedException \Exception
      * @expectedExceptionMessageRegExp #^Invalid setting key parameter. String expected, got.*#
      */
     public function testSetArrayKey()
@@ -102,10 +115,21 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase
         $this->conf->set(array('foo' => 'bar'), 'stuff');
     }
 
+    /**
+     * Remove with an empty key.
+     *
+     * @expectedException \Exception
+     * @expectedExceptionMessageRegExp #^Invalid setting key parameter. String expected, got.*#
+     */
+    public function testRmoveEmptyKey()
+    {
+        $this->conf->remove('');
+    }
+
     /**
      * Try to write the config without mandatory parameter (e.g. 'login').
      *
-     * @expectedException MissingFieldConfigException
+     * @expectedException Shaarli\Config\Exception\MissingFieldConfigException
      */
     public function testWriteMissingParameter()
     {