]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/utils/FakeConfigManager.php
Refactor login / ban authentication steps
[github/shaarli/Shaarli.git] / tests / utils / FakeConfigManager.php
index f29760cba846d0abc288594424d5cd6f3d065b23..85434de7b528861c436c430fff555013397dac95 100644 (file)
@@ -5,8 +5,41 @@
  */
 class FakeConfigManager
 {
-    public static function get($key)
+    protected $values = [];
+
+    /**
+     * Initialize with test values
+     *
+     * @param array $values Initial values
+     */
+    public function __construct($values = [])
+    {
+        $this->values = $values;
+    }
+
+    /**
+     * Set a given value
+     *
+     * @param string $key   Key of the value to set
+     * @param mixed  $value Value to set
+     */
+    public function set($key, $value)
+    {
+        $this->values[$key] = $value;
+    }
+
+    /**
+     * Get a given configuration value
+     *
+     * @param string $key Index of the value to retrieve
+     *
+     * @return mixed The value if set, else the name of the key
+     */
+    public function get($key)
     {
+        if (isset($this->values[$key])) {
+            return $this->values[$key];
+        }
         return $key;
     }
 }