]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - tests/updater/DummyUpdater.php
namespacing: \Shaarli\Updater
[github/shaarli/Shaarli.git] / tests / updater / DummyUpdater.php
CommitLineData
510377d2 1<?php
bcf056c9 2namespace Shaarli\Updater;
510377d2 3
bcf056c9
V
4use Exception;
5use ReflectionClass;
6use ReflectionMethod;
f24896b2 7use Shaarli\Bookmark\LinkDB;
bcf056c9 8use Shaarli\Config\ConfigManager;
510377d2
A
9
10/**
11 * Class DummyUpdater.
bcf056c9 12 * Extends updater to add update method designed for unit tests.
510377d2
A
13 */
14class DummyUpdater extends Updater
15{
16 /**
17 * Object constructor.
18 *
278d9ee2
A
19 * @param array $doneUpdates Updates which are already done.
20 * @param LinkDB $linkDB LinkDB instance.
21 * @param ConfigManager $conf Configuration Manager instance.
22 * @param boolean $isLoggedIn True if the user is logged in.
510377d2 23 */
278d9ee2 24 public function __construct($doneUpdates, $linkDB, $conf, $isLoggedIn)
510377d2 25 {
278d9ee2 26 parent::__construct($doneUpdates, $linkDB, $conf, $isLoggedIn);
510377d2
A
27
28 // Retrieve all update methods.
29 // For unit test, only retrieve final methods,
30 $class = new ReflectionClass($this);
31 $this->methods = $class->getMethods(ReflectionMethod::IS_FINAL);
32 }
33
34 /**
35 * Update method 1.
36 *
37 * @return bool true.
38 */
067c2dd8 39 final private function updateMethodDummy1()
510377d2
A
40 {
41 return true;
42 }
43
44 /**
45 * Update method 2.
46 *
47 * @return bool true.
48 */
067c2dd8 49 final private function updateMethodDummy2()
510377d2
A
50 {
51 return true;
52 }
53
54 /**
55 * Update method 3.
56 *
57 * @return bool true.
58 */
067c2dd8 59 final private function updateMethodDummy3()
510377d2
A
60 {
61 return true;
62 }
63
64 /**
65 * Update method 4, raise an exception.
66 *
67 * @throws Exception error.
68 */
067c2dd8 69 final private function updateMethodException()
510377d2
A
70 {
71 throw new Exception('whatever');
72 }
73}