-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from netlogix/feature/rendering-group-by-code
FEATURE: Allow mapping of renderingGroup by Exception Code
- Loading branch information
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
Tests/Unit/ExceptionHandler/ExceptionRenderingOptionsResolverTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Netlogix\Sentry\Tests\Unit\ExceptionHandler; | ||
|
||
use Neos\Flow\Tests\UnitTestCase; | ||
use Netlogix\Sentry\ExceptionHandler\ExceptionRenderingOptionsResolver; | ||
|
||
class ExceptionRenderingOptionsResolverTest extends UnitTestCase | ||
{ | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function If_no_renderingGroups_have_been_defined_an_empty_array_is_returned(): void | ||
{ | ||
$resolver = new ExceptionRenderingOptionsResolver(); | ||
|
||
$result = $resolver->resolveRenderingOptionsForThrowable(self::createThrowable()); | ||
|
||
self::assertEmpty($result); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function Exception_Code_is_used_to_match_rendering_Groups(): void | ||
{ | ||
$resolver = new ExceptionRenderingOptionsResolver(); | ||
|
||
$resolver->setOptions([ | ||
'renderingGroups' => [ | ||
'someGroup' => [ | ||
'matchingExceptionCodes' => [self::code()], | ||
'options' => [ | ||
'foo' => 'bar' | ||
] | ||
] | ||
] | ||
]); | ||
|
||
$result = $resolver->resolveRenderingOptionsForThrowable(self::createThrowable()); | ||
|
||
self::assertArrayHasKey('renderingGroup', $result); | ||
self::assertEquals('someGroup', $result['renderingGroup']); | ||
|
||
self::assertArrayHasKey('foo', $result); | ||
self::assertEquals('bar', $result['foo']); | ||
} | ||
|
||
private static function createThrowable(): \Throwable | ||
{ | ||
return new \Exception('foo', self::code()); | ||
} | ||
|
||
private static function code(): int | ||
{ | ||
return 1638882641; | ||
} | ||
|
||
} |