Skip to content

Commit

Permalink
feat(tests): add a method to generate the IRI from a resource (#5582)
Browse files Browse the repository at this point in the history
* feat: add a method to generate the IRI from a resource

* fix: code style

* fix: use new method inside findByIri

* refactor: rename method

* fix: method name
  • Loading branch information
GaryPEGEOT authored May 5, 2023
1 parent f66bc9c commit 7a1d351
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Symfony/Bundle/Test/ApiTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,17 @@ protected function findIriBy(string $resourceClass, array $criteria): ?string
return null;
}

return $this->getIriFromResource($item);
}

/**
* Generate the IRI of a resource item.
*/
protected function getIriFromResource(object $resource): ?string
{
/** @var IriConverterInterface $iriConverter */
$iriConverter = $container->get('api_platform.iri_converter');
$iriConverter = static::getContainer()->get('api_platform.iri_converter');

return $iriConverter->getIriFromResource($item);
return $iriConverter->getIriFromResource($resource);
}
}

0 comments on commit 7a1d351

Please sign in to comment.