Completed
Push — master ( d05a4b...d896c9 )
by Jonathan
01:23
created

TestPlugin::verify()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Vectorface\Tests\Auth\Helpers;
4
5
use Exception;
6
use Vectorface\Auth\Auth;
7
use Vectorface\Auth\AuthException;
8
use Vectorface\Auth\Plugin\BaseAuthPlugin;
9
use Vectorface\Auth\Plugin\SharedLoggerTrait;
10
use Psr\Log\LoggerAwareTrait;
11
12
/**
13
 * An auth plugin for testing.
14
 */
15
class TestPlugin extends BaseAuthPlugin
16
{
17
    use LoggerAwareTrait;
18
    use SharedLoggerTrait;
19
20
    protected $result = Auth::RESULT_NOOP;
21
22
    private function action()
23
    {
24
        if ($this->result instanceof Exception) {
25
            throw $this->result;
26
        }
27
        return $this->result;
28
    }
29
30
    /**
31
     * Pass through the auth object for unit test.
32
     *
33
     * @return Auth
34
     */
35
    public function getAuthObject()
36
    {
37
        return $this->getAuth();
38
    }
39
40
    public function setResult($result)
41
    {
42
        $this->result = $result;
43
    }
44
    public function login($username, $password)
45
    {
46
        return $this->action();
47
    }
48
    public function verify()
49
    {
50
        return $this->action();
51
    }
52
    public function logout()
53
    {
54
        return $this->action();
55
    }
56
57
    public function returnTrue()
58
    {
59
        return true;
60
    }
61
    public function throwException()
62
    {
63
        throw new Exception("Exception thrown on purpose in test case.");
64
    }
65
    public function throwAuthException()
66
    {
67
        throw new AuthException("AuthException thrown on purpose in test case.");
68
    }
69
    public function testWarning($message)
70
    {
71
        $this->warning($message);
72
    }
73
}
74