Skip to content

Commit c2a58bc

Browse files
author
Oleksii Korshenko
authored
Merge pull request #499 from magento-fearless-kiwis/MAGETWO-59676
Sync 2.0.11 with 2.0-develop
2 parents 60fcebc + d964cf2 commit c2a58bc

File tree

213 files changed

+7847
-1331
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

213 files changed

+7847
-1331
lines changed

app/code/Magento/Backend/Block/Store/Switcher.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,7 @@ public function getWebsites()
155155
{
156156
$websites = $this->_storeManager->getWebsites();
157157
if ($websiteIds = $this->getWebsiteIds()) {
158-
foreach (array_keys($websites) as $websiteId) {
159-
if (!in_array($websiteId, $websiteIds)) {
160-
unset($websites[$websiteId]);
161-
}
162-
}
158+
$websites = array_intersect_key($websites, array_flip($websiteIds));
163159
}
164160
return $websites;
165161
}

app/code/Magento/Backend/Model/Auth/Session.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,10 @@ public function isLoggedIn()
177177
*/
178178
public function prolong()
179179
{
180-
$lifetime = $this->_config->getValue(self::XML_PATH_SESSION_LIFETIME);
181-
$currentTime = time();
182-
183-
$this->setUpdatedAt($currentTime);
184180
$cookieValue = $this->cookieManager->getCookie($this->getName());
185181
if ($cookieValue) {
182+
$this->setUpdatedAt(time());
186183
$cookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata()
187-
->setDuration($lifetime)
188184
->setPath($this->sessionConfig->getCookiePath())
189185
->setDomain($this->sessionConfig->getCookieDomain())
190186
->setSecure($this->sessionConfig->getCookieSecure())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Test\Unit\Block\Store;
8+
9+
class SwitcherTest extends \PHPUnit_Framework_TestCase
10+
{
11+
/**
12+
* @var \Magento\Backend\Block\Store\Switcher
13+
*/
14+
private $switcherBlock;
15+
16+
private $storeManagerMock;
17+
18+
protected function setUp()
19+
{
20+
$this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class);
21+
$objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
22+
$context = $objectHelper->getObject(
23+
\Magento\Backend\Block\Template\Context::class,
24+
[
25+
'storeManager' => $this->storeManagerMock,
26+
]
27+
);
28+
29+
$this->switcherBlock = $objectHelper->getObject(
30+
\Magento\Backend\Block\Store\Switcher::class,
31+
['context' => $context]
32+
);
33+
}
34+
35+
public function testGetWebsites()
36+
{
37+
$websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false);
38+
$websites = [0 => $websiteMock, 1 => $websiteMock];
39+
$this->storeManagerMock->expects($this->once())->method('getWebsites')->will($this->returnValue($websites));
40+
$this->assertEquals($websites, $this->switcherBlock->getWebsites());
41+
}
42+
43+
public function testGetWebsitesIfSetWebsiteIds()
44+
{
45+
$websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false);
46+
$websites = [0 => $websiteMock, 1 => $websiteMock];
47+
$this->storeManagerMock->expects($this->once())->method('getWebsites')->will($this->returnValue($websites));
48+
49+
$this->switcherBlock->setWebsiteIds([1]);
50+
$expected = [1 => $websiteMock];
51+
$this->assertEquals($expected, $this->switcherBlock->getWebsites());
52+
}
53+
}

app/code/Magento/Backend/Test/Unit/Model/Auth/SessionTest.php

-15
Original file line numberDiff line numberDiff line change
@@ -164,17 +164,11 @@ public function testProlong()
164164
{
165165
$name = session_name();
166166
$cookie = 'cookie';
167-
$lifetime = 900;
168167
$path = '/';
169168
$domain = 'magento2';
170169
$secure = true;
171170
$httpOnly = true;
172-
173171
$cookieMetadata = $this->getMock('Magento\Framework\Stdlib\Cookie\PublicCookieMetadata');
174-
$cookieMetadata->expects($this->once())
175-
->method('setDuration')
176-
->with($lifetime)
177-
->will($this->returnSelf());
178172
$cookieMetadata->expects($this->once())
179173
->method('setPath')
180174
->with($path)
@@ -191,23 +185,16 @@ public function testProlong()
191185
->method('setHttpOnly')
192186
->with($httpOnly)
193187
->will($this->returnSelf());
194-
195188
$this->cookieMetadataFactory->expects($this->once())
196189
->method('createPublicCookieMetadata')
197190
->will($this->returnValue($cookieMetadata));
198-
199191
$this->cookieManager->expects($this->once())
200192
->method('getCookie')
201193
->with($name)
202194
->will($this->returnValue($cookie));
203195
$this->cookieManager->expects($this->once())
204196
->method('setPublicCookie')
205197
->with($name, $cookie, $cookieMetadata);
206-
207-
$this->config->expects($this->once())
208-
->method('getValue')
209-
->with(\Magento\Backend\Model\Auth\Session::XML_PATH_SESSION_LIFETIME)
210-
->will($this->returnValue($lifetime));
211198
$this->sessionConfig->expects($this->once())
212199
->method('getCookiePath')
213200
->will($this->returnValue($path));
@@ -220,9 +207,7 @@ public function testProlong()
220207
$this->sessionConfig->expects($this->once())
221208
->method('getCookieHttpOnly')
222209
->will($this->returnValue($httpOnly));
223-
224210
$this->session->prolong();
225-
226211
$this->assertLessThanOrEqual(time(), $this->session->getUpdatedAt());
227212
}
228213

app/code/Magento/Bundle/Model/Product/Type.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,12 @@ protected function _prepareProduct(\Magento\Framework\DataObject $buyRequest, $p
716716
if (!empty($selectionIds)) {
717717
$selections = $this->getSelectionsByIds($selectionIds, $product);
718718

719+
if (count($selections->getItems()) !== count($selectionIds)) {
720+
throw new \Magento\Framework\Exception\LocalizedException(
721+
__('The options you selected are not available.')
722+
);
723+
}
724+
719725
// Check if added selections are still on sale
720726
$this->checkSelectionsIsSale(
721727
$selections,
@@ -888,12 +894,6 @@ public function getSelectionsByIds($selectionIds, $product)
888894
->addFilterByRequiredOptions()
889895
->setSelectionIdsFilter($selectionIds);
890896

891-
if (count($usedSelections->getItems()) !== count($selectionIds)) {
892-
throw new \Magento\Framework\Exception\LocalizedException(
893-
__('The options you selected are not available.')
894-
);
895-
}
896-
897897
if (!$this->_catalogData->isPriceGlobal() && $storeId) {
898898
$websiteId = $this->_storeManager->getStore($storeId)
899899
->getWebsiteId();

0 commit comments

Comments
 (0)