-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixing services * Testing the services definition
- Loading branch information
1 parent
06cb9e1
commit 5b6ce5a
Showing
9 changed files
with
162 additions
and
20 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Phauthentic\Symfony\ProblemDetails\Tests\Unit; | ||
|
||
use Phauthentic\Symfony\ProblemDetails\ThrowableToProblemDetailsKernelListener; | ||
use PHPUnit\Framework\TestCase; | ||
use ReflectionClass; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; | ||
use Phauthentic\Symfony\ProblemDetails\ExceptionConversion\ValidationFailedExceptionConverter; | ||
use Phauthentic\Symfony\ProblemDetails\ExceptionConversion\HttpExceptionConverter; | ||
use Phauthentic\Symfony\ProblemDetails\ExceptionConversion\GenericExceptionConverter; | ||
|
||
/** | ||
* | ||
*/ | ||
class ServiceLoadingTest extends TestCase | ||
{ | ||
public function testCreateValidResponse(): void | ||
{ | ||
// Arrange | ||
$container = new ContainerBuilder(); | ||
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../../config')); | ||
$loader->load('services.yaml'); | ||
$container->compile(); | ||
|
||
// Assert | ||
$listener = $container->get(ThrowableToProblemDetailsKernelListener::class); | ||
$this->assertInstanceOf(ThrowableToProblemDetailsKernelListener::class, $listener); | ||
|
||
$reflectionClass = new ReflectionClass($listener); | ||
$converters = $reflectionClass->getProperty('exceptionConverters')->getValue($listener); | ||
$result = []; | ||
foreach ($converters as $converter) { | ||
$result[] = get_class($converter); | ||
} | ||
$this->assertCount(3, $result); | ||
$this->assertEquals([ | ||
ValidationFailedExceptionConverter::class, | ||
HttpExceptionConverter::class, | ||
GenericExceptionConverter::class, | ||
], $result); | ||
} | ||
} |