Skip to content

Commit 28a9a25

Browse files
Added delete product model
1 parent df372b6 commit 28a9a25

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

src/Api/ProductModelApi.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,12 @@ public function upsertList($productModels): \Traversable
122122
{
123123
return $this->resourceClient->upsertStreamResourceList(static::PRODUCT_MODELS_URI, [], $productModels);
124124
}
125+
126+
/**
127+
* {@inheritdoc}
128+
*/
129+
public function delete(string $code): int
130+
{
131+
return $this->resourceClient->deleteResource(static::PRODUCT_MODEL_URI, [$code]);
132+
}
125133
}

src/Api/ProductModelApiInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Akeneo\Pim\ApiClient\Api;
44

55
use Akeneo\Pim\ApiClient\Api\Operation\CreatableResourceInterface;
6+
use Akeneo\Pim\ApiClient\Api\Operation\DeletableResourceInterface;
67
use Akeneo\Pim\ApiClient\Api\Operation\GettableResourceInterface;
78
use Akeneo\Pim\ApiClient\Api\Operation\ListableResourceInterface;
89
use Akeneo\Pim\ApiClient\Api\Operation\UpsertableResourceInterface;
@@ -20,6 +21,7 @@ interface ProductModelApiInterface extends
2021
CreatableResourceInterface,
2122
UpsertableResourceInterface,
2223
UpsertableResourceListInterface,
23-
ListableResourceInterface
24+
ListableResourceInterface,
25+
DeletableResourceInterface
2426
{
2527
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Akeneo\Pim\ApiClient\tests\Api;
4+
5+
use Akeneo\Pim\ApiClient\Api\ProductModelApi;
6+
use donatj\MockWebServer\RequestInfo;
7+
use donatj\MockWebServer\Response;
8+
use donatj\MockWebServer\ResponseStack;
9+
use PHPUnit\Framework\Assert;
10+
11+
class DeleteProductModelTest extends ApiTestCase
12+
{
13+
public function test_delete_product_model()
14+
{
15+
$this->server->setResponseOfPath(
16+
'/'. sprintf(ProductModelApi::PRODUCT_MODEL_URI, 'docks_white'),
17+
new ResponseStack(
18+
new Response('', [], 204)
19+
)
20+
);
21+
22+
$api = $this->createClient()->getProductModelApi();
23+
24+
$response = $api->delete('docks_white');
25+
26+
Assert::assertSame($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_METHOD], 'DELETE');
27+
Assert::assertSame(204, $response);
28+
}
29+
}

0 commit comments

Comments
 (0)