Skip to content

Commit c190587

Browse files
authored
Merge pull request #81 from getsentry/improve-pr78
Add regression test and changelog entry about #78
2 parents 008479a + e538969 commit c190587

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1616
### Fixed
1717
- Remove usage of create_function to avoid deprecations (#71)
1818
- Fix a possible bug that could make Sentry crash if an error is triggered before loading a console command
19+
- Fix a fatal error when the user token is not authenticated (#78)
1920
### Removed
2021
- Drop deprecated fields from configuration; the same options can be used (since 0.8.3) under `sentry.options`
2122
- Dropped the third argument from the `SentrySymfonyClient` constructor; `error_types` are now fetched from the second argument, the options array

test/EventListener/ExceptionListenerTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,32 @@ public function test_that_username_is_set_from_user_interface_if_token_present_a
424424
$listener->onKernelRequest($mockEvent);
425425
}
426426

427+
public function test_regression_with_unauthenticated_user_token_PR_78()
428+
{
429+
$mockToken = $this->createMock(TokenInterface::class);
430+
$mockToken
431+
->method('isAuthenticated')
432+
->willReturn(false)
433+
;
434+
435+
$mockEvent = $this->createMock(GetResponseEvent::class);
436+
437+
$mockEvent
438+
->expects($this->once())
439+
->method('getRequestType')
440+
->willReturn(HttpKernelInterface::MASTER_REQUEST)
441+
;
442+
443+
$this->mockTokenStorage
444+
->method('getToken')
445+
->willReturn($mockToken)
446+
;
447+
448+
$this->containerBuilder->compile();
449+
$listener = $this->containerBuilder->get('sentry.exception_listener');
450+
$listener->onKernelRequest($mockEvent);
451+
}
452+
427453
public function test_that_it_does_not_report_http_exception_if_included_in_capture_skip()
428454
{
429455
$mockEvent = $this->createMock(GetResponseForExceptionEvent::class);

0 commit comments

Comments
 (0)