Skip to content

Commit

Permalink
Try to fix tests under prefer-lowest
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean85 committed Sep 22, 2019
1 parent b90e69c commit 41190dd
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 53 deletions.
1 change: 0 additions & 1 deletion src/EventListener/ConsoleListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Sentry\SentryBundle\EventListener;

use Sentry\SentryBundle\SentryBundle;
use Sentry\State\Hub;
use Sentry\State\HubInterface;
use Sentry\State\Scope;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
Expand Down
1 change: 0 additions & 1 deletion src/EventListener/RequestListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Sentry\SentryBundle\EventListener;

use Sentry\SentryBundle\SentryBundle;
use Sentry\State\Hub;
use Sentry\State\HubInterface;
use Sentry\State\Scope;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
Expand Down
2 changes: 2 additions & 0 deletions test/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

abstract class BaseTestCase extends TestCase
{
public const SUPPORTED_SENTRY_OPTIONS_COUNT = 23;

protected function classSerializersAreSupported(): bool
{
try {
Expand Down
92 changes: 45 additions & 47 deletions test/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

class ConfigurationTest extends BaseTestCase
{
public const SUPPORTED_SENTRY_OPTIONS_COUNT = 23;

public function testDataProviderIsMappingTheRightNumberOfOptions(): void
{
$providerData = $this->optionValuesProvider();
Expand Down Expand Up @@ -150,52 +148,52 @@ public function testInvalidValues(string $option, $value): void
$this->processConfiguration($input);
}

public function invalidValuesProvider(): array
public function invalidValuesProvider(): \Generator
{
return [
['attach_stacktrace', 'string'],
['before_breadcrumb', 'this is not a callable'],
['before_breadcrumb', [$this, 'is not a callable']],
['before_breadcrumb', false],
['before_breadcrumb', -1],
['before_send', 'this is not a callable'],
['before_send', [$this, 'is not a callable']],
['before_send', false],
['before_send', -1],
['class_serializers', 'this is not a callable'],
['class_serializers', [$this, 'is not a callable']],
['class_serializers', false],
['class_serializers', -1],
['context_lines', -1],
['context_lines', 99999],
['context_lines', 'string'],
['default_integrations', 'true'],
['default_integrations', 1],
['enable_compression', 'string'],
['environment', ''],
['error_types', []],
['excluded_exceptions', 'some-string'],
['http_proxy', []],
['in_app_exclude', 'some/single/path'],
['integrations', [1]],
['integrations', 'a string'],
['logger', []],
['max_breadcrumbs', -1],
['max_breadcrumbs', 'string'],
['max_value_length', -1],
['max_value_length', []],
['prefixes', 'string'],
['project_root', []],
['release', []],
['sample_rate', 1.1],
['sample_rate', -1],
['send_attempts', 1.5],
['send_attempts', 0],
['send_attempts', -1],
['send_default_pii', 'false'],
['server_name', []],
['tags', 'invalid-unmapped-tag'],
];
yield ['attach_stacktrace', 'string'];
yield ['before_breadcrumb', 'this is not a callable'];
yield ['before_breadcrumb', [$this, 'is not a callable']];
yield ['before_breadcrumb', false];
yield ['before_breadcrumb', -1];
yield ['before_send', 'this is not a callable'];
yield ['before_send', [$this, 'is not a callable']];
yield ['before_send', false];
yield ['before_send', -1];
if ($this->classSerializersAreSupported()) {
yield ['class_serializers', 'this is not a callable'];
yield ['class_serializers', [$this, 'is not a callable']];
yield ['class_serializers', false];
yield ['class_serializers', -1];
}
yield ['context_lines', -1];
yield ['context_lines', 99999];
yield ['context_lines', 'string'];
yield ['default_integrations', 'true'];
yield ['default_integrations', 1];
yield ['enable_compression', 'string'];
yield ['environment', ''];
yield ['error_types', []];
yield ['excluded_exceptions', 'some-string'];
yield ['http_proxy', []];
yield ['in_app_exclude', 'some/single/path'];
yield ['integrations', [1]];
yield ['integrations', 'a string'];
yield ['logger', []];
yield ['max_breadcrumbs', -1];
yield ['max_breadcrumbs', 'string'];
yield ['max_value_length', -1];
yield ['max_value_length', []];
yield ['prefixes', 'string'];
yield ['project_root', []];
yield ['release', []];
yield ['sample_rate', 1.1];
yield ['sample_rate', -1];
yield ['send_attempts', 1.5];
yield ['send_attempts', 0];
yield ['send_attempts', -1];
yield ['send_default_pii', 'false'];
yield ['server_name', []];
yield ['tags', 'invalid-unmapped-tag'];
}

private function processConfiguration(array $values): array
Expand Down
8 changes: 4 additions & 4 deletions test/DependencyInjection/SentryExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public function testDataProviderIsMappingTheRightNumberOfOptions(): void
$supportedOptions = \array_unique(\array_column($providerData, 0));

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

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

$this->assertCount(
$this->getSupportedOptionsCount(),
$expectedCount,
$supportedOptions,
'Provider for configuration options mismatch: ' . PHP_EOL . print_r($supportedOptions, true)
);
Expand Down

0 comments on commit 41190dd

Please sign in to comment.