1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Dasao\SentryLoggerTest; |
4
|
|
|
|
5
|
|
|
use Dasao\SentryLogger\Listener\SentryErrorListener; |
6
|
|
|
use Dasao\SentryLogger\Log\SentryLoggerInterface; |
7
|
|
|
use Exception; |
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
use PHPUnit_Framework_MockObject_MockObject; |
10
|
|
|
use Psr\Http\Message\ResponseInterface; |
11
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class SentryErrorListenerTest |
15
|
|
|
* |
16
|
|
|
* PHP Version 7 |
17
|
|
|
* |
18
|
|
|
* @category PHP |
19
|
|
|
* @package Dasao\SentryLoggerTest |
20
|
|
|
* @author Dasao <[email protected]> |
21
|
|
|
* @copyright 2014-2017 Dasao |
22
|
|
|
* @license Proprietary http://www.das-ao.com |
23
|
|
|
*/ |
24
|
|
|
class SentryErrorListenerTest extends TestCase |
25
|
|
|
{ |
26
|
|
|
/** @var SentryErrorListener */ |
27
|
|
|
protected $sentryErrorListener; |
28
|
|
|
|
29
|
|
|
/** @var SentryLoggerInterface|PHPUnit_Framework_MockObject_MockObject */ |
30
|
|
|
protected $sentryLogger; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @return void |
34
|
|
|
*/ |
35
|
|
|
public function setUp() |
36
|
|
|
{ |
37
|
|
|
$this->sentryLogger = $this->createMock(SentryLoggerInterface::class); |
38
|
|
|
|
39
|
|
|
$this->sentryErrorListener = new SentryErrorListener($this->sentryLogger); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return void |
44
|
|
|
*/ |
45
|
|
|
public function testInvoke() |
46
|
|
|
{ |
47
|
|
|
$sentryErrorListener = $this->sentryErrorListener; |
48
|
|
|
|
49
|
|
|
$this->sentryLogger->expects($this->once())->method('exception'); |
50
|
|
|
|
51
|
|
|
/** @var Exception $error */ |
52
|
|
|
$error = $this->createMock(Exception::class); |
53
|
|
|
/** @var ServerRequestInterface $request */ |
54
|
|
|
$request = $this->createMock(ServerRequestInterface::class); |
55
|
|
|
/** @var ResponseInterface $response */ |
56
|
|
|
$response = $this->createMock(ResponseInterface::class); |
57
|
|
|
|
58
|
|
|
$sentryErrorListener($error, $request, $response); |
59
|
|
|
} |
60
|
|
|
} |