Skip to content

Commit b53324c

Browse files
author
Yu Tang
committed
MAGETWO-28256: Bundle Integration API Refactoring
- Fix build failures
1 parent ae2b98f commit b53324c

File tree

11 files changed

+34
-19
lines changed

11 files changed

+34
-19
lines changed

app/code/Magento/Bundle/Api/Data/LinkInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function getId();
2222
/**
2323
* Set id
2424
*
25-
* @param $id
25+
* @param string $id
2626
* @return $this
2727
*/
2828
public function setId($id);

app/code/Magento/Bundle/Api/ProductLinkManagementInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface ProductLinkManagementInterface
1212
* Get all children for Bundle product
1313
*
1414
* @param string $productSku
15-
* @param int|null $optionId
15+
* @param int $optionId
1616
* @return \Magento\Bundle\Api\Data\LinkInterface[]
1717
* @throws \Magento\Framework\Exception\NoSuchEntityException
1818
* @throws \Magento\Framework\Exception\InputException

app/code/Magento/Bundle/Model/Link.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public function getId()
3636
return $this->getData(self::KEY_ID);
3737
}
3838

39+
/**
40+
* {@inheritdoc}
41+
*/
3942
public function setId($id)
4043
{
4144
return $this->setData(self::KEY_ID, $id);

app/code/Magento/Bundle/Model/LinkManagement.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function getChildren($productSku, $optionId = null)
8484

8585
$childrenList = [];
8686
foreach ($this->getOptions($product) as $option) {
87-
if (!is_null($optionId) && $option->getOptionId() != $optionId) {
87+
if ($optionId !== null && $option->getOptionId() != $optionId) {
8888
continue;
8989
}
9090
/** @var \Magento\Catalog\Model\Product $selection */
@@ -147,7 +147,7 @@ public function saveChild(
147147
try {
148148
$selectionModel->save();
149149
} catch (\Exception $e) {
150-
throw new CouldNotSaveException(__('Could not save child: "%1"', [$e->getMessage()], $e));
150+
throw new CouldNotSaveException(__('Could not save child: "%1"', $e->getMessage()), $e);
151151
}
152152

153153
return $selectionModel->getId();
@@ -168,25 +168,25 @@ protected function mapProductLinkToSelectionModel(
168168
) {
169169
$selectionModel->setProductId($linkedProductId);
170170
$selectionModel->setParentProductId($parentProductId);
171-
if (!is_null($productLink->getOptionId())) {
171+
if (($productLink->getOptionId() !== null)) {
172172
$selectionModel->setOptionId($productLink->getOptionId());
173173
}
174-
if (!is_null($productLink->getPosition())) {
174+
if ($productLink->getPosition() !== null) {
175175
$selectionModel->setPosition($productLink->getPosition());
176176
}
177-
if (!is_null($productLink->getQty())) {
177+
if ($productLink->getQty() !== null) {
178178
$selectionModel->setSelectionQty($productLink->getQty());
179179
}
180-
if (!is_null($productLink->getPriceType())) {
180+
if ($productLink->getPriceType() !== null) {
181181
$selectionModel->setSelectionPriceType($productLink->getPriceType());
182182
}
183-
if (!is_null($productLink->getPrice())) {
183+
if ($productLink->getPrice() !== null) {
184184
$selectionModel->setSelectionPriceValue($productLink->getPrice());
185185
}
186-
if (!is_null($productLink->getCanChangeQuantity())) {
186+
if ($productLink->getCanChangeQuantity() !== null) {
187187
$selectionModel->setSelectionCanChangeQty($productLink->getCanChangeQuantity());
188188
}
189-
if (!is_null($productLink->getIsDefault())) {
189+
if ($productLink->getIsDefault() !== null) {
190190
$selectionModel->setIsDefault($productLink->getIsDefault());
191191
}
192192

app/code/Magento/Bundle/Model/Plugin/BundleSaveOptions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class BundleSaveOptions
2121

2222
/**
2323
* @param \Magento\Bundle\Api\ProductOptionRepositoryInterface $optionRepository
24+
* @param \Magento\Catalog\Api\Data\ProductInterfaceFactory $productInterfaceFactory
2425
*/
2526
public function __construct(
2627
\Magento\Bundle\Api\ProductOptionRepositoryInterface $optionRepository,

app/code/Magento/Bundle/Test/Unit/Model/Plugin/BundleLoadOptionsTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public function testAroundLoad()
8181
->willReturn([$optionMock]);
8282
$productExtensionMock = $this->getMockBuilder('\Magento\Catalog\Api\Data\ProductExtension')
8383
->disableOriginalConstructor()
84+
->setMethods(['setBundleProductOptions', 'getBundleProductOptions'])
8485
->getMock();
8586
$this->productExtensionFactory->expects($this->once())
8687
->method('create')

app/code/Magento/Bundle/Test/Unit/Model/Plugin/BundleSaveOptionsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected function setUp()
7575
);
7676
$this->productExtensionMock = $this->getMock(
7777
'Magento\Catalog\Api\Data\ProductExtension',
78-
['getBundleProductOptions'],
78+
['getBundleProductOptions', 'setBundleProductOptions'],
7979
[],
8080
'',
8181
false
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright © 2015 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\Catalog\Model\Plugin\ProductRepository;
6+
namespace Magento\Catalog\Test\Unit\Model\Plugin\ProductRepository;
77

88
class TransactionWrapperTest extends \PHPUnit_Framework_TestCase
99
{

dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductLinkManagementTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,6 @@ protected function getChildren($productSku)
159159
'operation' => self::SERVICE_NAME . 'getChildren',
160160
],
161161
];
162-
return $this->_webApiCall($serviceInfo, ['productId' => $productSku]);
162+
return $this->_webApiCall($serviceInfo, ['productSku' => $productSku]);
163163
}
164164
}

dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductServiceTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ public function testUpdateBundleAddSelection()
208208
$bundleProductOptions[0]['product_links'][] = [
209209
'sku' => 'simple2',
210210
'qty' => 2,
211+
"price" => 20,
212+
"price_type" => 1,
213+
"is_default" => false,
211214
];
212215
$this->setBundleProductOptions($bundleProduct, $bundleProductOptions);
213216
$updatedProduct = $this->saveProduct($bundleProduct);
@@ -242,6 +245,9 @@ public function testUpdateBundleAddAndDeleteOption()
242245
[
243246
'sku' => 'simple2',
244247
'qty' => 2,
248+
"price" => 20,
249+
"price_type" => 1,
250+
"is_default" => false,
245251
],
246252
],
247253
];
@@ -302,6 +308,9 @@ protected function createDynamicBundleProduct()
302308
[
303309
"sku" => 'simple',
304310
"qty" => 1,
311+
"is_default" => true,
312+
"price" => 10,
313+
"price_type" => 1,
305314
],
306315
],
307316
],
@@ -363,6 +372,7 @@ protected function createFixedPriceBundleProduct()
363372
"qty" => 1,
364373
"price" => 20,
365374
"price_type" => 1,
375+
"is_default" => true,
366376
],
367377
],
368378
],
@@ -479,10 +489,10 @@ protected function deleteProductBySku($productSku)
479489
'soap' => [
480490
'service' => self::SERVICE_NAME,
481491
'serviceVersion' => self::SERVICE_VERSION,
482-
'operation' => self::SERVICE_NAME . 'Save',
492+
'operation' => self::SERVICE_NAME . 'deleteById',
483493
],
484494
];
485-
$requestData = [];
495+
$requestData = ["sku" => $productSku];
486496
$response = $this->_webApiCall($serviceInfo, $requestData);
487497
return $response;
488498
}

0 commit comments

Comments
 (0)