8000 [FrameworkBundle][Serializer] Add an ArgumentResolver to deserialize & validate user input by GaryPEGEOT · Pull Request #45628 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle][Serializer] Add an ArgumentResolver to deserialize & validate user input #45628

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

Closed
wants to merge 13 commits into from
Closed
Prev Previous commit
Next Next commit
fix: make FabBot happy
  • Loading branch information
GaryPEGEOT committed Mar 9, 2022
commit 642c7d03037b5e019608e1382da61fe0901b0a58
9 changes: 9 additions & 0 deletions src/Symfony/Component/Serializer/Annotation/Input.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Serializer\Annotation;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Serializer\ArgumentResolver;

use Symfony\Component\HttpFoundation\Request;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Serializer\EventListener;

use Psr\Log\LoggerInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ protected function setUp(): void
$this->resolver = new UserInputResolver(Validation::createValidatorBuilder()->enableAnnotationMapping()->getValidator(), new Serializer($normalizers, $encoders));
}

public function testSupports(): void
public function testSupports()
{
$this->assertTrue($this->resolver->supports(new Request(), $this->createMetadata()), 'Should be supported');

$this->assertFalse($this->resolver->supports(new Request(), $this->createMetadata([])), 'Should not be supported');
}

public function testResolveWithValidValue(): void
public function testResolveWithValidValue()
{
$json = '{"randomText": "Lorem ipsum"}';
$request = new Request(content: $json);
Expand All @@ -48,7 +48,7 @@ public function testResolveWithValidValue(): void
/**
* @dataProvider provideInvalidValues
*/
public function testResolveWithInvalidValue(string $content, array $groups = ['Default']): void
public function testResolveWithInvalidValue(string $content, array $groups = ['Default'])
{
$this->expectException(ValidationFailedException::class);
$request = new Request(content: $content);
Expand Down
0