]> git.immae.eu Git - github/shaarli/Shaarli.git/blob - tests/updater/DummyUpdater.php
Compatibility with PHP 8
[github/shaarli/Shaarli.git] / tests / updater / DummyUpdater.php
1 <?php
2 namespace Shaarli\Updater;
3
4 use Exception;
5 use ReflectionClass;
6 use ReflectionMethod;
7 use Shaarli\Bookmark\BookmarkFileService;
8 use Shaarli\Bookmark\LinkDB;
9 use Shaarli\Config\ConfigManager;
10
11 /**
12 * Class DummyUpdater.
13 * Extends updater to add update method designed for unit tests.
14 */
15 class DummyUpdater extends Updater
16 {
17 /**
18 * Object constructor.
19 *
20 * @param array $doneUpdates Updates which are already done.
21 * @param BookmarkFileService $bookmarkService 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, $bookmarkService, $conf, $isLoggedIn)
26 {
27 parent::__construct($doneUpdates, $bookmarkService, $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 protected function updateMethodDummy1()
41 {
42 return true;
43 }
44
45 /**
46 * Update method 2.
47 *
48 * @return bool true.
49 */
50 final protected function updateMethodDummy2()
51 {
52 return true;
53 }
54
55 /**
56 * Update method 3.
57 *
58 * @return bool true.
59 */
60 final protected function updateMethodDummy3()
61 {
62 return true;
63 }
64
65 /**
66 * Update method 4, raise an exception.
67 *
68 * @throws Exception error.
69 */
70 final protected function updateMethodException()
71 {
72 throw new Exception('whatever');
73 }
74 }