Skip to content

Commit 2ed0b6f

Browse files
committed
adapt tests to be uuid v7 compatible as well
1 parent 76fb997 commit 2ed0b6f

File tree

9 files changed

+64
-63
lines changed

9 files changed

+64
-63
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ A simple skeleton to build api's based on the [chubbyphp-framework][1].
3434
* [chubbyphp/chubbyphp-laminas-config-doctrine][10]: ^3.1.1
3535
* [chubbyphp/chubbyphp-laminas-config-factory][11]: ^1.5.1
3636
* [chubbyphp/chubbyphp-negotiation][12]: ^2.3.1
37-
* [chubbyphp/chubbyphp-parsing][13]: ^2.1.2
37+
* [chubbyphp/chubbyphp-parsing][13]: ^2.4
3838
* [doctrine/mongodb-odm][14]: ^2.15.3
3939
* [monolog/monolog][15]: ^3.10
4040
* [ramsey/uuid][16]: ^4.9.2
@@ -95,9 +95,9 @@ composer setup:dev
9595

9696
* GET https://localhost/api/pets?sort[name]=asc
9797
* POST https://localhost/api/pets
98-
* GET https://localhost/api/pets/8ba9661b-ba7f-436b-bd25-c0606f911f7d
99-
* PUT https://localhost/api/pets/8ba9661b-ba7f-436b-bd25-c0606f911f7d
100-
* DELETE https://localhost/api/pets/8ba9661b-ba7f-436b-bd25-c0606f911f7d
98+
* GET https://localhost/api/pets/019c201f-6a83-7696-9899-50fbf7b2278d
99+
* PUT https://localhost/api/pets/019c201f-6a83-7696-9899-50fbf7b2278d
100+
* DELETE https://localhost/api/pets/019c201f-6a83-7696-9899-50fbf7b2278d
101101

102102
### Database
103103

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"chubbyphp/chubbyphp-laminas-config-doctrine": "^3.1.1",
2727
"chubbyphp/chubbyphp-laminas-config-factory": "^1.5.1",
2828
"chubbyphp/chubbyphp-negotiation": "^2.3.1",
29-
"chubbyphp/chubbyphp-parsing": "^2.1.2",
29+
"chubbyphp/chubbyphp-parsing": "^2.4",
3030
"doctrine/mongodb-odm": "^2.15.3",
3131
"monolog/monolog": "^3.10",
3232
"ramsey/uuid": "^4.9.2",

openapi.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ components:
480480
id:
481481
type: string
482482
format: uuid
483-
example: c9b6657d-3809-45cf-9bf1-a0ccb31e0158
483+
example: 019c201f-6a83-7696-9899-50fbf7b2278d
484484
createdAt:
485485
type: string
486486
format: datetime
@@ -500,7 +500,7 @@ components:
500500
properties:
501501
href:
502502
type: string
503-
example: '/pets/c9b6657d-3809-45cf-9bf1-a0ccb31e0158'
503+
example: '/pets/019c201f-6a83-7696-9899-50fbf7b2278d'
504504
templated:
505505
type: boolean
506506
example: false
@@ -517,7 +517,7 @@ components:
517517
properties:
518518
href:
519519
type: string
520-
example: '/pets/c9b6657d-3809-45cf-9bf1-a0ccb31e0158'
520+
example: '/pets/019c201f-6a83-7696-9899-50fbf7b2278d'
521521
templated:
522522
type: boolean
523523
example: false
@@ -534,7 +534,7 @@ components:
534534
properties:
535535
href:
536536
type: string
537-
example: '/pets/c9b6657d-3809-45cf-9bf1-a0ccb31e0158'
537+
example: '/pets/019c201f-6a83-7696-9899-50fbf7b2278d'
538538
templated:
539539
type: boolean
540540
example: false

src/Pet/Parsing/PetParsing.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Chubbyphp\Api\Collection\CollectionInterface;
1616
use Chubbyphp\Api\Parsing\ParsingInterface;
1717
use Chubbyphp\Framework\Router\UrlGeneratorInterface;
18+
use Chubbyphp\Parsing\Enum\Uuid;
1819
use Chubbyphp\Parsing\ParserInterface;
1920
use Chubbyphp\Parsing\Schema\ObjectSchemaInterface;
2021
use Psr\Http\Message\ServerRequestInterface;
@@ -136,7 +137,7 @@ public function getModelResponseSchema(ServerRequestInterface $request): ObjectS
136137
$p = $this->parser;
137138

