1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Classmarkets\RavenBundle\Tests; |
4
|
|
|
|
5
|
|
|
use Classmarkets\RavenBundle\SentryEventRecorder; |
6
|
|
|
|
7
|
|
|
class SentryEventRecorderTest extends \PHPUnit\Framework\TestCase |
8
|
|
|
{ |
9
|
|
|
use \Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; |
10
|
|
|
|
11
|
|
View Code Duplication |
public function testStoreAndRetrieveEventId() |
12
|
|
|
{ |
13
|
|
|
$recorder = new SentryEventRecorder(); |
14
|
|
|
$exception = new \Exception(); |
15
|
|
|
$recorder->addExceptionEventId($exception, 'abc'); |
16
|
|
|
|
17
|
|
|
$this->assertEquals('abc', $recorder->getEventIdForException($exception)); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function testRetrieveAllIds() |
21
|
|
|
{ |
22
|
|
|
$recorder = new SentryEventRecorder(); |
23
|
|
|
|
24
|
|
|
$e = new \Exception(); |
25
|
|
|
$recorder->addExceptionEventId($e, 'abc'); |
26
|
|
|
$recorder->addExceptionEventId($e, 'abc'); // yes, twice. |
27
|
|
|
|
28
|
|
|
$e = new \Exception(); |
29
|
|
|
$recorder->addExceptionEventId($e, 'def'); |
30
|
|
|
|
31
|
|
|
$this->assertEquals(['abc', 'def'], $recorder->getAllEventIds()); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function testIgnoresNonObjects() |
35
|
|
|
{ |
36
|
|
|
$recorder = new SentryEventRecorder(); |
37
|
|
|
$nonObject = 'some string'; |
38
|
|
|
$recorder->addExceptionEventId($nonObject, 'abc'); |
|
|
|
|
39
|
|
|
|
40
|
|
|
$this->assertEquals(null, $recorder->getEventIdForException('some string')); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
View Code Duplication |
public function testIgnoresUnknownObjects() |
44
|
|
|
{ |
45
|
|
|
$recorder = new SentryEventRecorder(); |
46
|
|
|
$exception = new \Exception(); |
47
|
|
|
$otherException = new \Exception(); |
48
|
|
|
$recorder->addExceptionEventId($exception, 'abc'); |
49
|
|
|
|
50
|
|
|
$this->assertEquals(null, $recorder->getEventIdForException($otherException)); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
View Code Duplication |
public function testIgnoresEmptyIds() |
54
|
|
|
{ |
55
|
|
|
$recorder = new SentryEventRecorder(); |
56
|
|
|
$exception = new \Exception(); |
57
|
|
|
$recorder->addExceptionEventId($exception, ''); |
58
|
|
|
|
59
|
|
|
$this->assertEquals(null, $recorder->getEventIdForException($exception)); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: