Skip to content

Commit 7e6827d

Browse files
impr
1 parent a09d71a commit 7e6827d

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

app/code/Magento/Downloadable/Model/Link/UpdateHandler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function __construct(LinkRepository $linkRepository)
3636
* @param object $entity
3737
* @param array $arguments
3838
* @return ProductInterface|object
39+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
3940
*/
4041
public function execute($entity, $arguments = [])
4142
{

app/code/Magento/Downloadable/Model/Sample/UpdateHandler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function __construct(SampleRepository $sampleRepository)
3636
* @param object $entity
3737
* @param array $arguments
3838
* @return ProductInterface|object
39+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
3940
*/
4041
public function execute($entity, $arguments = [])
4142
{

dev/tests/api-functional/testsuite/Magento/Downloadable/Api/ProductRepositoryTest.php

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,35 @@
88

99
use Magento\Catalog\Api\Data\ProductInterface;
1010
use Magento\Framework\Api\ExtensibleDataInterface;
11+
use Magento\TestFramework\Helper\Bootstrap;
1112
use Magento\TestFramework\TestCase\WebapiAbstract;
1213

1314
/**
1415
* Class ProductRepositoryTest for testing ProductRepository interface with Downloadable Product
1516
*/
1617
class ProductRepositoryTest extends WebapiAbstract
1718
{
18-
const SERVICE_NAME = 'catalogProductRepositoryV1';
19-
const SERVICE_VERSION = 'V1';
20-
const RESOURCE_PATH = '/V1/products';
21-
const PRODUCT_SKU = 'sku-test-product-downloadable';
19+
private const SERVICE_NAME = 'catalogProductRepositoryV1';
20+
private const SERVICE_VERSION = 'V1';
21+
private const RESOURCE_PATH = '/V1/products';
22+
private const PRODUCT_SKU = 'sku-test-product-downloadable';
23+
24+
private const PRODUCT_SAMPLES = 'downloadable_product_samples';
25+
private const PRODUCT_LINKS = 'downloadable_product_links';
2226

2327
/**
2428
* @var string
2529
*/
26-
protected $testImagePath;
30+
private $testImagePath;
2731

32+
/**
33+
* @inheritdoc
34+
*/
2835
protected function setUp(): void
2936
{
30-
parent::setUp();
31-
$this->testImagePath = __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'test_image.jpg';
37+
$objectManager = Bootstrap::getObjectManager();
3238

33-
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
39+
$this->testImagePath = __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'test_image.jpg';
3440

3541
/** @var DomainManagerInterface $domainManager */
3642
$domainManager = $objectManager->get(DomainManagerInterface::class);
@@ -45,7 +51,7 @@ protected function tearDown(): void
4551
$this->deleteProductBySku(self::PRODUCT_SKU);
4652
parent::tearDown();
4753

48-
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
54+
$objectManager = Bootstrap::getObjectManager();
4955

5056
/** @var DomainManagerInterface $domainManager */
5157
$domainManager = $objectManager->get(DomainManagerInterface::class);
@@ -303,26 +309,26 @@ public function testUpdateDownloadableProductLinks()
303309
*/
304310
public function testUpdateDownloadableProductData(): void
305311
{
306-
$this->createDownloadableProduct();
307-
$extensionAttributes = ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY;
312+
$productResponce = $this->createDownloadableProduct();
313+
$stockItemData = $productResponce[ProductInterface::EXTENSION_ATTRIBUTES_KEY]['stock_item'];
314+
315+
$stockItemData = TESTS_WEB_API_ADAPTER === self::ADAPTER_SOAP
316+
? $stockItemData['manage_stock'] = false
317+
: ['stock_item' => ['manage_stock' => false]];
308318

309319
$productData = [
310320
ProductInterface::SKU => self::PRODUCT_SKU,
311-
ProductInterface::EXTENSION_ATTRIBUTES_KEY => [
312-
'stock_item' => [
313-
'manage_stock' => false,
314-
],
315-
],
321+
ProductInterface::EXTENSION_ATTRIBUTES_KEY => $stockItemData,
316322
];
317323

318324
$response = $this->saveProduct($productData);
319325

320-
$this->assertArrayHasKey(ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY, $response);
321-
$this->assertArrayHasKey('downloadable_product_samples', $response[$extensionAttributes]);
322-
$this->assertArrayHasKey('downloadable_product_links', $response[$extensionAttributes]);
326+
$this->assertArrayHasKey(ProductInterface::EXTENSION_ATTRIBUTES_KEY, $response);
327+
$this->assertArrayHasKey(self::PRODUCT_SAMPLES, $response[ProductInterface::EXTENSION_ATTRIBUTES_KEY]);
328+
$this->assertArrayHasKey(self::PRODUCT_LINKS, $response[ProductInterface::EXTENSION_ATTRIBUTES_KEY]);
323329

324-
$this->assertCount(2, $response[$extensionAttributes]['downloadable_product_samples']);
325-
$this->assertCount(2, $response[$extensionAttributes]['downloadable_product_links']);
330+
$this->assertCount(2, $response[ProductInterface::EXTENSION_ATTRIBUTES_KEY][self::PRODUCT_SAMPLES]);
331+
$this->assertCount(2, $response[ProductInterface::EXTENSION_ATTRIBUTES_KEY][self::PRODUCT_LINKS]);
326332
}
327333

328334
/**

0 commit comments

Comments
 (0)