]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - tests/utils/FakeConfigManager.php
Add test coverage for LoginManager methods
[github/shaarli/Shaarli.git] / tests / utils / FakeConfigManager.php
CommitLineData
dd883aaf
V
1<?php
2
3/**
4 * Fake ConfigManager
5 */
6class FakeConfigManager
7{
44acf706
V
8 protected $values = [];
9
10 /**
11 * Initialize with test values
12 *
13 * @param array $values Initial values
14 */
15 public function __construct($values = [])
16 {
17 $this->values = $values;
18 }
19
20 /**
21 * Set a given value
22 *
23 * @param string $key Key of the value to set
24 * @param mixed $value Value to set
25 */
26 public function set($key, $value)
27 {
28 $this->values[$key] = $value;
29 }
30
31 /**
32 * Get a given configuration value
33 *
34 * @param string $key Index of the value to retrieve
35 *
36 * @return mixed The value if set, else the name of the key
37 */
38 public function get($key)
dd883aaf 39 {
44acf706
V
40 if (isset($this->values[$key])) {
41 return $this->values[$key];
42 }
dd883aaf
V
43 return $key;
44 }
704637bf
V
45
46 /**
47 * Check if a setting exists
48 *
49 * @param string $setting Asked setting, keys separated with dots
50 *
51 * @return bool true if the setting exists, false otherwise
52 */
53 public function exists($setting)
54 {
55 return array_key_exists($setting, $this->values);
56 }
dd883aaf 57}