Skip to content

Commit 146af27

Browse files
committed
Add a test for 500
1 parent 42b9d5f commit 146af27

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Sentry\SentryBundle\Test\End2End\App\Controller;
4+
5+
use Symfony\Component\HttpFoundation\Response;
6+
7+
class MainController
8+
{
9+
public function exception(): Response
10+
{
11+
throw new \Exception('This is an intentional error');
12+
}
13+
}

test/End2End/App/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
framework:
2+
router: { resource: "./routing.yml" }
23
secret: secret
34
test: ~
45

test/End2End/App/routing.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
exception:
2+
path: /exception
3+
defaults: { _controller: '\Sentry\SentryBundle\Test\End2End\App\Controller\MainController::exception' }

test/End2End/End2EndTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,22 @@ public function testGet404(): void
4040
$this->assertInstanceOf(HubInterface::class, $hub);
4141
$this->assertNotNull($hub->getLastEventId(), 'Last error not captured');
4242
}
43+
44+
public function testGet500(): void
45+
{
46+
$client = static::createClient();
47+
48+
$client->request('GET', '/exception');
49+
50+
$response = $client->getResponse();
51+
52+
$this->assertInstanceOf(Response::class, $response);
53+
$this->assertSame(500, $response->getStatusCode(), $response->getContent());
54+
$this->assertContains('intentional error', $response->getContent());
55+
56+
$hub = $client->getContainer()->get('test.hub');
57+
58+
$this->assertInstanceOf(HubInterface::class, $hub);
59+
$this->assertNotNull($hub->getLastEventId(), 'Last error not captured');
60+
}
4361
}

0 commit comments

Comments
 (0)