Skip to content

Commit

Permalink
[Api] Refactor fetching id from IRI converter to direct object
Browse files Browse the repository at this point in the history
  • Loading branch information
lchrusciel committed Feb 26, 2021
1 parent 6070216 commit e7d1f2d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/Sylius/Bundle/ApiBundle/test/src/Tests/FooTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ public function it_allows_to_get_collection_as_a_visitor(): void
*/
public function it_allows_to_get_item_by_iri(): void
{
$response = static::createClient()->request('GET', $this->findIriBy(Foo::class, ['name' => 'Foo0']));
/** @var Foo $foo */
$foo = $this->objects['foo1'];

$response = static::createClient()->request('GET', 'api/v2/foos/' . $foo->getId());

$this->assertResponseIsSuccessful();
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ trait SetUpTestsTrait
/** @var array */
private $fixturesFiles;

/** @var array */
private $objects;

public function setFixturesFiles(array $fixturesFiles)
{
$this->fixturesFiles = array_merge(
Expand All @@ -43,9 +46,9 @@ public function setUpTest(): void
/** @var JWTTokenManagerInterface $JWTManager */
$JWTManager = $container->get('lexik_jwt_authentication.jwt_manager');

$objects = $loader->load($this->fixturesFiles, [], [], PurgeMode::createDeleteMode());
$this->objects = $loader->load($this->fixturesFiles, [], [], PurgeMode::createDeleteMode());

$adminUser = $objects['admin'];
$adminUser = $this->objects['admin'];

$this->JWTAdminUserToken = $JWTManager->create($adminUser);
}
Expand Down

0 comments on commit e7d1f2d

Please sign in to comment.