138139
$this->modelResponseSchema = $p->object([
139-
'id' => $p->string(),
140+
'id' => $p->string()->uuid(Uuid::v7),
140141
'createdAt' => $p->dateTime()->toString(),
141142
'updatedAt' => $p->dateTime()->nullable()->toString(),
142143
'name' => $p->string(),

tests/Integration/Pet/PetCrudRequestHandlerTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public function testReadWithUnsupportedAccept(): void
252252
{
253253
$response = $this->httpRequest(
254254
'GET',
255-
'/api/pets/e19a00b4-241e-4241-a641-bac2a4a65f64',
255+
'/api/pets/019c201f-6a83-7696-9899-50fbf7b2278d',
256256
[
257257
'Accept' => 'text/html',
258258
]
@@ -265,7 +265,7 @@ public function testReadWithNotFound(): void
265265
{
266266
$response = $this->httpRequest(
267267
'GET',
268-
'/api/pets/e19a00b4-241e-4241-a641-bac2a4a65f64',
268+
'/api/pets/019c201f-6a83-7696-9899-50fbf7b2278d',
269269
[
270270
'Accept' => 'application/json',
271271
]
@@ -316,7 +316,7 @@ public function testUpdateWithUnsupportedAccept(): void
316316
{
317317
$response = $this->httpRequest(
318318
'PUT',
319-
'/api/pets/e19a00b4-241e-4241-a641-bac2a4a65f64',
319+
'/api/pets/019c201f-6a83-7696-9899-50fbf7b2278d',
320320
[
321321
'Accept' => 'text/html',
322322
]
@@ -329,7 +329,7 @@ public function testUpdateWithUnsupportedContentType(): void
329329
{
330330
$response = $this->httpRequest(
331331
'PUT',
332-
'/api/pets/e19a00b4-241e-4241-a641-bac2a4a65f64',
332+
'/api/pets/019c201f-6a83-7696-9899-50fbf7b2278d',
333333
[
334334
'Accept' => 'application/json',
335335
'Content-Type' => 'text/html',
@@ -363,7 +363,7 @@ public function testUpdateWithNotFound(): void
363363
{
364364
$response = $this->httpRequest(
365365
'PUT',
366-
'/api/pets/e19a00b4-241e-4241-a641-bac2a4a65f64',
366+
'/api/pets/019c201f-6a83-7696-9899-50fbf7b2278d',
367367
[
368368
'Accept' => 'application/json',
369369
'Content-Type' => 'application/json',
@@ -483,7 +483,7 @@ public function testDeleteWithUnsupportedAccept(): void
483483
{
484484
$response = $this->httpRequest(
485485
'DELETE',
486-
'/api/pets/e19a00b4-241e-4241-a641-bac2a4a65f64',
486+
'/api/pets/019c201f-6a83-7696-9899-50fbf7b2278d',
487487
[
488488
'Accept' => 'text/html',
489489
]
@@ -496,7 +496,7 @@ public function testDeleteWithNotFound(): void
496496
{
497497
$response = $this->httpRequest(
498498
'DELETE',
499-
'/api/pets/e19a00b4-241e-4241-a641-bac2a4a65f64',
499+
'/api/pets/019c201f-6a83-7696-9899-50fbf7b2278d',
500500
[
501501
'Accept' => 'application/json',
502502
]

tests/Unit/Pet/Dto/Collection/PetCollectionResponseTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public function testCreateCollection(): void
3333
$vaccinationResponse->_type = 'vaccination';
3434

3535
$petResponse = new PetResponse();
36-
$petResponse->id = '93c75323-38a2-4c89-b500-7fc5d9f0c602';
36+
$petResponse->id = '019c201f-6a83-7696-9899-50fbf7b2278d';
3737
$petResponse->createdAt = '2024-02-10T18:15:00+00:00';
3838
$petResponse->updatedAt = '2024-02-10T18:15:00+00:00';
3939
$petResponse->name = 'jerry';
40-
$petResponse->tag = 'efd3c6a6-a12e-4551-bf89-62727fba0d92';
40+
$petResponse->tag = 'tag';
4141
$petResponse->vaccinations = [$vaccinationResponse];
4242
$petResponse->_type = 'pet';
4343
$petResponse->_links = [];
@@ -63,11 +63,11 @@ public function testCreateCollection(): void
6363
],
6464
'items' => [
6565
[
66-
'id' => '93c75323-38a2-4c89-b500-7fc5d9f0c602',
66+
'id' => '019c201f-6a83-7696-9899-50fbf7b2278d',
6767
'createdAt' => '2024-02-10T18:15:00+00:00',
6868
'updatedAt' => '2024-02-10T18:15:00+00:00',
6969
'name' => 'jerry',
70-
'tag' => 'efd3c6a6-a12e-4551-bf89-62727fba0d92',
70+
'tag' => 'tag',
7171
'vaccinations' => [
7272
[
7373
'name' => 'rabid',

tests/Unit/Pet/Dto/Model/PetRequestTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function testCreateModel(): void
2525

2626
$petRequest = new PetRequest();
2727
$petRequest->name = 'jerry';
28-
$petRequest->tag = 'efd3c6a6-a12e-4551-bf89-62727fba0d92';
28+
$petRequest->tag = '019c201f-6a83-7696-9899-50fbf7b2278d';
2929
$petRequest->vaccinations = [$vaccinationRequest];
3030

3131
/** @var Pet $pet */
@@ -39,7 +39,7 @@ public function testCreateModel(): void
3939
self::assertMatchesRegularExpression('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2}$/', $petData['createdAt']->format('c'));
4040
self::assertNull($petData['updatedAt']);
4141
self::assertSame('jerry', $petData['name']);
42-
self::assertSame('efd3c6a6-a12e-4551-bf89-62727fba0d92', $petData['tag']);
42+
self::assertSame('019c201f-6a83-7696-9899-50fbf7b2278d', $petData['tag']);
4343
self::assertSame([
4444
[
4545
'name' => 'rabid',
@@ -54,7 +54,7 @@ public function testUpdateModel(): void
5454

5555
$petRequest = new PetRequest();
5656
$petRequest->name = 'jerry';
57-
$petRequest->tag = 'efd3c6a6-a12e-4551-bf89-62727fba0d92';
57+
$petRequest->tag = '019c201f-6a83-7696-9899-50fbf7b2278d';
5858
$petRequest->vaccinations = [$vaccinationRequest];
5959

6060
$pet = new Pet();
@@ -70,7 +70,7 @@ public function testUpdateModel(): void
7070
self::assertMatchesRegularExpression('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2}$/', $petData['createdAt']->format('c'));
7171
self::assertMatchesRegularExpression('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2}$/', $petData['updatedAt']->format('c'));
7272
self::assertSame('jerry', $petData['name']);
73-
self::assertSame('efd3c6a6-a12e-4551-bf89-62727fba0d92', $petData['tag']);
73+
self::assertSame('019c201f-6a83-7696-9899-50fbf7b2278d', $petData['tag']);
7474
self::assertSame([
7575
[
7676
'name' => 'rabid',

tests/Unit/Pet/Dto/Model/PetResponseTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ public function testCreateCollection(): void
2323
$vaccinationResponse->_type = 'vaccination';
2424

2525
$petResponse = new PetResponse();
26-
$petResponse->id = '93c75323-38a2-4c89-b500-7fc5d9f0c602';
26+
$petResponse->id = '019c201f-6a83-7696-9899-50fbf7b2278d';
2727
$petResponse->createdAt = '2024-02-10T18:15:00+00:00';
2828
$petResponse->updatedAt = '2024-02-10T18:15:00+00:00';
2929
$petResponse->name = 'jerry';
30-
$petResponse->tag = 'efd3c6a6-a12e-4551-bf89-62727fba0d92';
30+
$petResponse->tag = 'tag';
3131
$petResponse->vaccinations = [$vaccinationResponse];
3232
$petResponse->_type = 'pet';
3333
$petResponse->_links = [];
3434

3535
self::assertSame([
36-
'id' => '93c75323-38a2-4c89-b500-7fc5d9f0c602',
36+
'id' => '019c201f-6a83-7696-9899-50fbf7b2278d',
3737
'createdAt' => '2024-02-10T18:15:00+00:00',
3838
'updatedAt' => '2024-02-10T18:15:00+00:00',
3939
'name' => 'jerry',
40-
'tag' => 'efd3c6a6-a12e-4551-bf89-62727fba0d92',
40+
'tag' => 'tag',
4141
'vaccinations' => [
4242
[
4343
'name' => 'rabid',

0 commit comments

Comments
 (0)