Add serializer groups to SignedUrl and SignedUrlPost classes, include tests

Serializer groups have been added to the SignedUrl and SignedUrlPost classes to ensure correct serialization. Two new test files were also included: SignedUrlNormalizerTest and SignedUrlPostNormalizerTest which test the normalization of instances of the classes.
This commit is contained in:
2023-12-11 16:09:26 +01:00
parent 450e7c348b
commit 4fd5a37df3
4 changed files with 164 additions and 0 deletions

View File

@@ -11,11 +11,28 @@ declare(strict_types=1);
namespace Chill\DocStoreBundle\AsyncUpload;
use Symfony\Component\Serializer\Annotation as Serializer;
readonly class SignedUrl
{
public function __construct(
/**
* @Serializer\Groups({"read"})
*/
public string $method,
/**
* @Serializer\Groups({"read"})
*/
public string $url,
public \DateTimeImmutable $expires,
) {}
/**
* @Serializer\Groups({"read"})
*/
public function getExpires(): int
{
return $this->expires->getTimestamp();
}
}

View File

@@ -11,16 +11,42 @@ declare(strict_types=1);
namespace Chill\DocStoreBundle\AsyncUpload;
use Symfony\Component\Serializer\Annotation as Serializer;
readonly class SignedUrlPost extends SignedUrl
{
public function __construct(
string $url,
\DateTimeImmutable $expires,
/**
* @Serializer\Groups({"read"})
*/
public int $max_file_size,
/**
* @Serializer\Groups({"read"})
*/
public int $max_file_count,
/**
* @Serializer\Groups({"read"})
*/
public int $submit_delay,
/**
* @Serializer\Groups({"read"})
*/
public string $redirect,
/**
* @Serializer\Groups({"read"})
*/
public string $prefix,
/**
* @Serializer\Groups({"read"})
*/
public string $signature,
) {
parent::__construct('POST', $url, $expires);