https://github.com/bpolaszek/ulid-denormalization-bug
https://github.com/bpolaszek/ulid-denormalization-bug
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bpolaszek/ulid-denormalization-bug
- Owner: bpolaszek
- Created: 2022-01-03T08:48:29.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-03T08:50:15.000Z (about 4 years ago)
- Last Synced: 2025-01-10T09:59:34.324Z (about 1 year ago)
- Language: PHP
- Size: 43 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
```php
# tests/SerializationTest.php
it('is supposed to work', function () {
/** @var NormalizerInterface $normalizer */
$normalizer = container()->get(NormalizerInterface::class);
/** @var DenormalizerInterface $denormalizer */
$denormalizer = container()->get(DenormalizerInterface::class);
// Given
$book = new Book();
$book->id = new Ulid();
$book->name = 'Api-Platform for dummies';
$normalized = $normalizer->normalize($book);
// When
/** @var Book $denormalized */
$denormalized = $denormalizer->denormalize($normalized, Book::class);
// Then
expect($denormalized)->toBeInstanceOf(Book::class);
expect($denormalized->name)->toBe('Api-Platform for dummies');
expect($denormalized->id)->toBeInstanceOf(Ulid::class); // 👉 Fails
});
```
```bash
vendor/bin/pest
```
👇
> Typed property App\Entity\Book::$id must not be accessed before initialization