From 44acf706812bc77812e6648c2cc28af36e172a14 Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Wed, 25 Oct 2017 23:03:31 +0200 Subject: Refactor login / ban authentication steps Relates to https://github.com/shaarli/Shaarli/issues/324 Added: - Add the `LoginManager` class to manage logins and bans Changed: - Refactor IP ban management - Simplify logic - Avoid using globals, inject dependencies Fixed: - Use `ban_duration` instead of `ban_after` when setting a new ban Signed-off-by: VirtualTam --- tests/utils/FakeConfigManager.php | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'tests/utils') diff --git a/tests/utils/FakeConfigManager.php b/tests/utils/FakeConfigManager.php index f29760cb..85434de7 100644 --- a/tests/utils/FakeConfigManager.php +++ b/tests/utils/FakeConfigManager.php @@ -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; } } -- cgit v1.2.3