| 1 | <?php |
||
| 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 |