@@ -452,7 +452,7 @@ public function testNormalizeResourceCollectionWithoutPrefix(): void
452452 ], $ actual );
453453 }
454454
455- public function testNormalizeCollectionWithHydraOperations (): void
455+ public function testNormalizeResourceCollectionWithHydraOperations (): void
456456 {
457457 $ fooOne = new Foo ();
458458 $ fooOne ->id = 1 ;
@@ -492,8 +492,8 @@ public function testNormalizeCollectionWithHydraOperations(): void
492492 $ contextBuilderProphecy ->reveal (),
493493 $ resourceClassResolverProphecy ->reveal (),
494494 $ iriConverterProphecy ->reveal (),
495- $ resourceMetadataCollectionFactoryProphecy -> reveal () ,
496- [ ' hydra_prefix ' => false , ' hydra_operations ' => true ]
495+ [ ' hydra_prefix ' => false , ' hydra_operations ' => true ] ,
496+ $ resourceMetadataCollectionFactoryProphecy -> reveal ()
497497 );
498498 $ normalizer ->setNormalizer ($ delegateNormalizerProphecy ->reveal ());
499499
@@ -502,22 +502,41 @@ public function testNormalizeCollectionWithHydraOperations(): void
502502 'resource_class ' => Foo::class,
503503 ]);
504504
505- $ this ->assertArrayHasKey ('supportedOperation ' , $ actual );
506- $ this ->assertIsArray ($ actual ['supportedOperation ' ]);
507- $ this ->assertNotEmpty ($ actual ['supportedOperation ' ]);
508-
509- $ methods = array_map (static fn ($ op ) => $ op ['method ' ] ?? null , $ actual ['supportedOperation ' ]);
510- $ this ->assertContains ('GET ' , $ methods );
511- $ this ->assertContains ('POST ' , $ methods );
512-
513- $ this ->assertArrayHasKey ('@context ' , $ actual );
514- $ this ->assertArrayHasKey ('@id ' , $ actual );
515- $ this ->assertArrayHasKey ('@type ' , $ actual );
516- $ this ->assertArrayHasKey ('member ' , $ actual );
517- $ this ->assertArrayHasKey ('totalItems ' , $ actual );
505+ $ this ->assertEquals ([
506+ '@context ' => '/contexts/Foo ' ,
507+ '@id ' => '/foos ' ,
508+ '@type ' => 'Collection ' ,
509+ 'member ' => [
510+ $ normalizedFooOne ,
511+ ],
512+ 'totalItems ' => 1 ,
513+ 'operation ' => [
514+ [
515+ '@type ' => [
516+ 'Operation ' ,
517+ 'schema:FindAction ' ,
518+ ],
519+ 'description ' => 'Retrieves the collection of Foo resources. ' ,
520+ 'method ' => 'GET ' ,
521+ 'returns ' => 'Collection ' ,
522+ 'title ' => 'getFooCollection ' ,
523+ ],
524+ [
525+ '@type ' => [
526+ 'Operation ' ,
527+ 'schema:CreateAction ' ,
528+ ],
529+ 'description ' => 'Creates a Foo resource. ' ,
530+ 'expects ' => 'Foo ' ,
531+ 'method ' => 'POST ' ,
532+ 'returns ' => 'Foo ' ,
533+ 'title ' => 'postFoo ' ,
534+ ],
535+ ],
536+ ], $ actual );
518537 }
519538
520- public function testNormalizeCollectionWithMultipleApiResourcesAndHydraOperations (): void
539+ public function testNormalizeResourceCollectionWithHydraOperationsMultipleApiResource (): void
521540 {
522541 $ fooOne = new Foo ();
523542 $ fooOne ->id = 1 ;
@@ -560,8 +579,8 @@ public function testNormalizeCollectionWithMultipleApiResourcesAndHydraOperation
560579 $ contextBuilderProphecy ->reveal (),
561580 $ resourceClassResolverProphecy ->reveal (),
562581 $ iriConverterProphecy ->reveal (),
563- $ resourceMetadataCollectionFactoryProphecy -> reveal () ,
564- [ ' hydra_prefix ' => false , ' hydra_operations ' => true ]
582+ [ ' hydra_prefix ' => false , ' hydra_operations ' => true ] ,
583+ $ resourceMetadataCollectionFactoryProphecy -> reveal ()
565584 );
566585 $ normalizer ->setNormalizer ($ delegateNormalizerProphecy ->reveal ());
567586
@@ -570,20 +589,37 @@ public function testNormalizeCollectionWithMultipleApiResourcesAndHydraOperation
570589 'resource_class ' => Foo::class,
571590 ]);
572591
573- $ this ->assertArrayHasKey ('supportedOperation ' , $ actual );
574- $ this ->assertIsArray ($ actual ['supportedOperation ' ]);
575-
576- $ this ->assertCount (2 , $ actual ['supportedOperation ' ]);
577-
578- $ methods = array_map (static fn ($ op ) => $ op ['method ' ] ?? null , $ actual ['supportedOperation ' ]);
579- $ this ->assertContains ('GET ' , $ methods );
580- $ this ->assertContains ('POST ' , $ methods );
581-
582- $ this ->assertArrayHasKey ('@context ' , $ actual );
583- $ this ->assertArrayHasKey ('@id ' , $ actual );
584- $ this ->assertArrayHasKey ('@type ' , $ actual );
585- $ this ->assertEquals ('Collection ' , $ actual ['@type ' ]);
586- $ this ->assertArrayHasKey ('member ' , $ actual );
587- $ this ->assertArrayHasKey ('totalItems ' , $ actual );
592+ $ this ->assertEquals ([
593+ '@context ' => '/contexts/Foo ' ,
594+ '@id ' => '/foos ' ,
595+ '@type ' => 'Collection ' ,
596+ 'member ' => [
597+ $ normalizedFooOne ,
598+ ],
599+ 'totalItems ' => 1 ,
600+ 'operation ' => [
601+ [
602+ '@type ' => [
603+ 'Operation ' ,
604+ 'schema:FindAction ' ,
605+ ],
606+ 'description ' => 'Retrieves the collection of Foo resources. ' ,
607+ 'method ' => 'GET ' ,
608+ 'returns ' => 'Collection ' ,
609+ 'title ' => 'getFooCollection ' ,
610+ ],
611+ [
612+ '@type ' => [
613+ 'Operation ' ,
614+ 'schema:CreateAction ' ,
615+ ],
616+ 'description ' => 'Creates a Foo resource. ' ,
617+ 'expects ' => 'Foo ' ,
618+ 'method ' => 'POST ' ,
619+ 'returns ' => 'Foo ' ,
620+ 'title ' => 'postFoo ' ,
621+ ],
622+ ],
623+ ], $ actual );
588624 }
589625}
0 commit comments