Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
140 additions
and
13 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
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
54 changes: 54 additions & 0 deletions
54
tests/Bridge/RamseyUuid/Serializer/UuidDenormalizerTest.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,54 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Core\Tests\Bridge\RamseyUuid\Serializer; | ||
|
||
use ApiPlatform\Core\Bridge\RamseyUuid\Serializer\UuidDenormalizer; | ||
use PHPUnit\Framework\TestCase; | ||
use Ramsey\Uuid\Uuid; | ||
use Symfony\Component\Serializer\Exception\NotNormalizableValueException; | ||
|
||
class UuidDenormalizerTest extends TestCase | ||
{ | ||
public function testDenormalizeUuid() | ||
{ | ||
$uuid = Uuid::uuid4(); | ||
$normalizer = new UuidDenormalizer(); | ||
$this->assertTrue($normalizer->supportsDenormalization($uuid->toString(), Uuid::class)); | ||
$this->assertEquals($uuid, $normalizer->denormalize($uuid->toString(), Uuid::class)); | ||
} | ||
|
||
public function testNoSupportDenormalizeUuid() | ||
{ | ||
$uuid = 'notanuuid'; | ||
$normalizer = new UuidDenormalizer(); | ||
$this->assertFalse($normalizer->supportsDenormalization($uuid, '')); | ||
} | ||
|
||
public function testFailDenormalizeUuid() | ||
{ | ||
$this->expectException(NotNormalizableValueException::class); | ||
|
||
$uuid = 'notanuuid'; | ||
$normalizer = new UuidDenormalizer(); | ||
$this->assertTrue($normalizer->supportsDenormalization($uuid, Uuid::class)); | ||
$normalizer->denormalize($uuid, Uuid::class); | ||
} | ||
|
||
public function testDoNotSupportNotString() | ||
{ | ||
$uuid = Uuid::uuid4(); | ||
$normalizer = new UuidDenormalizer(); | ||
$this->assertFalse($normalizer->supportsDenormalization($uuid, Uuid::class)); | ||
} | ||
} |
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