diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php b/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php index df98969c262cea0b631504f57abd1353c4ab26d3..dfbaf3a62420ae7bd225f9d0df9e27f73f530910 100644 --- a/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php +++ b/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php @@ -689,7 +689,7 @@ class Toolbar extends \Magento\Framework\View\Element\Template 'limit' => ToolbarModel::LIMIT_PARAM_NAME, 'modeDefault' => $defaultMode, 'directionDefault' => $this->_direction ?: ProductList::DEFAULT_SORT_DIRECTION, - 'orderDefault' => $this->_productListHelper->getDefaultSortField(), + 'orderDefault' => $this->getOrderField(), 'limitDefault' => $this->_productListHelper->getDefaultLimitPerPageValue($defaultMode), 'url' => $this->getPagerUrl(), ]; diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/step-navigator.js b/app/code/Magento/Checkout/view/frontend/web/js/model/step-navigator.js index bfcd0d02585bb77a801716b1d6bc3b6c2087660f..2341748bc4e4a0b11be35cfff6a37ae7103a8752 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/step-navigator.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/step-navigator.js @@ -66,7 +66,7 @@ define([ * @param {*} sortOrder */ registerStep: function (code, alias, title, isVisible, navigate, sortOrder) { - var hash; + var hash, active; if ($.inArray(code, this.validCodes) !== -1) { throw new DOMException('Step code [' + code + '] already registered in step navigator'); @@ -87,6 +87,12 @@ define([ navigate: navigate, sortOrder: sortOrder }); + active = this.getActiveItemIndex(); + steps.each(function (elem, index) { + if (active !== index) { + elem.isVisible(false); + } + }); this.stepCodes.push(code); hash = window.location.hash.replace('#', ''); @@ -111,10 +117,14 @@ define([ getActiveItemIndex: function () { var activeIndex = 0; - steps.sort(this.sortItems).forEach(function (element, index) { + steps.sort(this.sortItems).some(function (element, index) { if (element.isVisible()) { activeIndex = index; + + return true; } + + return false; }); return activeIndex; diff --git a/app/code/Magento/Wishlist/Controller/Index/Update.php b/app/code/Magento/Wishlist/Controller/Index/Update.php index a79e4aa95ffc59a0f92a0f2d017953caf21d4312..cc3f222c83065cf0bc3e222d5fda2d3bc1026c74 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Update.php +++ b/app/code/Magento/Wishlist/Controller/Index/Update.php @@ -83,8 +83,6 @@ class Update extends \Magento\Wishlist\Controller\AbstractIndex )->defaultCommentString() ) { $description = ''; - } elseif (!strlen($description)) { - $description = $item->getDescription(); } $qty = null; diff --git a/dev/tests/integration/testsuite/Magento/Framework/Filesystem/Driver/FileTest.php b/dev/tests/integration/testsuite/Magento/Framework/Filesystem/Driver/FileTest.php index 26401c782efc4f73ba7c7b56178787e57c14a89c..b74d87fab3a84f35dcc2131523e25a812a8b06c9 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Filesystem/Driver/FileTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Filesystem/Driver/FileTest.php @@ -7,7 +7,10 @@ */ namespace Magento\Framework\Filesystem\Driver; -use Magento\Framework\Filesystem\DriverInterface; +use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Filesystem; +use Magento\Framework\Filesystem\Directory\WriteInterface; +use Magento\TestFramework\Helper\Bootstrap; class FileTest extends \PHPUnit\Framework\TestCase { @@ -80,4 +83,44 @@ class FileTest extends \PHPUnit\Framework\TestCase $this->assertTrue($this->driver->createDirectory($generatedPath)); $this->assertTrue(is_dir($generatedPath)); } + + /** + * Check, driver can create file with content or without one. + * + * @dataProvider createFileDataProvider + * @param int $result + * @param string $fileName + * @param string $fileContent + * @return void + * @throws \Magento\Framework\Exception\FileSystemException + */ + public function testCreateFile(int $result, string $fileName, string $fileContent) + { + /** @var WriteInterface $directory */ + $directory = Bootstrap::getObjectManager()->get(Filesystem::class)->getDirectoryWrite(DirectoryList::VAR_DIR); + $filePath = $directory->getAbsolutePath() . '/' . $fileName; + $this->assertSame($result, $this->driver->filePutContents($filePath, $fileContent)); + $this->assertTrue($this->driver->deleteFile($filePath)); + } + + /** + * Provides test data for testCreateFile(). + * + * @return array + */ + public function createFileDataProvider() + { + return [ + 'file_with_content' => [ + 'result' => 11, + 'fileName' => 'test.txt', + 'fileContent' => 'testContent', + ], + 'empty_file' => [ + 'result' => 0, + 'filePath' => 'test.txt', + 'fileContent' => '', + ] + ]; + } } diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/Controller/UpdateTest.php b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/UpdateTest.php new file mode 100644 index 0000000000000000000000000000000000000000..48f738763b67215fcaf3f997c9ab0f357b089f07 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/UpdateTest.php @@ -0,0 +1,150 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Wishlist\Controller; + +use Magento\Customer\Api\AccountManagementInterface; +use Magento\Customer\Helper\View; +use Magento\Customer\Model\Customer; +use Magento\Customer\Model\Session; +use Magento\Framework\Data\Form\FormKey; +use Magento\Framework\Message\ManagerInterface; +use Magento\Wishlist\Model\Item; +use Magento\Wishlist\Model\Wishlist; +use Psr\Log\LoggerInterface; +use Zend\Http\Request; + +/** + * Tests updating wishlist item comment. + * + * @magentoAppIsolation enabled + * @magentoDbIsolation enabled + * @magentoAppArea frontend + */ +class UpdateTest extends \Magento\TestFramework\TestCase\AbstractController +{ + /** + * @var Session + */ + private $customerSession; + + /** + * @var ManagerInterface + */ + private $messages; + + /** + * @var View + */ + private $customerViewHelper; + + /** + * Description field value for wishlist item. + * + * @var string + */ + private $description = 'some description'; + + /** + * Tests updating wishlist item comment. + * + * @magentoDataFixture Magento/Wishlist/_files/wishlist.php + * @dataProvider commentDataProvider + * @param string|null $postDescription + * @param string $expectedResult + * @param boolean $presetComment + */ + public function testUpdateComment($postDescription, $expectedResult, $presetComment) + { + /** @var Customer $customer */ + $customer = $this->customerSession->getCustomer(); + /** @var Wishlist $wishlist */ + $wishlist = $this->_objectManager + ->get(Wishlist::class) + ->loadByCustomerId($customer->getId(), true); + /** @var Item $item */ + $item = $wishlist->getItemCollection()->getFirstItem(); + + if ($presetComment) { + $item->setDescription($this->description); + $item->save(); + } + + $formKey = $this->_objectManager->get(FormKey::class); + $this->getRequest()->setPostValue( + [ + 'description' => isset($postDescription) ? [$item->getId() => $postDescription] : [], + 'qty' => isset($postDescription) ? [$item->getId() => 1] : [], + 'do' => '', + 'form_key' => $formKey->getFormKey() + ] + )->setMethod(Request::METHOD_POST); + $this->dispatch('wishlist/index/update/wishlist_id/' . $wishlist->getId()); + + // Reload item + $item = $this->_objectManager->get(Item::class)->load($item->getId()); + self::assertEquals( + $expectedResult, + $item->getDescription() + ); + } + + /** + * Data provider for testUpdateComment. + * + * @return array + */ + public function commentDataProvider() + { + + return [ + 'test adding comment' => [ + 'postDescription' => $this->description, + 'expectedResult' => $this->description, + 'presetComment' => false + ], + 'test removing comment' => [ + 'postDescription' => '', + 'expectedResult' => '', + 'presetComment' => true + ], + 'test not changing comment' => [ + 'postDescription' => null, + 'expectedResult' => $this->description, + 'presetComment' => true + ], + ]; + } + + protected function setUp() + { + parent::setUp(); + $logger = $this->createMock(LoggerInterface::class); + $this->customerSession = $this->_objectManager->get( + Session::class, + [$logger] + ); + /** @var AccountManagementInterface $service */ + $service = $this->_objectManager->create( + AccountManagementInterface::class + ); + $customer = $service->authenticate('customer@example.com', 'password'); + $this->customerSession->setCustomerDataAsLoggedIn($customer); + + $this->customerViewHelper = $this->_objectManager->create(View::class); + + $this->messages = $this->_objectManager->get( + ManagerInterface::class + ); + } + + protected function tearDown() + { + $this->customerSession->logout(); + $this->customerSession = null; + parent::tearDown(); + } +} diff --git a/lib/internal/Magento/Framework/Filesystem/Driver/File.php b/lib/internal/Magento/Framework/Filesystem/Driver/File.php index 519ca21deadb2ef5e6b0a338c84d7798170bb63e..6f9c24344f6776cba348a872ea550c79f5d78651 100644 --- a/lib/internal/Magento/Framework/Filesystem/Driver/File.php +++ b/lib/internal/Magento/Framework/Filesystem/Driver/File.php @@ -528,7 +528,7 @@ class File implements DriverInterface public function filePutContents($path, $content, $mode = null) { $result = @file_put_contents($this->getScheme() . $path, $content, $mode); - if (!$result) { + if ($result === false) { throw new FileSystemException( new \Magento\Framework\Phrase( 'The specified "%1" file could not be written %2', diff --git a/lib/internal/Magento/Framework/View/Design/Theme/ThemeList.php b/lib/internal/Magento/Framework/View/Design/Theme/ThemeList.php index 826811b55b4bf2f4f85bb3f08e9bf98a4b832c9f..000fba24f0822468a1260b603a055f42bfb74c35 100644 --- a/lib/internal/Magento/Framework/View/Design/Theme/ThemeList.php +++ b/lib/internal/Magento/Framework/View/Design/Theme/ThemeList.php @@ -234,7 +234,7 @@ class ThemeList extends \Magento\Framework\Data\Collection implements ListInterf $media = $themeConfig->getMedia(); $parentPathPieces = $themeConfig->getParentTheme(); - if (count($parentPathPieces) == 1) { + if (is_array($parentPathPieces) && count($parentPathPieces) == 1) { $pathPieces = $pathData['theme_path_pieces']; array_pop($pathPieces); $parentPathPieces = array_merge($pathPieces, $parentPathPieces);