Skip to content

Commit a726b6c

Browse files
authored
Clean up impossible test conditions and fix broken CI (#787)
1 parent 2ab21d9 commit a726b6c

File tree

5 files changed

+29
-25
lines changed

5 files changed

+29
-25
lines changed

phpstan-baseline.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ parameters:
9696
path: src/DependencyInjection/SentryExtension.php
9797

9898
-
99-
message: "#^Parameter \\#2 \\$callback of function array_filter expects callable\\(mixed\\)\\: mixed, Closure\\(string\\)\\: bool given\\.$#"
99+
message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(string\\)\\: bool given\\.$#"
100100
count: 1
101101
path: src/DependencyInjection/SentryExtension.php
102102

tests/End2End/App/Kernel.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
4848
$loader->load(__DIR__ . '/deprecations_for_6.yml');
4949
}
5050

51+
if (self::VERSION_ID >= 60400) {
52+
$loader->load(__DIR__ . '/deprecations_for_64.yml');
53+
}
54+
5155
if (interface_exists(MessageBusInterface::class) && self::VERSION_ID >= 40300) {
5256
$loader->load(__DIR__ . '/messenger.yml');
5357
}

tests/End2End/App/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ framework:
1313
router: { resource: "%routing_config_dir%/routing.yml" }
1414
secret: secret
1515
test: ~
16+
annotations: false
17+
php_errors:
18+
log: true
1619

1720
services:
1821
test.hub:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
framework:
2+
handle_all_throwables: true

tests/Integration/RequestFetcherTest.php

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
declare(strict_types=1);
44

5-
namespace Sentry\SentryBundle\Test\Integration;
5+
namespace Sentry\SentryBundle\Tests\Integration;
66

7-
use GuzzleHttp\Psr7\ServerRequest;
87
use PHPUnit\Framework\MockObject\MockObject;
98
use PHPUnit\Framework\TestCase;
109
use Psr\Http\Message\ServerRequestInterface;
@@ -37,24 +36,36 @@ protected function setUp(): void
3736
$this->requestFetcher = new RequestFetcher($this->requestStack, $this->httpMessageFactory);
3837
}
3938

40-
/**
41-
* @dataProvider fetchRequestDataProvider
42-
*/
43-
public function testFetchRequest(?Request $request, ?ServerRequestInterface $expectedRequest): void
39+
public function testFetchRequest(): void
4440
{
41+
$request = Request::create('https://www.example.com');
42+
$expectedRequest = $this->createMock(ServerRequestInterface::class);
43+
4544
$this->requestStack->expects($this->once())
4645
->method('getCurrentRequest')
4746
->willReturn($request);
4847

49-
$this->httpMessageFactory->expects(null !== $expectedRequest ? $this->once() : $this->never())
48+
$this->httpMessageFactory->expects($this->once())
5049
->method('createRequest')
5150
->with($request)
5251
->willReturn($expectedRequest);
5352

5453
$this->assertSame($expectedRequest, $this->requestFetcher->fetchRequest());
5554
}
5655

57-
public function testFetchRequestFailsSilently(): void
56+
public function testFetchRequestReturnsNullIfTheRequestStackIsEmpty(): void
57+
{
58+
$this->requestStack->expects($this->once())
59+
->method('getCurrentRequest')
60+
->willReturn(null);
61+
62+
$this->httpMessageFactory->expects($this->never())
63+
->method('createRequest');
64+
65+
$this->assertNull($this->requestFetcher->fetchRequest());
66+
}
67+
68+
public function testFetchRequestReturnsNullIfTheRequestFactoryThrowsAnException(): void
5869
{
5970
$this->requestStack->expects($this->once())
6071
->method('getCurrentRequest')
@@ -66,20 +77,4 @@ public function testFetchRequestFailsSilently(): void
6677

6778
$this->assertNull($this->requestFetcher->fetchRequest());
6879
}
69-
70-
/**
71-
* @return \Generator<array{Request|null,ServerRequest|null}>
72-
*/
73-
public function fetchRequestDataProvider(): \Generator
74-
{
75-
yield [
76-
null,
77-
null,
78-
];
79-
80-
yield [
81-
Request::create('http://www.example.com'),
82-
new ServerRequest('GET', 'http://www.example.com'),
83-
];
84-
}
8580
}

0 commit comments

Comments
 (0)