Skip to content

Commit 41190dd

Browse files
committed
Try to fix tests under prefer-lowest
1 parent b90e69c commit 41190dd

File tree

5 files changed

+51
-53
lines changed

5 files changed

+51
-53
lines changed

src/EventListener/ConsoleListener.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Sentry\SentryBundle\EventListener;
44

55
use Sentry\SentryBundle\SentryBundle;
6-
use Sentry\State\Hub;
76
use Sentry\State\HubInterface;
87
use Sentry\State\Scope;
98
use Symfony\Component\Console\Event\ConsoleCommandEvent;

src/EventListener/RequestListener.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Sentry\SentryBundle\EventListener;
44

55
use Sentry\SentryBundle\SentryBundle;
6-
use Sentry\State\Hub;
76
use Sentry\State\HubInterface;
87
use Sentry\State\Scope;
98
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;

test/BaseTestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
abstract class BaseTestCase extends TestCase
1010
{
11+
public const SUPPORTED_SENTRY_OPTIONS_COUNT = 23;
12+
1113
protected function classSerializersAreSupported(): bool
1214
{
1315
try {

test/DependencyInjection/ConfigurationTest.php

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
class ConfigurationTest extends BaseTestCase
1414
{
15-
public const SUPPORTED_SENTRY_OPTIONS_COUNT = 23;
16-
1715
public function testDataProviderIsMappingTheRightNumberOfOptions(): void
1816
{
1917
$providerData = $this->optionValuesProvider();
@@ -150,52 +148,52 @@ public function testInvalidValues(string $option, $value): void
150148
$this->processConfiguration($input);
151149
}
152150

153-
public function invalidValuesProvider(): array
151+
public function invalidValuesProvider(): \Generator
154152
{
155-
return [
156-
['attach_stacktrace', 'string'],
157-
['before_breadcrumb', 'this is not a callable'],
158-
['before_breadcrumb', [$this, 'is not a callable']],
159-
['before_breadcrumb', false],
160-
['before_breadcrumb', -1],
161-
['before_send', 'this is not a callable'],
162-
['before_send', [$this, 'is not a callable']],
163-
['before_send', false],
164-
['before_send', -1],
165-
['class_serializers', 'this is not a callable'],
166-
['class_serializers', [$this, 'is not a callable']],
167-
['class_serializers', false],
168-
['class_serializers', -1],
169-
['context_lines', -1],
170-
['context_lines', 99999],
171-
['context_lines', 'string'],
172-
['default_integrations', 'true'],
173-
['default_integrations', 1],
174-
['enable_compression', 'string'],
175-
['environment', ''],
176-
['error_types', []],
177-
['excluded_exceptions', 'some-string'],
178-
['http_proxy', []],
179-
['in_app_exclude', 'some/single/path'],
180-
['integrations', [1]],
181-
['integrations', 'a string'],
182-
['logger', []],
183-
['max_breadcrumbs', -1],
184-
['max_breadcrumbs', 'string'],
185-
['max_value_length', -1],
186-
['max_value_length', []],
187-
['prefixes', 'string'],
188-
['project_root', []],
189-
['release', []],
190-
['sample_rate', 1.1],
191-
['sample_rate', -1],
192-
['send_attempts', 1.5],
193-
['send_attempts', 0],
194-
['send_attempts', -1],
195-
['send_default_pii', 'false'],
196-
['server_name', []],
197-
['tags', 'invalid-unmapped-tag'],
198-
];
153+
yield ['attach_stacktrace', 'string'];
154+
yield ['before_breadcrumb', 'this is not a callable'];
155+
yield ['before_breadcrumb', [$this, 'is not a callable']];
156+
yield ['before_breadcrumb', false];
157+
yield ['before_breadcrumb', -1];
158+
yield ['before_send', 'this is not a callable'];
159+
yield ['before_send', [$this, 'is not a callable']];
160+
yield ['before_send', false];
161+
yield ['before_send', -1];
162+
if ($this->classSerializersAreSupported()) {
163+
yield ['class_serializers', 'this is not a callable'];
164+
yield ['class_serializers', [$this, 'is not a callable']];
165+
yield ['class_serializers', false];
166+
yield ['class_serializers', -1];
167+
}
168+
yield ['context_lines', -1];
169+
yield ['context_lines', 99999];
170+
yield ['context_lines', 'string'];
171+
yield ['default_integrations', 'true'];
172+
yield ['default_integrations', 1];
173+
yield ['enable_compression', 'string'];
174+
yield ['environment', ''];
175+
yield ['error_types', []];
176+
yield ['excluded_exceptions', 'some-string'];
177+
yield ['http_proxy', []];
178+
yield ['in_app_exclude', 'some/single/path'];
179+
yield ['integrations', [1]];
180+
yield ['integrations', 'a string'];
181+
yield ['logger', []];
182+
yield ['max_breadcrumbs', -1];
183+
yield ['max_breadcrumbs', 'string'];
184+
yield ['max_value_length', -1];
185+
yield ['max_value_length', []];
186+
yield ['prefixes', 'string'];
187+
yield ['project_root', []];
188+
yield ['release', []];
189+
yield ['sample_rate', 1.1];
190+
yield ['sample_rate', -1];
191+
yield ['send_attempts', 1.5];
192+
yield ['send_attempts', 0];
193+
yield ['send_attempts', -1];
194+
yield ['send_default_pii', 'false'];
195+
yield ['server_name', []];
196+
yield ['tags', 'invalid-unmapped-tag'];
199197
}
200198

201199
private function processConfiguration(array $values): array

test/DependencyInjection/SentryExtensionTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ public function testDataProviderIsMappingTheRightNumberOfOptions(): void
2727
$supportedOptions = \array_unique(\array_column($providerData, 0));
2828

2929
// subtracted one is `integration`, which cannot be tested with the provider
30-
$expectedCount = ConfigurationTest::SUPPORTED_SENTRY_OPTIONS_COUNT - 1;
30+
$expectedCount = $this->getSupportedOptionsCount();
3131

32-
if (PrettyVersions::getVersion('sentry/sentry')->getPrettyVersion() !== '2.0.0') {
33-
++$expectedCount;
32+
if (PrettyVersions::getVersion('sentry/sentry')->getPrettyVersion() === '2.0.0') {
33+
--$expectedCount;
3434
}
3535

3636
$this->assertCount(
37-
$this->getSupportedOptionsCount(),
37+
$expectedCount,
3838
$supportedOptions,
3939
'Provider for configuration options mismatch: ' . PHP_EOL . print_r($supportedOptions, true)
4040
);

0 commit comments

Comments
 (0)