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