Skip to content

Commit

Permalink
Implement official API client mock (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
lruozzi9 committed Apr 11, 2022
1 parent cf96a0d commit 152c03e
Show file tree
Hide file tree
Showing 7 changed files with 607 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/Integration/TestDouble/AttributeApiMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

namespace Tests\Webgriffe\SyliusAkeneoPlugin\Integration\TestDouble;

use Akeneo\Pim\ApiClient\Api\AttributeApiInterface;
use Akeneo\Pim\ApiClient\Pagination\PageInterface;
use Akeneo\Pim\ApiClient\Pagination\ResourceCursorInterface;

final class AttributeApiMock implements AttributeApiInterface
{
public function create(string $code, array $data = []): int
{
// TODO: Implement create() method.
}

public function get(string $code): array
{
return OfficialApiClientMock::jsonFileOrHttpNotFoundException(
__DIR__ . '/../DataFixtures/ApiClientMock/Attribute/' . $code . '.json'
);
}

public function listPerPage(int $limit = 10, bool $withCount = false, array $queryParameters = []): PageInterface
{
// TODO: Implement listPerPage() method.
}

public function all(int $pageSize = 10, array $queryParameters = []): ResourceCursorInterface
{
// TODO: Implement all() method.
}

public function upsert(string $code, array $data = []): int
{
// TODO: Implement upsert() method.
}

public function upsertList($resources): \Traversable
{
// TODO: Implement upsertList() method.
}
}
48 changes: 48 additions & 0 deletions tests/Integration/TestDouble/AttributeOptionApiMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

declare(strict_types=1);

namespace Tests\Webgriffe\SyliusAkeneoPlugin\Integration\TestDouble;

use Akeneo\Pim\ApiClient\Api\AttributeOptionApiInterface;
use Akeneo\Pim\ApiClient\Pagination\PageInterface;
use Akeneo\Pim\ApiClient\Pagination\ResourceCursorInterface;

final class AttributeOptionApiMock implements AttributeOptionApiInterface
{
public function get($attributeCode, $code): array
{
return OfficialApiClientMock::jsonFileOrHttpNotFoundException(
__DIR__ . '/../DataFixtures/ApiClientMock/AttributeOption/' . $attributeCode . '/' . $code . '.json'
);
}

public function listPerPage(
$attributeCode,
$limit = 10,
$withCount = false,
array $queryParameters = []
): PageInterface {
// TODO: Implement listPerPage() method.
}

public function all($attributeCode, $pageSize = 10, array $queryParameters = []): ResourceCursorInterface
{
// TODO: Implement all() method.
}

public function create($attributeCode, $attributeOptionCode, array $data = []): int
{
// TODO: Implement create() method.
}

public function upsert($attributeCode, $attributeOptionCode, array $data = []): int
{
// TODO: Implement upsert() method.
}

public function upsertList($attributeCode, $attributeOptions): \Traversable
{
// TODO: Implement upsertList() method.
}
}
48 changes: 48 additions & 0 deletions tests/Integration/TestDouble/FamilyVariantApiMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

declare(strict_types=1);

namespace Tests\Webgriffe\SyliusAkeneoPlugin\Integration\TestDouble;

use Akeneo\Pim\ApiClient\Api\FamilyVariantApiInterface;
use Akeneo\Pim\ApiClient\Pagination\PageInterface;
use Akeneo\Pim\ApiClient\Pagination\ResourceCursorInterface;

final class FamilyVariantApiMock implements FamilyVariantApiInterface
{
public function get($familyCode, $familyVariantCode): array
{
return OfficialApiClientMock::jsonFileOrHttpNotFoundException(
__DIR__ . '/../DataFixtures/ApiClientMock/FamilyVariant/' . $familyCode . '/' . $familyVariantCode . '.json'
);
}

public function create($familyCode, $familyVariantCode, array $data = []): int
{
// TODO: Implement create() method.
}

public function upsert($familyCode, $familyVariantCode, array $data = []): int
{
// TODO: Implement upsert() method.
}

public function listPerPage(
$familyCode,
$limit = 10,
$withCount = false,
array $queryParameters = []
): PageInterface {
// TODO: Implement listPerPage() method.
}

public function all($familyCode, $pageSize = 10, array $queryParameters = []): ResourceCursorInterface
{
// TODO: Implement all() method.
}

public function upsertList($familyCode, $familyVariants): \Traversable
{
// TODO: Implement upsertList() method.
}
}
Loading

0 comments on commit 152c03e

Please sign in to comment.