Browse Source

Harden API for Configure, correct doc blocks.

euromark 11 years ago
parent
commit
7d6bf7f428
2 changed files with 21 additions and 4 deletions
  1. 3 3
      src/Core/Configure.php
  2. 18 1
      tests/TestCase/Core/ConfigureTest.php

+ 3 - 3
src/Core/Configure.php

@@ -129,7 +129,7 @@ class Configure
      * @param string $var Variable name to check for
      * @return bool True if variable is there
      */
-    public static function check($var = null)
+    public static function check($var)
     {
         if (empty($var)) {
             return false;
@@ -150,7 +150,7 @@ class Configure
      * @return void
      * @link http://book.cakephp.org/3.0/en/development/configuration.html#deleting-configuration-data
      */
-    public static function delete($var = null)
+    public static function delete($var)
     {
         static::$_values = Hash::remove(static::$_values, $var);
     }
@@ -202,7 +202,7 @@ class Configure
     /**
      * Gets the names of the configured Engine objects.
      *
-     * @param string $name Engine name.
+     * @param string|null $name Engine name.
      * @return array Array of the configured Engine objects.
      */
     public static function configured($name = null)

+ 18 - 1
tests/TestCase/Core/ConfigureTest.php

@@ -237,7 +237,8 @@ class ConfigureTest extends TestCase
      */
     public function testCheckEmpty()
     {
-        $this->assertFalse(Configure::check());
+        $this->assertFalse(Configure::check(''));
+        $this->assertFalse(Configure::check(null));
     }
 
     /**
@@ -551,4 +552,20 @@ class ConfigureTest extends TestCase
         $expected = ['key2' => 'value2'];
         $this->assertEquals($expected, $result);
     }
+
+    /**
+     * testConsumeEmpty
+     *
+     * @return void
+     */
+    public function testConsumeEmpty()
+    {
+        Configure::write('Test', ['key' => 'value', 'key2' => 'value2']);
+
+        $result = Configure::consume('');
+        $this->assertNull($result);
+
+        $result = Configure::consume(null);
+        $this->assertNull($result);
+    }
 }