diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-01-12 19:50:48 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-02-15 20:30:24 +0100 |
commit | 510377d2cb4b12d1a421e8a88bd7edb86f223451 (patch) | |
tree | 6cea29c199fc1b29ccfb78f902313019f6f9d95e /tests/Updater/DummyUpdater.php | |
parent | 268a2e52659964fb7d033a1bb4d1490bf8cc49bf (diff) | |
download | Shaarli-510377d2cb4b12d1a421e8a88bd7edb86f223451.tar.gz Shaarli-510377d2cb4b12d1a421e8a88bd7edb86f223451.tar.zst Shaarli-510377d2cb4b12d1a421e8a88bd7edb86f223451.zip |
Introduce the Updater class which
* contains methods designed to be run once.
* is able to upgrade the datastore or the configuration.
* is based on methods names, stored in a text file with ';' separator (updates.txt).
* begins with existing function 'mergeDeprecatedConfigFile()' (options.php).
Diffstat (limited to 'tests/Updater/DummyUpdater.php')
-rw-r--r-- | tests/Updater/DummyUpdater.php | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/Updater/DummyUpdater.php b/tests/Updater/DummyUpdater.php new file mode 100644 index 00000000..e9ef2aaa --- /dev/null +++ b/tests/Updater/DummyUpdater.php | |||
@@ -0,0 +1,68 @@ | |||
1 | <?php | ||
2 | |||
3 | require_once 'application/Updater.php'; | ||
4 | |||
5 | /** | ||
6 | * Class DummyUpdater. | ||
7 | * Extends Updater to add update method designed for unit tests. | ||
8 | */ | ||
9 | class DummyUpdater extends Updater | ||
10 | { | ||
11 | /** | ||
12 | * Object constructor. | ||
13 | * | ||
14 | * @param array $doneUpdates Updates which are already done. | ||
15 | * @param array $config Shaarli's configuration array. | ||
16 | * @param LinkDB $linkDB LinkDB instance. | ||
17 | * @param boolean $isLoggedIn True if the user is logged in. | ||
18 | */ | ||
19 | public function __construct($doneUpdates, $config, $linkDB, $isLoggedIn) | ||
20 | { | ||
21 | parent::__construct($doneUpdates, $config, $linkDB, $isLoggedIn); | ||
22 | |||
23 | // Retrieve all update methods. | ||
24 | // For unit test, only retrieve final methods, | ||
25 | $class = new ReflectionClass($this); | ||
26 | $this->methods = $class->getMethods(ReflectionMethod::IS_FINAL); | ||
27 | } | ||
28 | |||
29 | /** | ||
30 | * Update method 1. | ||
31 | * | ||
32 | * @return bool true. | ||
33 | */ | ||
34 | private final function updateMethodDummy1() | ||
35 | { | ||
36 | return true; | ||
37 | } | ||
38 | |||
39 | /** | ||
40 | * Update method 2. | ||
41 | * | ||
42 | * @return bool true. | ||
43 | */ | ||
44 | private final function updateMethodDummy2() | ||
45 | { | ||
46 | return true; | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * Update method 3. | ||
51 | * | ||
52 | * @return bool true. | ||
53 | */ | ||
54 | private final function updateMethodDummy3() | ||
55 | { | ||
56 | return true; | ||
57 | } | ||
58 | |||
59 | /** | ||
60 | * Update method 4, raise an exception. | ||
61 | * | ||
62 | * @throws Exception error. | ||
63 | */ | ||
64 | private final function updateMethodException() | ||
65 | { | ||
66 | throw new Exception('whatever'); | ||
67 | } | ||
68 | } | ||