8
8
9
9
use Magento \Catalog \Api \Data \ProductInterface ;
10
10
use Magento \Framework \Api \ExtensibleDataInterface ;
11
+ use Magento \TestFramework \Helper \Bootstrap ;
11
12
use Magento \TestFramework \TestCase \WebapiAbstract ;
12
13
13
14
/**
14
15
* Class ProductRepositoryTest for testing ProductRepository interface with Downloadable Product
15
16
*/
16
17
class ProductRepositoryTest extends WebapiAbstract
17
18
{
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 ' ;
22
26
23
27
/**
24
28
* @var string
25
29
*/
26
- protected $ testImagePath ;
30
+ private $ testImagePath ;
27
31
32
+ /**
33
+ * @inheritdoc
34
+ */
28
35
protected function setUp (): void
29
36
{
30
- parent ::setUp ();
31
- $ this ->testImagePath = __DIR__ . DIRECTORY_SEPARATOR . '_files ' . DIRECTORY_SEPARATOR . 'test_image.jpg ' ;
37
+ $ objectManager = Bootstrap::getObjectManager ();
32
38
33
- $ objectManager = \ Magento \ TestFramework \ Helper \Bootstrap:: getObjectManager () ;
39
+ $ this -> testImagePath = __DIR__ . DIRECTORY_SEPARATOR . ' _files ' . DIRECTORY_SEPARATOR . ' test_image.jpg ' ;
34
40
35
41
/** @var DomainManagerInterface $domainManager */
36
42
$ domainManager = $ objectManager ->get (DomainManagerInterface::class);
@@ -45,7 +51,7 @@ protected function tearDown(): void
45
51
$ this ->deleteProductBySku (self ::PRODUCT_SKU );
46
52
parent ::tearDown ();
47
53
48
- $ objectManager = \ Magento \ TestFramework \ Helper \ Bootstrap::getObjectManager ();
54
+ $ objectManager = Bootstrap::getObjectManager ();
49
55
50
56
/** @var DomainManagerInterface $domainManager */
51
57
$ domainManager = $ objectManager ->get (DomainManagerInterface::class);
@@ -303,26 +309,26 @@ public function testUpdateDownloadableProductLinks()
303
309
*/
304
310
public function testUpdateDownloadableProductData (): void
305
311
{
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 ]];
308
318
309
319
$ productData = [
310
320
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 ,
316
322
];
317
323
318
324
$ response = $ this ->saveProduct ($ productData );
319
325
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 ]);
323
329
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 ]);
326
332
}
327
333
328
334
/**
0 commit comments