Skip to content

Commit

Permalink
Merge pull request #499 from magento-fearless-kiwis/MAGETWO-59676
Browse files Browse the repository at this point in the history
Sync 2.0.11 with 2.0-develop
  • Loading branch information
Oleksii Korshenko authored Oct 12, 2016
2 parents 60fcebc + d964cf2 commit c2a58bc
Show file tree
Hide file tree
Showing 213 changed files with 7,847 additions and 1,331 deletions.
6 changes: 1 addition & 5 deletions app/code/Magento/Backend/Block/Store/Switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,7 @@ public function getWebsites()
{
$websites = $this->_storeManager->getWebsites();
if ($websiteIds = $this->getWebsiteIds()) {
foreach (array_keys($websites) as $websiteId) {
if (!in_array($websiteId, $websiteIds)) {
unset($websites[$websiteId]);
}
}
$websites = array_intersect_key($websites, array_flip($websiteIds));
}
return $websites;
}
Expand Down
6 changes: 1 addition & 5 deletions app/code/Magento/Backend/Model/Auth/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,10 @@ public function isLoggedIn()
*/
public function prolong()
{
$lifetime = $this->_config->getValue(self::XML_PATH_SESSION_LIFETIME);
$currentTime = time();

$this->setUpdatedAt($currentTime);
$cookieValue = $this->cookieManager->getCookie($this->getName());
if ($cookieValue) {
$this->setUpdatedAt(time());
$cookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata()
->setDuration($lifetime)
->setPath($this->sessionConfig->getCookiePath())
->setDomain($this->sessionConfig->getCookieDomain())
->setSecure($this->sessionConfig->getCookieSecure())
Expand Down
53 changes: 53 additions & 0 deletions app/code/Magento/Backend/Test/Unit/Block/Store/SwitcherTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Backend\Test\Unit\Block\Store;

class SwitcherTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Magento\Backend\Block\Store\Switcher
*/
private $switcherBlock;

private $storeManagerMock;

protected function setUp()
{
$this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class);
$objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$context = $objectHelper->getObject(
\Magento\Backend\Block\Template\Context::class,
[
'storeManager' => $this->storeManagerMock,
]
);

$this->switcherBlock = $objectHelper->getObject(
\Magento\Backend\Block\Store\Switcher::class,
['context' => $context]
);
}

public function testGetWebsites()
{
$websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false);
$websites = [0 => $websiteMock, 1 => $websiteMock];
$this->storeManagerMock->expects($this->once())->method('getWebsites')->will($this->returnValue($websites));
$this->assertEquals($websites, $this->switcherBlock->getWebsites());
}

public function testGetWebsitesIfSetWebsiteIds()
{
$websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false);
$websites = [0 => $websiteMock, 1 => $websiteMock];
$this->storeManagerMock->expects($this->once())->method('getWebsites')->will($this->returnValue($websites));

$this->switcherBlock->setWebsiteIds([1]);
$expected = [1 => $websiteMock];
$this->assertEquals($expected, $this->switcherBlock->getWebsites());
}
}
15 changes: 0 additions & 15 deletions app/code/Magento/Backend/Test/Unit/Model/Auth/SessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,11 @@ public function testProlong()
{
$name = session_name();
$cookie = 'cookie';
$lifetime = 900;
$path = '/';
$domain = 'magento2';
$secure = true;
$httpOnly = true;

$cookieMetadata = $this->getMock('Magento\Framework\Stdlib\Cookie\PublicCookieMetadata');
$cookieMetadata->expects($this->once())
->method('setDuration')
->with($lifetime)
->will($this->returnSelf());
$cookieMetadata->expects($this->once())
->method('setPath')
->with($path)
Expand All @@ -191,23 +185,16 @@ public function testProlong()
->method('setHttpOnly')
->with($httpOnly)
->will($this->returnSelf());

$this->cookieMetadataFactory->expects($this->once())
->method('createPublicCookieMetadata')
->will($this->returnValue($cookieMetadata));

$this->cookieManager->expects($this->once())
->method('getCookie')
->with($name)
->will($this->returnValue($cookie));
$this->cookieManager->expects($this->once())
->method('setPublicCookie')
->with($name, $cookie, $cookieMetadata);

$this->config->expects($this->once())
->method('getValue')
->with(\Magento\Backend\Model\Auth\Session::XML_PATH_SESSION_LIFETIME)
->will($this->returnValue($lifetime));
$this->sessionConfig->expects($this->once())
->method('getCookiePath')
->will($this->returnValue($path));
Expand All @@ -220,9 +207,7 @@ public function testProlong()
$this->sessionConfig->expects($this->once())
->method('getCookieHttpOnly')
->will($this->returnValue($httpOnly));

$this->session->prolong();

$this->assertLessThanOrEqual(time(), $this->session->getUpdatedAt());
}

Expand Down
12 changes: 6 additions & 6 deletions app/code/Magento/Bundle/Model/Product/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,12 @@ protected function _prepareProduct(\Magento\Framework\DataObject $buyRequest, $p
if (!empty($selectionIds)) {
$selections = $this->getSelectionsByIds($selectionIds, $product);

if (count($selections->getItems()) !== count($selectionIds)) {
throw new \Magento\Framework\Exception\LocalizedException(
__('The options you selected are not available.')
);
}

// Check if added selections are still on sale
$this->checkSelectionsIsSale(
$selections,
Expand Down Expand Up @@ -888,12 +894,6 @@ public function getSelectionsByIds($selectionIds, $product)
->addFilterByRequiredOptions()
->setSelectionIdsFilter($selectionIds);

if (count($usedSelections->getItems()) !== count($selectionIds)) {
throw new \Magento\Framework\Exception\LocalizedException(
__('The options you selected are not available.')
);
}

if (!$this->_catalogData->isPriceGlobal() && $storeId) {
$websiteId = $this->_storeManager->getStore($storeId)
->getWebsiteId();
Expand Down
Loading

0 comments on commit c2a58bc

Please sign in to comment.