Skip to content

Fix failing unit tests after Symfony issue #38019 bugfix #461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
"jean85/pretty-package-versions": "^1.5 || ^2.0",
"php-http/discovery": "^1.11",
"sentry/sdk": "^3.1",
"symfony/config": "^3.4.44||^4.4.12||^5.0.11",
"symfony/console": "^3.4.44||^4.4.12||^5.0.11",
"symfony/dependency-injection": "^3.4.44||^4.4.12||^5.0.11",
"symfony/event-dispatcher": "^3.4.44||^4.4.12||^5.0.11",
"symfony/http-kernel": "^3.4.44||^4.4.12||^5.0.11",
"symfony/config": "^3.4.44||^4.4.20||^5.0.11",
"symfony/console": "^3.4.44||^4.4.20||^5.0.11",
"symfony/dependency-injection": "^3.4.44||^4.4.20||^5.0.11",
"symfony/event-dispatcher": "^3.4.44||^4.4.20||^5.0.11",
"symfony/http-kernel": "^3.4.44||^4.4.20||^5.0.11",
"symfony/polyfill-php80": "^1.22",
"symfony/psr-http-message-bridge": "^2.0",
"symfony/security-core": "^3.4.44||^4.4.12||^5.0.11"
"symfony/security-core": "^3.4.44||^4.4.20||^5.0.11"
},
"require-dev": {
"doctrine/dbal": "^2.10||^3.0",
Expand All @@ -44,14 +44,14 @@
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpunit/phpunit": "^8.5||^9.0",
"symfony/browser-kit": "^3.4.44||^4.4.12||^5.0.11",
"symfony/dom-crawler": "^3.4.44||^4.4.12||^5.0.11",
"symfony/framework-bundle": "^3.4.44||^4.4.12||^5.0.11",
"symfony/messenger": "^4.4.12||^5.0.11",
"symfony/browser-kit": "^3.4.44||^4.4.20||^5.0.11",
"symfony/dom-crawler": "^3.4.44||^4.4.20||^5.0.11",
"symfony/framework-bundle": "^3.4.44||^4.4.20||^5.0.11",
"symfony/messenger": "^4.4.20||^5.0.11",
"symfony/monolog-bundle": "^3.4",
"symfony/phpunit-bridge": "^5.0",
"symfony/twig-bundle": "^3.4.44||^4.4.12||^5.0.11",
"symfony/yaml": "^3.4.44||^4.4.12||^5.0.11",
"symfony/phpunit-bridge": "^5.2.6",
"symfony/twig-bundle": "^3.4.44||^4.4.20||^5.0.11",
"symfony/yaml": "^3.4.44||^4.4.20||^5.0.11",
"vimeo/psalm": "^4.3"
},
"suggest": {
Expand Down
78 changes: 36 additions & 42 deletions tests/EventListener/TracingRequestListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,18 @@ public function handleKernelRequestEventDataProvider(): \Generator
'net.host.name' => 'www.example.com',
]);

yield 'request.server.sentry-trace EXISTS' => [
new Options(['send_default_pii' => false]),
yield 'request.headers.sentry-trace EXISTS' => [
new Options(),
Request::create(
'http://www.example.com',
'GET',
[],
[],
[],
['HTTP_sentry-trace' => '566e3688a61d4bc888951642d6f14a19-566e3688a61d4bc8-1']
[
'REQUEST_TIME_FLOAT' => 1613493597.010275,
'HTTP_sentry-trace' => '566e3688a61d4bc888951642d6f14a19-566e3688a61d4bc8-1',
]
),
$transactionContext,
];
Expand All @@ -126,58 +129,43 @@ public function handleKernelRequestEventDataProvider(): \Generator
'net.host.name' => 'www.example.com',
]);

$request = Request::create('http://www.example.com');
$request->server->remove('REQUEST_TIME_FLOAT');

yield 'request.server.REQUEST_TIME_FLOAT NOT EXISTS' => [
new Options(['send_default_pii' => false]),
Request::create('http://www.example.com'),
new Options(),
$request,
$transactionContext,
];

$transactionContext = new TransactionContext();
$transactionContext->setName('GET http://www.example.com/');
$transactionContext->setName('GET http://127.0.0.1/');
$transactionContext->setOp('http.server');
$transactionContext->setStartTimestamp(1613493597.010819);
$transactionContext->setStartTimestamp(1613493597.010275);
$transactionContext->setTags([
'net.host.port' => '80',
'http.method' => 'GET',
'http.url' => 'http://www.example.com/',
'http.url' => 'http://127.0.0.1/',
'http.flavor' => '1.1',
'route' => '<unknown>',
'net.host.name' => 'www.example.com',
'net.host.ip' => '127.0.0.1',
]);

