Skip to content

Commit 8e950d1

Browse files
committed
Fix PHPStan errors
1 parent e83a9a4 commit 8e950d1

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ parameters:
1111
- '/Parameter \$.+ of method Sentry\\SentryBundle\\EventListener\\ErrorListener::onConsoleException\(\) has invalid typehint type Symfony\\Component\\Console\\Event\\ConsoleExceptionEvent./'
1212
- '/Call to method getException\(\) on an unknown class Symfony\\Component\\Console\\Event\\ConsoleExceptionEvent./'
1313
- '/Access to undefined constant Symfony\\Component\\Console\\ConsoleEvents::EXCEPTION./'
14+
- '/Class PHPUnit_Framework_TestCase not found/'
1415

1516
includes:
1617
- vendor/jangregor/phpstan-prophecy/src/extension.neon

test/End2End/End2EndTest.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PHPUnit\Framework\TestCase;
66
use Sentry\SentryBundle\Test\End2End\App\Kernel;
77
use Sentry\State\HubInterface;
8+
use Symfony\Bundle\FrameworkBundle\Client;
89
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
910
use Symfony\Component\HttpFoundation\Response;
1011
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -35,7 +36,7 @@ public function testGet404(): void
3536
$response = $client->getResponse();
3637

3738
$this->assertInstanceOf(Response::class, $response);
38-
$this->assertSame(404, $response->getStatusCode(), $response->getContent());
39+
$this->assertSame(404, $response->getStatusCode());
3940
} catch (\Throwable $exception) {
4041
if (! $exception instanceof NotFoundHttpException) {
4142
throw $exception;
@@ -44,10 +45,7 @@ public function testGet404(): void
4445
$this->assertSame('No route found for "GET /missing-page"', $exception->getMessage());
4546
}
4647

47-
$hub = $client->getContainer()->get('test.hub');
48-
49-
$this->assertInstanceOf(HubInterface::class, $hub);
50-
$this->assertNotNull($hub->getLastEventId(), 'Last error not captured');
48+
$this->assertLastEventIdIsNotNull($client);
5149
}
5250

5351
public function testGet500(): void
@@ -60,7 +58,7 @@ public function testGet500(): void
6058
$response = $client->getResponse();
6159

6260
$this->assertInstanceOf(Response::class, $response);
63-
$this->assertSame(500, $response->getStatusCode(), $response->getContent());
61+
$this->assertSame(500, $response->getStatusCode());
6462
$this->assertContains('intentional error', $response->getContent());
6563
} catch (\Throwable $exception) {
6664
if (! $exception instanceof \RuntimeException) {
@@ -70,9 +68,17 @@ public function testGet500(): void
7068
$this->assertSame('This is an intentional error', $exception->getMessage());
7169
}
7270

73-
$hub = $client->getContainer()->get('test.hub');
71+
$this->assertLastEventIdIsNotNull($client);
72+
}
7473

74+
private function assertLastEventIdIsNotNull(Client $client): void
75+
{
76+
$container = $client->getContainer();
77+
$this->assertNotNull($container);
78+
79+
$hub = $container->get('test.hub');
7580
$this->assertInstanceOf(HubInterface::class, $hub);
81+
7682
$this->assertNotNull($hub->getLastEventId(), 'Last error not captured');
7783
}
7884
}

0 commit comments

Comments
 (0)