Skip to content

Commit a1ee98a

Browse files
Merge pull request #1825 from magento-engcom/2.2-develop-prs
[EngCom] Public Pull Requests - 2.2-develop - MAGETWO-85332: Fix error loading theme configuration on PHP 7.2 #12606 - MAGETWO-85307: 12468: Sort by Price not working on CatalogSearch Page in Magento 2 #929 - MAGETWO-85303: #12582: Can't remove item description from wishlist #981 - MAGETWO-85297: 8410: Custom Checkout Step and Shipping Step are Highlighted and Combined upon Checkout page load #975 - MAGETWO-85290: 7467: File Put Contents file with empty content. #962
2 parents 35f404b + 9447e45 commit a1ee98a

File tree

7 files changed

+209
-8
lines changed

7 files changed

+209
-8
lines changed

app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ public function getWidgetOptionsJson(array $customOptions = [])
689689
'limit' => ToolbarModel::LIMIT_PARAM_NAME,
690690
'modeDefault' => $defaultMode,
691691
'directionDefault' => $this->_direction ?: ProductList::DEFAULT_SORT_DIRECTION,
692-
'orderDefault' => $this->_productListHelper->getDefaultSortField(),
692+
'orderDefault' => $this->getOrderField(),
693693
'limitDefault' => $this->_productListHelper->getDefaultLimitPerPageValue($defaultMode),
694694
'url' => $this->getPagerUrl(),
695695
];

