Skip to content

Commit

Permalink
#10789: Merge branch 'develop' of github.com:magento/magento2 into ne…
Browse files Browse the repository at this point in the history
…tzkollektiv-develop
  • Loading branch information
ishakhsuvarov committed Sep 14, 2017
2 parents 4687f71 + 53072e0 commit 815be57
Show file tree
Hide file tree
Showing 103 changed files with 2,355 additions and 285 deletions.
2 changes: 2 additions & 0 deletions .github/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Order deny,allow
Deny from all
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,6 @@
order allow,deny
deny from all
</Files>
<Files CONTRIBUTING.md>
order allow,deny
deny from all
</Files>
<Files COPYING.txt>
order allow,deny
deny from all
Expand Down
4 changes: 0 additions & 4 deletions .htaccess.sample
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,6 @@
order allow,deny
deny from all
</Files>
<Files CONTRIBUTING.md>
order allow,deny
deny from all
</Files>
<Files COPYING.txt>
order allow,deny
deny from all
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ cache:
- $HOME/node_modules
- $HOME/yarn.lock
before_install: ./dev/travis/before_install.sh
install: composer install --no-interaction --prefer-dist
install: composer install --no-interaction
before_script: ./dev/travis/before_script.sh
script:
# Set arguments for variants of phpunit based tests; '|| true' prevents failing script when leading test fails
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function getDefaultValues()
*/
protected function _getSelectedOptions()
{
if (is_null($this->_selectedOptions)) {
if ($this->_selectedOptions === null) {
$this->_selectedOptions = [];

/** @var \Magento\Bundle\Model\Option $option */
Expand All @@ -152,17 +152,29 @@ protected function _getSelectedOptions()
$selectionId = $this->getProduct()->getPreconfiguredValues()->getData(
'bundle_option/' . $option->getId()
);
if ($selectionId && $option->getSelectionById($selectionId)) {
$this->_selectedOptions = $selectionId;
} elseif (!$option->getRequired()) {
$this->_selectedOptions = 'None';
}
$this->assignSelection($option, $selectionId);
}
}

return $this->_selectedOptions;
}

/**
* Set selected options.
*
* @param \Magento\Bundle\Model\Option $option
* @param mixed $selectionId
* @return void
*/
protected function assignSelection(\Magento\Bundle\Model\Option $option, $selectionId)
{
if ($selectionId && $option->getSelectionById($selectionId)) {
$this->_selectedOptions = $selectionId;
} elseif (!$option->getRequired()) {
$this->_selectedOptions = 'None';
}
}

/**
* Define if selection is selected
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,20 @@ class Multi extends \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Optio
* @var string
*/
protected $_template = 'catalog/product/view/type/bundle/option/multi.phtml';

/**
* @inheritdoc
*/
protected function assignSelection(\Magento\Bundle\Model\Option $option, $selectionId)
{
if (is_array($selectionId)) {
foreach ($selectionId as $id) {
if ($id && $option->getSelectionById($id)) {
$this->_selectedOptions[] = $id;
}
}
} else {
parent::assignSelection($option, $selectionId);
}
}
}
4 changes: 2 additions & 2 deletions app/code/Magento/Bundle/Model/Product/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ protected function _prepareProduct(\Magento\Framework\DataObject $buyRequest, $p
$options
);

$optionsCollection->appendSelections($selections, false, $_appendAllSelections);
$optionsCollection->appendSelections($selections, true, $_appendAllSelections);

