|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Classmarkets\RavenBundle\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use Classmarkets\RavenBundle\RecordingRavenClient; |
|
6
|
|
|
|
|
7
|
|
|
class RecordingRavenClientTest extends \PHPUnit\Framework\TestCase |
|
8
|
|
|
{ |
|
9
|
|
|
use \Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; |
|
10
|
|
|
|
|
11
|
|
|
public function testNotifiesRecorderViaCaptureException() |
|
12
|
|
|
{ |
|
13
|
|
|
$exception = new \Exception(); |
|
14
|
|
|
|
|
15
|
|
|
$realRavenClient = \Mockery::mock('Raven_Client'); |
|
16
|
|
|
$realRavenClient |
|
17
|
|
|
->shouldReceive('captureException') |
|
18
|
|
|
->with($exception, [], null, []) |
|
19
|
|
|
->andReturn('123'); |
|
20
|
|
|
$realRavenClient->shouldReceive('getIdent')->with('123')->andReturn('456'); |
|
21
|
|
|
|
|
22
|
|
|
$recorder = \Mockery::mock('Classmarkets\RavenBundle\SentryEventRecorder'); |
|
23
|
|
|
$recorder->shouldReceive('addExceptionEventId')->with($exception, '456'); |
|
24
|
|
|
|
|
25
|
|
|
$ourRavenClient = new RecordingRavenClient($realRavenClient, $recorder); |
|
26
|
|
|
|
|
27
|
|
|
$eventId = $ourRavenClient->captureException($exception); |
|
28
|
|
|
$this->assertEquals('123', $eventId); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function testDelegatesMethods() |
|
32
|
|
|
{ |
|
33
|
|
|
$realRavenClient = \Mockery::mock('Raven_Client'); |
|
34
|
|
|
$realRavenClient->shouldReceive('captureMessage')->once()->with('foobar'); |
|
35
|
|
|
|
|
36
|
|
|
$recorder = \Mockery::mock('Classmarkets\RavenBundle\SentryEventRecorder'); |
|
37
|
|
|
|
|
38
|
|
|
$ourRavenClient = new RecordingRavenClient($realRavenClient, $recorder); |
|
39
|
|
|
$ourRavenClient->captureMessage('foobar'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function testInstanceOfOriginClient() |
|
43
|
|
|
{ |
|
44
|
|
|
$realRavenClient = \Mockery::mock('Raven_Client'); |
|
45
|
|
|
$recorder = \Mockery::mock('Classmarkets\RavenBundle\SentryEventRecorder'); |
|
46
|
|
|
|
|
47
|
|
|
$ourRavenClient = new RecordingRavenClient($realRavenClient, $recorder); |
|
48
|
|
|
|
|
49
|
|
|
$this->assertInstanceOf('Raven_Client', $ourRavenClient); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|