Skip to content

Commit b196d8a

Browse files
committed
MAGETWO-46832: Downloadable webAPI tests tries to acces associative array via ID when keys have only natural identifiers
1 parent 1c6dd25 commit b196d8a

File tree

1 file changed

+13
-19
lines changed
  • dev/tests/integration/testsuite/Magento/Downloadable/Model/Product

1 file changed

+13
-19
lines changed

dev/tests/integration/testsuite/Magento/Downloadable/Model/Product/TypeTest.php

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,27 @@ public function testSaveTypeSpecificData()
110110
$sampleFactory = $objectManager->create('Magento\Downloadable\Api\Data\SampleInterfaceFactory');
111111
$linkFactory = $objectManager->create('Magento\Downloadable\Api\Data\LinkInterfaceFactory');
112112
$extension = $product->getExtensionAttributes();
113+
$expectedLink = [
114+
'is_shareable' => '2',
115+
'link_type' => 'file',
116+
'link_file' => '/j/e/jellyfish_2_4.jpg',
117+
'number_of_downloads' => '15',
118+
'price' => '15.0000',
119+
'sample_type' => 'file',
120+
'sort_order' => '1',
121+
'title' => 'Updated downloadable link #1',
122+
];
113123
$links = [];
114124
foreach ($downloadableData['link'] as $linkData) {
115125
if (!$linkData || (isset($linkData['is_delete']) && (bool)$linkData['is_delete'])) {
116126
continue;
117127
} else {
118128
$link = $linkFactory->create(['data' => $linkData]);
119-
$link->setId(null);
120-
if (isset($linkData['link_id'])) {
121-
$link->setId($linkData['link_id']);
122-
}
129+
$link->setId($linkData['link_id']);
123130
if (isset($linkData['sample'])) {
124131
$link->setSampleType($linkData['sample']['type']);
125132
$link->setSampleFileData($linkData['sample']['file']);
133+
$expectedLink['sample_file'] = $linkData['sample']['file'];
126134
$link->setSampleUrl($linkData['sample']['url']);
127135
}
128136
$link->setLinkType($linkData['type']);
@@ -150,9 +158,8 @@ public function testSaveTypeSpecificData()
150158
if (!$sampleData || (isset($sampleData['is_delete']) && (bool)$sampleData['is_delete'])) {
151159
continue;
152160
} else {
153-
unset($sampleData['sample_id']);
154161
$sample = $sampleFactory->create(['data' => $sampleData]);
155-
$sample->setId(null);
162+
$sample->setId($sampleData['sample_id']);
156163
$sample->setStoreId($product->getStoreId());
157164
$sample->setSampleType($sampleData['type']);
158165
$sample->setSampleUrl($sampleData['sample_url']);
@@ -172,26 +179,13 @@ public function testSaveTypeSpecificData()
172179
$product->setTypeHasRequiredOptions(false)->setRequiredOptions(false);
173180
}
174181

175-
176-
177182
$product->save();
178183
/** @var \Magento\Catalog\Model\Product $product */
179184
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
180185
'Magento\Catalog\Model\Product'
181186
);
182187
$product->load(1);
183188

184-
$expectedLink = [
185-
'is_shareable' => '2',
186-
'link_type' => 'file',
187-
'link_file' => '/j/e/jellyfish_2_4.jpg',
188-
'number_of_downloads' => '15',
189-
'price' => '15.0000',
190-
'sample_file' => '/n/d/jellyfish_1_3.jpg',
191-
'sample_type' => 'file',
192-
'sort_order' => '1',
193-
'title' => 'Updated downloadable link #1',
194-
];
195189
$links = $product->getExtensionAttributes()->getDownloadableProductLinks();
196190

197191
$this->assertNotEmpty($links);

0 commit comments

Comments
 (0)