diff options
author | ArthurHoaro <arthur@hoa.ro> | 2019-07-27 12:30:33 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2019-07-27 12:30:33 +0200 |
commit | 1b8ed48a0d3964186f4d66d443783f4d250e7147 (patch) | |
tree | 23597f312507ba0c1b461755b9aa086106374a4d /tests/updater/DummyUpdater.php | |
parent | 1aa24ed8d2974cda98733f74b36844b02942cc11 (diff) | |
parent | ed3365325d231e044dedc32608fde87b1b39fa34 (diff) | |
download | Shaarli-1b8ed48a0d3964186f4d66d443783f4d250e7147.tar.gz Shaarli-1b8ed48a0d3964186f4d66d443783f4d250e7147.tar.zst Shaarli-1b8ed48a0d3964186f4d66d443783f4d250e7147.zip |
Merge tag 'v0.11.0' into latest
Release v0.11.0
Diffstat (limited to 'tests/updater/DummyUpdater.php')
-rw-r--r-- | tests/updater/DummyUpdater.php | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/updater/DummyUpdater.php b/tests/updater/DummyUpdater.php new file mode 100644 index 00000000..9e866f1f --- /dev/null +++ b/tests/updater/DummyUpdater.php | |||
@@ -0,0 +1,73 @@ | |||
1 | <?php | ||
2 | namespace Shaarli\Updater; | ||
3 | |||
4 | use Exception; | ||
5 | use ReflectionClass; | ||
6 | use ReflectionMethod; | ||
7 | use Shaarli\Bookmark\LinkDB; | ||
8 | use Shaarli\Config\ConfigManager; | ||
9 | |||
10 | /** | ||
11 | * Class DummyUpdater. | ||
12 | * Extends updater to add update method designed for unit tests. | ||
13 | */ | ||
14 | class DummyUpdater extends Updater | ||
15 | { | ||
16 | /** | ||
17 | * Object constructor. | ||
18 | * | ||
19 | * @param array $doneUpdates Updates which are already done. | ||
20 | * @param LinkDB $linkDB LinkDB instance. | ||
21 | * @param ConfigManager $conf Configuration Manager instance. | ||
22 | * @param boolean $isLoggedIn True if the user is logged in. | ||
23 | */ | ||
24 | public function __construct($doneUpdates, $linkDB, $conf, $isLoggedIn) | ||
25 | { | ||
26 | parent::__construct($doneUpdates, $linkDB, $conf, $isLoggedIn); | ||
27 | |||
28 | // Retrieve all update methods. | ||
29 | // For unit test, only retrieve final methods, | ||
30 | $class = new ReflectionClass($this); | ||
31 | $this->methods = $class->getMethods(ReflectionMethod::IS_FINAL); | ||
32 | } | ||
33 | |||
34 | /** | ||
35 | * Update method 1. | ||
36 | * | ||
37 | * @return bool true. | ||
38 | */ | ||
39 | final private function updateMethodDummy1() | ||
40 | { | ||
41 | return true; | ||
42 | } | ||
43 | |||
44 | /** | ||
45 | * Update method 2. | ||
46 | * | ||
47 | * @return bool true. | ||
48 | */ | ||
49 | final private function updateMethodDummy2() | ||
50 | { | ||
51 | return true; | ||
52 | } | ||
53 | |||
54 | /** | ||
55 | * Update method 3. | ||
56 | * | ||
57 | * @return bool true. | ||
58 | */ | ||
59 | final private function updateMethodDummy3() | ||
60 | { | ||
61 | return true; | ||
62 | } | ||
63 | |||
64 | /** | ||
65 | * Update method 4, raise an exception. | ||
66 | * | ||
67 | * @throws Exception error. | ||
68 | */ | ||
69 | final private function updateMethodException() | ||
70 | { | ||
71 | throw new Exception('whatever'); | ||
72 | } | ||
73 | } | ||