]>
Commit | Line | Data |
---|---|---|
510377d2 | 1 | <?php |
bcf056c9 | 2 | namespace Shaarli\Updater; |
510377d2 | 3 | |
bcf056c9 V |
4 | use Exception; |
5 | use ReflectionClass; | |
6 | use ReflectionMethod; | |
e26e2060 | 7 | use Shaarli\Bookmark\BookmarkFileService; |
f24896b2 | 8 | use Shaarli\Bookmark\LinkDB; |
bcf056c9 | 9 | use Shaarli\Config\ConfigManager; |
510377d2 A |
10 | |
11 | /** | |
12 | * Class DummyUpdater. | |
bcf056c9 | 13 | * Extends updater to add update method designed for unit tests. |
510377d2 A |
14 | */ |
15 | class DummyUpdater extends Updater | |
16 | { | |
17 | /** | |
18 | * Object constructor. | |
19 | * | |
e26e2060 A |
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. | |
510377d2 | 24 | */ |
e26e2060 | 25 | public function __construct($doneUpdates, $bookmarkService, $conf, $isLoggedIn) |
510377d2 | 26 | { |
e26e2060 | 27 | parent::__construct($doneUpdates, $bookmarkService, $conf, $isLoggedIn); |
510377d2 A |
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 | */ | |
067c2dd8 | 40 | final private function updateMethodDummy1() |
510377d2 A |
41 | { |
42 | return true; | |
43 | } | |
44 | ||
45 | /** | |
46 | * Update method 2. | |
47 | * | |
48 | * @return bool true. | |
49 | */ | |
067c2dd8 | 50 | final private function updateMethodDummy2() |
510377d2 A |
51 | { |
52 | return true; | |
53 | } | |
54 | ||
55 | /** | |
56 | * Update method 3. | |
57 | * | |
58 | * @return bool true. | |
59 | */ | |
067c2dd8 | 60 | final private function updateMethodDummy3() |
510377d2 A |
61 | { |
62 | return true; | |
63 | } | |
64 | ||
65 | /** | |
66 | * Update method 4, raise an exception. | |
67 | * | |
68 | * @throws Exception error. | |
69 | */ | |
067c2dd8 | 70 | final private function updateMethodException() |
510377d2 A |
71 | { |
72 | throw new Exception('whatever'); | |
73 | } | |
74 | } |