Skip to content

Commit 7a1d351

Browse files
authored
feat(tests): add a method to generate the IRI from a resource (api-platform#5582)
* 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
1 parent f66bc9c commit 7a1d351

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Symfony/Bundle/Test/ApiTestCase.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,17 @@ protected function findIriBy(string $resourceClass, array $criteria): ?string
9494
return null;
9595
}
9696

97+
return $this->getIriFromResource($item);
98+
}
99+
100+
/**
101+
* Generate the IRI of a resource item.
102+
*/
103+
protected function getIriFromResource(object $resource): ?string
104+
{
97105
/** @var IriConverterInterface $iriConverter */
98-
$iriConverter = $container->get('api_platform.iri_converter');
106+
$iriConverter = static::getContainer()->get('api_platform.iri_converter');
99107

100-
return $iriConverter->getIriFromResource($item);
108+
return $iriConverter->getIriFromResource($resource);
101109
}
102110
}

0 commit comments

Comments
 (0)