X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Futils%2FFakeConfigManager.php;h=360b34a981c91d797d29d769dd858bb1c032a36a;hb=8edd7f15886620b07064aa889aea05c5acbc0e58;hp=f29760cba846d0abc288594424d5cd6f3d065b23;hpb=101b935de4852308a238c04bf5a08d01a6ebe45c;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/utils/FakeConfigManager.php b/tests/utils/FakeConfigManager.php index f29760cb..360b34a9 100644 --- a/tests/utils/FakeConfigManager.php +++ b/tests/utils/FakeConfigManager.php @@ -5,8 +5,53 @@ */ 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; } + + /** + * Check if a setting exists + * + * @param string $setting Asked setting, keys separated with dots + * + * @return bool true if the setting exists, false otherwise + */ + public function exists($setting) + { + return array_key_exists($setting, $this->values); + } }