$selections = $selections->getItems();
} else {
Expand All @@ -704,7 +704,7 @@ protected function _prepareProduct(\Magento\Framework\DataObject $buyRequest, $p
->getOptionsIds($product);
$selectionCollection = $product->getTypeInstance()
->getSelectionsCollection($optionIds, $product);
$options = $optionCollection->appendSelections($selectionCollection, false, $_appendAllSelections);
$options = $optionCollection->appendSelections($selectionCollection, true, $_appendAllSelections);

$selections = $this->mergeSelectionsWithOptions($options, $selections);
}
Expand Down
13 changes: 9 additions & 4 deletions app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ public function testPrepareForCartAdvancedWithoutOptions()
->willReturn($productType);
$optionCollection->expects($this->any())
->method('appendSelections')
->with($selectionCollection, true, true)
->willReturn([$option]);
$productType->expects($this->once())
->method('setStoreFilter');
Expand Down Expand Up @@ -433,7 +434,8 @@ function ($key) use ($optionCollection, $selectionCollection) {
->method('getItemById')
->willReturn($option);
$optionCollection->expects($this->once())
->method('appendSelections');
->method('appendSelections')
->with($selectionCollection, true, true);
$productType->expects($this->once())
->method('setStoreFilter');
$buyRequest->expects($this->once())
Expand Down Expand Up @@ -668,7 +670,8 @@ function ($key) use ($optionCollection, $selectionCollection) {
->method('getItemById')
->willReturn($option);
$optionCollection->expects($this->once())
->method('appendSelections');
->method('appendSelections')
->with($selectionCollection, true, true);
$productType->expects($this->once())
->method('setStoreFilter');
$buyRequest->expects($this->once())
Expand Down Expand Up @@ -891,7 +894,8 @@ function ($key) use ($optionCollection, $selectionCollection) {
->method('getItemById')
->willReturn($option);
$optionCollection->expects($this->once())
->method('appendSelections');
->method('appendSelections')
->with($selectionCollection, true, true);
$productType->expects($this->once())
->method('setStoreFilter');
$buyRequest->expects($this->once())
Expand Down Expand Up @@ -1169,7 +1173,8 @@ function ($key) use ($optionCollection, $selectionCollection) {
}
);
$optionCollection->expects($this->once())
->method('appendSelections');
->method('appendSelections')
->with($selectionCollection, true, true);
$productType->expects($this->once())
->method('setStoreFilter');
$buyRequest->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
<?php
$product = $block->getProduct();
$helper = $this->helper('Magento\Catalog\Helper\Output');
$stripSelection = $product->getConfigureMode() ? true : false;
$options = $block->decorateArray($block->getOptions($stripSelection));
?>
<?php $options = $block->decorateArray($block->getOptions()); ?>
<?php if ($product->isSaleable()):?>
<?php if (count($options)): ?>
<script type="text/x-magento-init">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ public function getProductAttributeValue($product, $attribute)
['select', 'boolean', 'multiselect']
)
) {
//$value = $attribute->getSource()->getOptionText($product->getData($attribute->getAttributeCode()));
$value = $attribute->getFrontend()->getValue($product);
} else {
$value = $product->getData($attribute->getAttributeCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ public function __construct(
*/
public function execute()
{
$response = new \Magento\Framework\DataObject();
$response->setError(0);

$resultJson = $this->resultJsonFactory->create();
$resultJson->setData($response);
$resultJson->setData(['error' => 0]);

return $resultJson;
}
Expand Down
15 changes: 13 additions & 2 deletions app/code/Magento/Catalog/Pricing/Price/TierPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Magento\Framework\Pricing\Price\AbstractPrice;
use Magento\Framework\Pricing\Price\BasePriceProviderInterface;
use Magento\Framework\Pricing\PriceInfoInterface;
use Magento\Customer\Model\Group\RetrieverInterface as CustomerGroupRetrieverInterface;

/**
* @api
Expand All @@ -30,6 +31,7 @@ class TierPrice extends AbstractPrice implements TierPriceInterface, BasePricePr

/**
* @var Session
* @deprecated
*/
protected $customerSession;

Expand Down Expand Up @@ -57,30 +59,39 @@ class TierPrice extends AbstractPrice implements TierPriceInterface, BasePricePr
*/
protected $groupManagement;

/**
* @var CustomerGroupRetrieverInterface
*/
private $customerGroupRetriever;

/**
* @param Product $saleableItem
* @param float $quantity
* @param CalculatorInterface $calculator
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
* @param Session $customerSession
* @param GroupManagementInterface $groupManagement
* @param CustomerGroupRetrieverInterface|null $customerGroupRetriever
*/
public function __construct(
Product $saleableItem,
$quantity,
CalculatorInterface $calculator,
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
Session $customerSession,
GroupManagementInterface $groupManagement
GroupManagementInterface $groupManagement,
CustomerGroupRetrieverInterface $customerGroupRetriever = null
) {
$quantity = floatval($quantity) ? $quantity : 1;
parent::__construct($saleableItem, $quantity, $calculator, $priceCurrency);
$this->customerSession = $customerSession;
$this->groupManagement = $groupManagement;
$this->customerGroupRetriever = $customerGroupRetriever
?? \Magento\Framework\App\ObjectManager::getInstance()->get(CustomerGroupRetrieverInterface::class);
if ($saleableItem->hasCustomerGroupId()) {
$this->customerGroup = (int) $saleableItem->getCustomerGroupId();
} else {
$this->customerGroup = (int) $this->customerSession->getCustomerGroupId();
$this->customerGroup = (int) $this->customerGroupRetriever->getCustomerGroupId();
}
}

Expand Down
34 changes: 21 additions & 13 deletions app/code/Magento/Catalog/Test/Unit/Pricing/Price/TierPriceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,52 @@ class TierPriceTest extends \PHPUnit\Framework\TestCase
*
* @var int
*/
protected $customerGroup = Group::NOT_LOGGED_IN_ID;
private $customerGroup = Group::NOT_LOGGED_IN_ID;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $priceInfo;
private $priceInfo;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $product;
private $product;

/**
* @var float
*/
protected $quantity = 3.;
private $quantity = 3.;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $calculator;
private $calculator;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $session;
private $session;

/**
* @var TierPrice
*/
protected $model;
private $model;

/**
* @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $priceCurrencyMock;
private $priceCurrencyMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $groupManagement;
private $groupManagement;

/**
* @var \Magento\Customer\Model\Group\RetrieverInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $customerGroupRetriever;

/**
* Initialize base dependencies
Expand All @@ -76,11 +81,12 @@ protected function setUp()

$this->product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getPriceInfo', 'hasCustomerGroupId', 'getCustomerGroupId', 'getResource', '__wakeup']);
$this->product->expects($this->any())->method('getPriceInfo')->will($this->returnValue($this->priceInfo));

$this->customerGroupRetriever = $this->getMockBuilder(\Magento\Customer\Model\Group\RetrieverInterface::class)
->disableOriginalConstructor()->getMock();
$this->session = $this->createMock(\Magento\Customer\Model\Session::class);
$this->session->expects($this->any())->method('getCustomerGroupId')
->will($this->returnValue($this->customerGroup));

$this->customerGroupRetriever = $this->createMock(\Magento\Customer\Model\Group\RetrieverInterface::class);
$this->calculator = $this->createMock(\Magento\Framework\Pricing\Adjustment\Calculator::class);
$this->groupManagement = $this->createMock(\Magento\Customer\Api\GroupManagementInterface::class);

Expand All @@ -92,7 +98,8 @@ protected function setUp()
$this->calculator,
$this->priceCurrencyMock,
$this->session,
$this->groupManagement
$this->groupManagement,
$this->customerGroupRetriever
);
}

Expand Down Expand Up @@ -218,7 +225,8 @@ public function testGetterStoredTierPrices()
$this->calculator,
$this->priceCurrencyMock,
$this->session,
$this->groupManagement
$this->groupManagement,
$this->customerGroupRetriever
);
$group = $this->createMock(\Magento\Customer\Model\Data\Group::class);
$group->expects($this->once())->method('getId')->willReturn(GroupManagement::CUST_GROUP_ALL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if ($_attributeType && $_attributeType == 'text') {

<?php if ($_attributeValue): ?>
<div class="product attribute <?= /* @escapeNotVerified */ $_className ?>">
<?php if ($_attributeLabel != 'none'): ?><strong class="type"><?= /* @escapeNotVerified */ $_attributeLabel ?></strong><?php endif; ?>
<?php if ($_attributeLabel != __('none')): ?><strong class="type"><?= /* @escapeNotVerified */ $_attributeLabel ?></strong><?php endif; ?>
<div class="value" <?= /* @escapeNotVerified */ $_attributeAddAttribute ?>><?= /* @escapeNotVerified */ $_attributeValue ?></div>
</div>
<?php endif; ?>
Loading

0 comments on commit 815be57

Please sign in to comment.