aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Updater/DummyUpdater.php
blob: e9ef2aaa3092e0921af8e0fad37619ceb4f176fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php

require_once 'application/Updater.php';

/**
 * Class DummyUpdater.
 * Extends Updater to add update method designed for unit tests.
 */
class DummyUpdater extends Updater
{
    /**
     * Object constructor.
     *
     * @param array   $doneUpdates Updates which are already done.
     * @param array   $config      Shaarli's configuration array.
     * @param LinkDB  $linkDB      LinkDB instance.
     * @param boolean $isLoggedIn  True if the user is logged in.
     */
    public function __construct($doneUpdates, $config, $linkDB, $isLoggedIn)
    {
        parent::__construct($doneUpdates, $config, $linkDB, $isLoggedIn);

        // Retrieve all update methods.
        // For unit test, only retrieve final methods,
        $class = new ReflectionClass($this);
        $this->methods = $class->getMethods(ReflectionMethod::IS_FINAL);
    }

    /**
     * Update method 1.
     *
     * @return bool true.
     */
    private final function updateMethodDummy1()
    {
        return true;
    }

    /**
     * Update method 2.
     *
     * @return bool true.
     */
    private final function updateMethodDummy2()
    {
        return true;
    }

    /**
     * Update method 3.
     *
     * @return bool true.
     */
    private final function updateMethodDummy3()
    {
        return true;
    }

    /**
     * Update method 4, raise an exception.
     *
     * @throws Exception error.
     */
    private final function updateMethodException()
    {
        throw new Exception('whatever');
    }
}