]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | use Shaarli\Bookmark\LinkDB; | |
4 | ||
5 | require_once 'application/Updater.php'; | |
6 | ||
7 | /** | |
8 | * Class DummyUpdater. | |
9 | * Extends Updater to add update method designed for unit tests. | |
10 | */ | |
11 | class DummyUpdater extends Updater | |
12 | { | |
13 | /** | |
14 | * Object constructor. | |
15 | * | |
16 | * @param array $doneUpdates Updates which are already done. | |
17 | * @param LinkDB $linkDB LinkDB instance. | |
18 | * @param ConfigManager $conf Configuration Manager instance. | |
19 | * @param boolean $isLoggedIn True if the user is logged in. | |
20 | */ | |
21 | public function __construct($doneUpdates, $linkDB, $conf, $isLoggedIn) | |
22 | { | |
23 | parent::__construct($doneUpdates, $linkDB, $conf, $isLoggedIn); | |
24 | ||
25 | // Retrieve all update methods. | |
26 | // For unit test, only retrieve final methods, | |
27 | $class = new ReflectionClass($this); | |
28 | $this->methods = $class->getMethods(ReflectionMethod::IS_FINAL); | |
29 | } | |
30 | ||
31 | /** | |
32 | * Update method 1. | |
33 | * | |
34 | * @return bool true. | |
35 | */ | |
36 | final private function updateMethodDummy1() | |
37 | { | |
38 | return true; | |
39 | } | |
40 | ||
41 | /** | |
42 | * Update method 2. | |
43 | * | |
44 | * @return bool true. | |
45 | */ | |
46 | final private function updateMethodDummy2() | |
47 | { | |
48 | return true; | |
49 | } | |
50 | ||
51 | /** | |
52 | * Update method 3. | |
53 | * | |
54 | * @return bool true. | |
55 | */ | |
56 | final private function updateMethodDummy3() | |
57 | { | |
58 | return true; | |
59 | } | |
60 | ||
61 | /** | |
62 | * Update method 4, raise an exception. | |
63 | * | |
64 | * @throws Exception error. | |
65 | */ | |
66 | final private function updateMethodException() | |
67 | { | |
68 | throw new Exception('whatever'); | |
69 | } | |
70 | } |