Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(tests): add a method to generate the IRI from a resource#5582

Merged
soyuka merged 5 commits into
api-platform:mainfrom
GaryPEGEOT:patch-1
May 5, 2023
Merged

feat(tests): add a method to generate the IRI from a resource#5582
soyuka merged 5 commits into
api-platform:mainfrom
GaryPEGEOT:patch-1

Conversation

@GaryPEGEOT
Copy link
Copy Markdown
Contributor

Q A
Branch? main
Tickets
License MIT
Doc PR

Use case:

$code = CouponCodeFactory::createOne(['code' => 'FOOBAR_123']);

$response = $client->request('POST', '/cart', [
    'json' => [
        ...
        'code' => getIriForResource($code->object()), // Instead of findIriBy(['code' => 'FOOBAR_123']) or manually generating IRI                
    ],
]);

self::assertResponseIsSuccessful();

@GaryPEGEOT GaryPEGEOT changed the title feat: add a method to generate the IRI from a resource feat(tests): add a method to generate the IRI from a resource May 4, 2023
Comment thread src/Symfony/Bundle/Test/ApiTestCase.php Outdated
/**
* Generate the IRI of a resource item.
*/
protected function getIriForResource(object $resource): ?string
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about using the same method name as for the iri converter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test needs fixing then :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad 😅 fixed

@soyuka soyuka merged commit 7a1d351 into api-platform:main May 5, 2023
@soyuka
Copy link
Copy Markdown
Member

soyuka commented May 5, 2023

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants