Skip to content

Commit

Permalink
Fixes for failed static tests in Bundle module.
Browse files Browse the repository at this point in the history
  • Loading branch information
rain2o committed Mar 18, 2020
1 parent 49c261e commit 659beb2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
24 changes: 19 additions & 5 deletions app/code/Magento/Bundle/Model/LinkManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ class LinkManagement implements \Magento\Bundle\Api\ProductLinkManagementInterfa
*/
private $metadataPool;

/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
private $storeManager;

/**
* @param ProductRepositoryInterface $productRepository
* @param \Magento\Bundle\Api\Data\LinkInterfaceFactory $linkFactory
Expand Down Expand Up @@ -82,7 +87,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getChildren($productSku, $optionId = null)
{
Expand All @@ -105,7 +110,7 @@ public function getChildren($productSku, $optionId = null)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function addChildByProductSku($sku, $optionId, \Magento\Bundle\Api\Data\LinkInterface $linkedProduct)
{
Expand All @@ -115,7 +120,8 @@ public function addChildByProductSku($sku, $optionId, \Magento\Bundle\Api\Data\L
}

/**
* {@inheritdoc}
* @inheritdoc
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
Expand Down Expand Up @@ -169,6 +175,8 @@ public function saveChild(
}

/**
* Map data from the product link object to the new selection model
*
* @param \Magento\Bundle\Model\Selection $selectionModel
* @param \Magento\Bundle\Api\Data\LinkInterface $productLink
* @param string $linkedProductId
Expand Down Expand Up @@ -217,7 +225,8 @@ protected function mapProductLinkToSelectionModel(
}

/**
* {@inheritdoc}
* @inheritdoc
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function addChild(
Expand Down Expand Up @@ -297,7 +306,7 @@ public function addChild(
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function removeChild($sku, $optionId, $childSku)
{
Expand Down Expand Up @@ -336,6 +345,8 @@ public function removeChild($sku, $optionId, $childSku)
}

/**
* Build new Link object from the product and selection
*
* @param \Magento\Catalog\Model\Product $selection
* @param \Magento\Catalog\Model\Product $product
* @return \Magento\Bundle\Api\Data\LinkInterface
Expand Down Expand Up @@ -367,6 +378,8 @@ private function buildLink(\Magento\Catalog\Model\Product $selection, \Magento\C
}

/**
* Retrieve bundle options with selections
*
* @param \Magento\Catalog\Api\Data\ProductInterface $product
* @return \Magento\Bundle\Api\Data\OptionInterface[]
*/
Expand All @@ -392,6 +405,7 @@ private function getOptions(\Magento\Catalog\Api\Data\ProductInterface $product)

/**
* Get MetadataPool instance
*
* @return MetadataPool
*/
private function getMetadataPool()
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Bundle/Model/Option/SaveAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function save(ProductInterface $bundleProduct, OptionInterface $option)
}
} else {
if (!$existingOption->getOptionId()) {
throw new NoSuchEntityException(
throw new \Magento\Framework\Exception\NoSuchEntityException(
__("The option that was requested doesn't exist. Verify the entity and try again.")
);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Bundle/Model/Selection.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,6 @@ public function afterSave()
$this->unsSelectionPriceType();
}
}
parent::afterSave();
return parent::afterSave();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;

/**
* Class LinkManagementTest
* Unit Test for Link Management Model
*
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Expand Down Expand Up @@ -121,7 +121,7 @@ protected function setUp()
->setMethods(['get'])
->disableOriginalConstructor()
->getMock();
$this->productType = $this->getMockBuilder(\Magento\Bundle\Model\Product\Type\Interceptor::class)
$this->productType = $this->getMockBuilder(\Magento\Bundle\Model\Product\Type::class)
->setMethods(['getOptionsCollection', 'setStoreFilter', 'getSelectionsCollection', 'getOptionsIds'])
->disableOriginalConstructor()
->getMock();
Expand Down

0 comments on commit 659beb2

Please sign in to comment.