app/code/Magento/Checkout/view/frontend/web/js/model/step-navigator.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ define([
6666
* @param {*} sortOrder
6767
*/
6868
registerStep: function (code, alias, title, isVisible, navigate, sortOrder) {
69-
var hash;
69+
var hash, active;
7070

7171
if ($.inArray(code, this.validCodes) !== -1) {
7272
throw new DOMException('Step code [' + code + '] already registered in step navigator');
@@ -87,6 +87,12 @@ define([
8787
navigate: navigate,
8888
sortOrder: sortOrder
8989
});
90+
active = this.getActiveItemIndex();
91+
steps.each(function (elem, index) {
92+
if (active !== index) {
93+
elem.isVisible(false);
94+
}
95+
});
9096
this.stepCodes.push(code);
9197
hash = window.location.hash.replace('#', '');
9298

@@ -111,10 +117,14 @@ define([
111117
getActiveItemIndex: function () {
112118
var activeIndex = 0;
113119

114-
steps.sort(this.sortItems).forEach(function (element, index) {
120+
steps.sort(this.sortItems).some(function (element, index) {
115121
if (element.isVisible()) {
116122
activeIndex = index;
123+
124+
return true;
117125
}
126+
127+
return false;
118128
});
119129

120130
return activeIndex;

app/code/Magento/Wishlist/Controller/Index/Update.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ public function execute()
8383
)->defaultCommentString()
8484
) {
8585
$description = '';
86-
} elseif (!strlen($description)) {
87-
$description = $item->getDescription();
8886
}
8987

9088
$qty = null;

dev/tests/integration/testsuite/Magento/Framework/Filesystem/Driver/FileTest.php

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
*/
88
namespace Magento\Framework\Filesystem\Driver;
99

10-
use Magento\Framework\Filesystem\DriverInterface;
10+
use Magento\Framework\App\Filesystem\DirectoryList;
11+
use Magento\Framework\Filesystem;
12+
use Magento\Framework\Filesystem\Directory\WriteInterface;
13+
use Magento\TestFramework\Helper\Bootstrap;
1114

1215
class FileTest extends \PHPUnit\Framework\TestCase
1316
{
@@ -80,4 +83,44 @@ public function testCreateDirectory()
8083
$this->assertTrue($this->driver->createDirectory($generatedPath));
8184
$this->assertTrue(is_dir($generatedPath));
8285
}
86+
87+
/**
88+
* Check, driver can create file with content or without one.
89+
*
90+
* @dataProvider createFileDataProvider
91+
* @param int $result
92+
* @param string $fileName
93+
* @param string $fileContent
94+
* @return void
95+
* @throws \Magento\Framework\Exception\FileSystemException
96+
*/
97+
public function testCreateFile(int $result, string $fileName, string $fileContent)
98+
{
99+
/** @var WriteInterface $directory */
100+
$directory = Bootstrap::getObjectManager()->get(Filesystem::class)->getDirectoryWrite(DirectoryList::VAR_DIR);
101+
$filePath = $directory->getAbsolutePath() . '/' . $fileName;
102+
$this->assertSame($result, $this->driver->filePutContents($filePath, $fileContent));
103+
$this->assertTrue($this->driver->deleteFile($filePath));
104+
}
105+
106+
/**
107+
* Provides test data for testCreateFile().
108+
*
109+
* @return array
110+
*/
111+
public function createFileDataProvider()
112+
{
113+
return [
114+
'file_with_content' => [
115+
'result' => 11,
116+
'fileName' => 'test.txt',
117+
'fileContent' => 'testContent',
118+
],
119+
'empty_file' => [
120+
'result' => 0,
121+
'filePath' => 'test.txt',
122+
'fileContent' => '',
123+
]
124+
];
125+
}
83126
}
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Wishlist\Controller;
8+
9+
use Magento\Customer\Api\AccountManagementInterface;
10+
use Magento\Customer\Helper\View;
11+
use Magento\Customer\Model\Customer;
12+
use Magento\Customer\Model\Session;
13+
use Magento\Framework\Data\Form\FormKey;
14+
use Magento\Framework\Message\ManagerInterface;
15+
use Magento\Wishlist\Model\Item;
16+
use Magento\Wishlist\Model\Wishlist;
17+
use Psr\Log\LoggerInterface;
18+
use Zend\Http\Request;
19+
20+
/**
21+
* Tests updating wishlist item comment.
22+
*
23+
* @magentoAppIsolation enabled
24+
* @magentoDbIsolation enabled
25+
* @magentoAppArea frontend
26+
*/
27+
class UpdateTest extends \Magento\TestFramework\TestCase\AbstractController
28+
{
29+
/**
30+
* @var Session
31+
*/
32+
private $customerSession;
33+
34+
/**
35+
* @var ManagerInterface
36+
*/
37+
private $messages;
38+
39+
/**
40+
* @var View
41+
*/
42+
private $customerViewHelper;
43+
44+
/**
45+
* Description field value for wishlist item.
46+
*
47+
* @var string
48+
*/
49+
private $description = 'some description';
50+
51+
/**
52+
* Tests updating wishlist item comment.
53+
*
54+
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
55+
* @dataProvider commentDataProvider
56+
* @param string|null $postDescription
57+
* @param string $expectedResult
58+
* @param boolean $presetComment
59+
*/
60+
public function testUpdateComment($postDescription, $expectedResult, $presetComment)
61+
{
62+
/** @var Customer $customer */
63+
$customer = $this->customerSession->getCustomer();
64+
/** @var Wishlist $wishlist */
65+
$wishlist = $this->_objectManager
66+
->get(Wishlist::class)
67+
->loadByCustomerId($customer->getId(), true);
68+
/** @var Item $item */
69+
$item = $wishlist->getItemCollection()->getFirstItem();
70+
71+
if ($presetComment) {
72+
$item->setDescription($this->description);
73+
$item->save();
74+
}
75+
76+
$formKey = $this->_objectManager->get(FormKey::class);
77+
$this->getRequest()->setPostValue(
78+
[
79+
'description' => isset($postDescription) ? [$item->getId() => $postDescription] : [],
80+
'qty' => isset($postDescription) ? [$item->getId() => 1] : [],
81+
'do' => '',
82+
'form_key' => $formKey->getFormKey()
83+
]
84+
)->setMethod(Request::METHOD_POST);
85+
$this->dispatch('wishlist/index/update/wishlist_id/' . $wishlist->getId());
86+
87+
// Reload item
88+
$item = $this->_objectManager->get(Item::class)->load($item->getId());
89+
self::assertEquals(
90+
$expectedResult,
91+
$item->getDescription()
92+
);
93+
}
94+
95+
/**
96+
* Data provider for testUpdateComment.
97+
*
98+
* @return array
99+
*/
100+
public function commentDataProvider()
101+
{
102+
103+
return [
104+
'test adding comment' => [
105+
'postDescription' => $this->description,
106+
'expectedResult' => $this->description,
107+
'presetComment' => false
108+
],
109+
'test removing comment' => [
110+
'postDescription' => '',
111+
'expectedResult' => '',
112+
'presetComment' => true
113+
],
114+
'test not changing comment' => [
115+
'postDescription' => null,
116+
'expectedResult' => $this->description,
117+
'presetComment' => true
118+
],
119+
];
120+
}
121+
122+
protected function setUp()
123+
{
124+
parent::setUp();
125+
$logger = $this->createMock(LoggerInterface::class);
126+
$this->customerSession = $this->_objectManager->get(
127+
Session::class,
128+
[$logger]
129+
);
130+
/** @var AccountManagementInterface $service */
131+
$service = $this->_objectManager->create(
132+
AccountManagementInterface::class
133+
);
134+
$customer = $service->authenticate('[email protected]', 'password');
135+
$this->customerSession->setCustomerDataAsLoggedIn($customer);
136+
137+
$this->customerViewHelper = $this->_objectManager->create(View::class);
138+
139+
$this->messages = $this->_objectManager->get(
140+
ManagerInterface::class
141+
);
142+
}
143+
144+
protected function tearDown()
145+
{
146+
$this->customerSession->logout();
147+
$this->customerSession = null;
148+
parent::tearDown();
149+
}
150+
}

lib/internal/Magento/Framework/Filesystem/Driver/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ public function touch($path, $modificationTime = null)
528528
public function filePutContents($path, $content, $mode = null)
529529
{
530530
$result = @file_put_contents($this->getScheme() . $path, $content, $mode);
531-
if (!$result) {
531+
if ($result === false) {
532532
throw new FileSystemException(
533533
new \Magento\Framework\Phrase(
534534
'The specified "%1" file could not be written %2',

lib/internal/Magento/Framework/View/Design/Theme/ThemeList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ protected function _prepareConfigurationData($themePackage)
234234
$media = $themeConfig->getMedia();
235235

236236
$parentPathPieces = $themeConfig->getParentTheme();
237-
if (count($parentPathPieces) == 1) {
237+
if (is_array($parentPathPieces) && count($parentPathPieces) == 1) {
238238
$pathPieces = $pathData['theme_path_pieces'];
239239
array_pop($pathPieces);
240240
$parentPathPieces = array_merge($pathPieces, $parentPathPieces);

0 commit comments

Comments
 (0)