|
11 | 11 | use Sentry\Integration\ModulesIntegration; |
12 | 12 | use Sentry\SentrySdk; |
13 | 13 | use Sentry\State\Scope; |
| 14 | +use Sentry\ClientBuilder; |
| 15 | +use Sentry\Transport\Result; |
| 16 | +use Sentry\Transport\ResultStatus; |
| 17 | +use Sentry\Transport\TransportInterface; |
14 | 18 |
|
15 | 19 | use function Sentry\withScope; |
16 | 20 |
|
@@ -57,4 +61,33 @@ public static function invokeDataProvider(): \Generator |
57 | 61 | false, |
58 | 62 | ]; |
59 | 63 | } |
| 64 | + |
| 65 | + public function testModuleIntegration(): void |
| 66 | + { |
| 67 | + /** @var TransportInterface&MockObject $transport */ |
| 68 | + $transport = $this->createMock(TransportInterface::class); |
| 69 | + $transport->expects($this->once()) |
| 70 | + ->method('send') |
| 71 | + ->with($this->callback(function (Event $event): bool { |
| 72 | + $modules = $event->getModules(); |
| 73 | + |
| 74 | + $this->assertIsArray($modules); |
| 75 | + $this->assertNotEmpty($modules); |
| 76 | + $this->assertArrayHasKey('psr/log', $modules); |
| 77 | + $this->assertMatchesRegularExpression("/^\d+\.\d+\.\d+$/", $modules['psr/log']); |
| 78 | + |
| 79 | + return true; |
| 80 | + })) |
| 81 | + ->willReturnCallback(static function (Event $event): Result { |
| 82 | + return new Result(ResultStatus::success(), $event); |
| 83 | + }); |
| 84 | + |
| 85 | + $client = ClientBuilder::create() |
| 86 | + ->setTransport($transport) |
| 87 | + ->getClient(); |
| 88 | + |
| 89 | + SentrySdk::getCurrentHub()->bindClient($client); |
| 90 | + |
| 91 | + $client->captureEvent(Event::createEvent(), null, new Scope()); |
| 92 | + } |
60 | 93 | } |
0 commit comments