1515use App \Tests \Api \Security \TokenGenerator ;
1616use App \Tests \Api \Trait \SerializerTrait ;
1717use PHPUnit \Framework \Attributes \DataProvider ;
18+ use PHPUnit \Framework \Attributes \Group ;
1819use PHPUnit \Framework \Attributes \Test ;
1920use Symfony \Component \HttpFoundation \Response ;
2021use Symfony \Component \Mercure \Update ;
@@ -363,8 +364,8 @@ public static function getInvalidData(): iterable
363364 }
364365
365366 #[Test]
366- #[\ PHPUnit \ Framework \ Attributes \ Group('apiCall ' )]
367- #[\ PHPUnit \ Framework \ Attributes \ Group('mercure ' )]
367+ #[Group('apiCall ' )]
368+ #[Group('mercure ' )]
368369 public function asAdminUserICanCreateABook (): void
369370 {
370371 $ token = self ::getContainer ()->get (TokenGenerator::class)->generateToken ([
@@ -424,13 +425,13 @@ public function asNonAdminUserICannotUpdateBook(int $expectedCode, string $hydra
424425 $ options ['auth_bearer ' ] = $ token ;
425426 }
426427
427- $ this ->client ->request ('PUT ' , '/admin/books/ ' . $ book ->getId (), $ options + [
428+ $ this ->client ->request ('PATCH ' , '/admin/books/ ' . $ book ->getId (), $ options + [
428429 'json ' => [
429430 'book ' => 'https://gutendex.com/books/31547.json ' ,
430431 'condition ' => BookCondition::NewCondition->value ,
431432 ],
432433 'headers ' => [
433- 'Content-Type ' => 'application/ld +json ' ,
434+ 'Content-Type ' => 'application/merge-patch +json ' ,
434435 'Accept ' => 'application/ld+json ' ,
435436 ],
436437 ]);
@@ -454,13 +455,13 @@ public function asAdminUserICannotUpdateAnInvalidBook(): void
454455 'email ' => UserFactory::createOneAdmin ()->email ,
455456 ]);
456457
457- $ this ->client ->request ('PUT ' , '/admin/books/invalid ' , [
458+ $ this ->client ->request ('PATCH ' , '/admin/books/invalid ' , [
458459 'auth_bearer ' => $ token ,
459460 'json ' => [
460461 'condition ' => BookCondition::DamagedCondition->value ,
461462 ],
462463 'headers ' => [
463- 'Content-Type ' => 'application/ld +json ' ,
464+ 'Content-Type ' => 'application/merge-patch +json ' ,
464465 'Accept ' => 'application/ld+json ' ,
465466 ],
466467 ]);
@@ -478,11 +479,11 @@ public function asAdminUserICannotUpdateABookWithInvalidData(array $data, int $s
478479 'email ' => UserFactory::createOneAdmin ()->email ,
479480 ]);
480481
481- $ this ->client ->request ('PUT ' , '/admin/books/ ' . $ book ->getId (), [
482+ $ this ->client ->request ('PATCH ' , '/admin/books/ ' . $ book ->getId (), [
482483 'auth_bearer ' => $ token ,
483484 'json ' => $ data ,
484485 'headers ' => [
485- 'Content-Type ' => 'application/ld +json ' ,
486+ 'Content-Type ' => 'application/merge-patch +json ' ,
486487 'Accept ' => 'application/ld+json ' ,
487488 ],
488489 ]);
@@ -494,29 +495,27 @@ public function asAdminUserICannotUpdateABookWithInvalidData(array $data, int $s
494495 }
495496
496497 #[Test]
497- #[\ PHPUnit \ Framework \ Attributes \ Group('apiCall ' )]
498- #[\ PHPUnit \ Framework \ Attributes \ Group('mercure ' )]
498+ #[Group('apiCall ' )]
499+ #[Group('mercure ' )]
499500 public function asAdminUserICanUpdateABook (): void
500501 {
501502 $ book = BookFactory::createOne ([
502503 'book ' => 'https://gutendex.com/books/31547.json ' ,
504+ 'condition ' => BookCondition::UsedCondition,
503505 ]);
504506 self ::getMercureHub ()->reset ();
505507
506508 $ token = self ::getContainer ()->get (TokenGenerator::class)->generateToken ([
507509 'email ' => UserFactory::createOneAdmin ()->email ,
508510 ]);
509511
510- $ response = $ this ->client ->request ('PUT ' , '/admin/books/ ' . $ book ->getId (), [
512+ $ response = $ this ->client ->request ('PATCH ' , '/admin/books/ ' . $ book ->getId (), [
511513 'auth_bearer ' => $ token ,
512514 'json ' => [
513- '@id ' => '/books/ ' . $ book ->getId (),
514- // Must set all data because of standard PUT
515- 'book ' => 'https://gutendex.com/books/31547.json ' ,
516515 'condition ' => BookCondition::DamagedCondition->value ,
517516 ],
518517 'headers ' => [
519- 'Content-Type ' => 'application/ld +json ' ,
518+ 'Content-Type ' => 'application/merge-patch +json ' ,
520519 'Accept ' => 'application/ld+json ' ,
521520 ],
522521 ]);
@@ -586,7 +585,7 @@ public function asAdminUserICannotDeleteAnInvalidBook(): void
586585 }
587586
588587 #[Test]
589- #[\ PHPUnit \ Framework \ Attributes \ Group('mercure ' )]
588+ #[Group('mercure ' )]
590589 public function asAdminUserICanDeleteABook (): void
591590 {
592591 $ book = BookFactory::createOne (['title ' => 'Hyperion ' ]);
0 commit comments