yield 'request.server.REQUEST_TIME_FLOAT EXISTS' => [
new Options(['send_default_pii' => false]),
yield 'request.server.HOST IS IPV4' => [
new Options(),
Request::create(
'http://www.example.com',
'http://127.0.0.1',
'GET',
[],
[],
[],
['REQUEST_TIME_FLOAT' => 1613493597.010819]
['REQUEST_TIME_FLOAT' => 1613493597.010275]
),
$transactionContext,
];

$transactionContext = new TransactionContext();
$transactionContext->setName('GET http://127.0.0.1/');
$transactionContext->setOp('http.server');
$transactionContext->setStartTimestamp(1613493597.010275);
$transactionContext->setTags([
'net.host.port' => '80',
'http.method' => 'GET',
'http.url' => 'http://127.0.0.1/',
'http.flavor' => '1.1',
'route' => '<unknown>',
'net.host.ip' => '127.0.0.1',
]);

yield 'request.server.HOST IS IPV4' => [
new Options(['send_default_pii' => false]),
Request::create('http://127.0.0.1'),
$transactionContext,
];

$request = Request::create('http://www.example.com/path');
$request->server->set('REQUEST_TIME_FLOAT', 1613493597.010275);
$request->attributes->set('_route', 'app_homepage');

$transactionContext = new TransactionContext();
Expand All @@ -194,12 +182,13 @@ public function handleKernelRequestEventDataProvider(): \Generator
]);

yield 'request.attributes.route IS STRING' => [
new Options(['send_default_pii' => false]),
new Options(),
$request,
$transactionContext,
];

$request = Request::create('http://www.example.com/path');
$request->server->set('REQUEST_TIME_FLOAT', 1613493597.010275);
$request->attributes->set('_route', new Route('/path'));

$transactionContext = new TransactionContext();
Expand All @@ -216,12 +205,13 @@ public function handleKernelRequestEventDataProvider(): \Generator
]);

yield 'request.attributes.route IS INSTANCEOF Symfony\Component\Routing\Route' => [
new Options(['send_default_pii' => false]),
new Options(),
$request,
$transactionContext,
];

$request = Request::create('http://www.example.com/');
$request->server->set('REQUEST_TIME_FLOAT', 1613493597.010275);
$request->attributes->set('_controller', 'App\\Controller::indexAction');

$transactionContext = new TransactionContext();
Expand All @@ -237,13 +227,14 @@ public function handleKernelRequestEventDataProvider(): \Generator
'net.host.name' => 'www.example.com',
]);

yield 'request.attributes.controller IS STRING' => [
new Options(['send_default_pii' => false]),
yield 'request.attributes._controller IS STRING' => [
new Options(),
$request,
$transactionContext,
];

$request = Request::create('http://www.example.com/');
$request->server->set('REQUEST_TIME_FLOAT', 1613493597.010275);
$request->attributes->set('_controller', ['App\\Controller', 'indexAction']);

$transactionContext = new TransactionContext();
Expand All @@ -259,13 +250,14 @@ public function handleKernelRequestEventDataProvider(): \Generator
'net.host.name' => 'www.example.com',
]);

yield 'request.attributes.controller IS CALLABLE (1)' => [
new Options(['send_default_pii' => false]),
yield 'request.attributes._controller IS CALLABLE (1)' => [
new Options(),
$request,
$transactionContext,
];

$request = Request::create('http://www.example.com/');
$request->server->set('REQUEST_TIME_FLOAT', 1613493597.010275);
$request->attributes->set('_controller', [new class() {}, 'indexAction']);

$transactionContext = new TransactionContext();
Expand All @@ -281,13 +273,14 @@ public function handleKernelRequestEventDataProvider(): \Generator
'net.host.name' => 'www.example.com',
]);

yield 'request.attributes.controller IS CALLABLE (2)' => [
new Options(['send_default_pii' => false]),
yield 'request.attributes._controller IS CALLABLE (2)' => [
new Options(),
$request,
$transactionContext,
];

$request = Request::create('http://www.example.com/');
$request->server->set('REQUEST_TIME_FLOAT', 1613493597.010275);
$request->attributes->set('_controller', [10]);

$transactionContext = new TransactionContext();
Expand All @@ -303,13 +296,14 @@ public function handleKernelRequestEventDataProvider(): \Generator
'net.host.name' => 'www.example.com',
]);

yield 'request.attributes.controller IS ARRAY and NOT VALID CALLABLE' => [
new Options(['send_default_pii' => false]),
yield 'request.attributes._controller IS ARRAY and NOT VALID CALLABLE' => [
new Options(),
$request,
$transactionContext,
];

$request = Request::create('http://www.example.com/');
$request->server->set('REQUEST_TIME_FLOAT', 1613493597.010275);
$request->attributes->set('_controller', [10]);

$transactionContext = new TransactionContext();
Expand Down