aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/legacy/LegacyDummyUpdater.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-01-17 21:34:12 +0100
committerArthurHoaro <arthur@hoa.ro>2020-01-18 09:56:32 +0100
commite26e2060f5470ce8bf4c5973284bae07b8af170a (patch)
treeadf8512f93f5559ba87d0c9931969ae4ebea7133 /tests/legacy/LegacyDummyUpdater.php
parentcf92b4dd1521241eefc58eaf6dcd202cd83969d8 (diff)
downloadShaarli-e26e2060f5470ce8bf4c5973284bae07b8af170a.tar.gz
Shaarli-e26e2060f5470ce8bf4c5973284bae07b8af170a.tar.zst
Shaarli-e26e2060f5470ce8bf4c5973284bae07b8af170a.zip
Add and update unit test for the new system (Bookmark + Service)
See #1307
Diffstat (limited to 'tests/legacy/LegacyDummyUpdater.php')
-rw-r--r--tests/legacy/LegacyDummyUpdater.php74
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
2namespace Shaarli\Updater;
3
4use Exception;
5use ReflectionClass;
6use ReflectionMethod;
7use Shaarli\Config\ConfigManager;
8use Shaarli\Legacy\LegacyLinkDB;
9use Shaarli\Legacy\LegacyUpdater;
10
11/**
12 * Class LegacyDummyUpdater.
13 * Extends updater to add update method designed for unit tests.
14 */
15class 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}