Skip to content

Commit 41aeb20

Browse files
authored
Merge pull request #3243 from magento-tsg-csl3/2.2-develop-pr4
[TSG-CSL3] Backporting 2.2 (pr4)
2 parents 02d1e1b + 953dc16 commit 41aeb20

File tree

7 files changed

+128
-21
lines changed

7 files changed

+128
-21
lines changed

app/code/Magento/Checkout/Controller/Cart/Delete.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ public function execute()
2222
$id = (int)$this->getRequest()->getParam('id');
2323
if ($id) {
2424
try {
25-
$this->cart->removeItem($id)->save();
25+
$this->cart->removeItem($id);
26+
// We should set Totals to be recollected once more because of Cart model as usually is loading
27+
// before action executing and in case when triggerRecollect setted as true recollecting will
28+
// executed and the flag will be true already.
29+
$this->cart->getQuote()->setTotalsCollectedFlag(false);
30+
$this->cart->save();
2631
} catch (\Exception $e) {
2732
$this->messageManager->addError(__('We can\'t remove the item.'));
2833
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);

app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ public function getAddressCollectionJson()
217217
*/
218218
protected function _prepareForm()
219219
{
220+
$storeId = $this->getCreateOrderModel()
221+
->getSession()
222+
->getStoreId();
223+
$this->_storeManager->setCurrentStore($storeId);
224+
220225
$fieldset = $this->_form->addFieldset('main', ['no_container' => true]);
221226

222227
$addressForm = $this->_customerFormFactory->create('customer_address', 'adminhtml_customer_address');

app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Address/FormTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
use Magento\Sales\Model\Order;
2121
use Magento\Sales\Model\Order\Address;
2222
use PHPUnit_Framework_MockObject_MockObject as MockObject;
23+
use Magento\Backend\Model\Session\Quote as QuoteSession;
24+
use Magento\Sales\Model\AdminOrder\Create;
2325

2426
/**
2527
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -51,6 +53,16 @@ class FormTest extends \PHPUnit\Framework\TestCase
5153
*/
5254
private $countriesCollection;
5355

56+
/**
57+
* @var Create|MockObject
58+
*/
59+
private $orderCreate;
60+
61+
/**
62+
* @var QuoteSession|MockObject
63+
*/
64+
private $sessionQuote;
65+
5466
protected function setUp()
5567
{
5668
$objectManager = new ObjectManager($this);
@@ -61,6 +73,15 @@ protected function setUp()
6173
$this->countriesCollection = $this->createMock(
6274
Collection::class
6375
);
76+
$this->sessionQuote = $this->getMockBuilder(QuoteSession::class)
77+
->disableOriginalConstructor()
78+
->setMethods(['getStoreId', 'getStore'])
79+
->getMock();
80+
$this->orderCreate = $this->getMockBuilder(Create::class)
81+
->disableOriginalConstructor()
82+
->getMock();
83+
$this->orderCreate->method('getSession')
84+
->willReturn($this->sessionQuote);
6485

6586
$this->addressBlock = $objectManager->getObject(
6687
Form::class,
@@ -69,6 +90,8 @@ protected function setUp()
6990
'_customerFormFactory' => $this->customerFormFactory,
7091
'_coreRegistry' => $this->coreRegistry,
7192
'countriesCollection' => $this->countriesCollection,
93+
'sessionQuote' => $this->sessionQuote,
94+
'_orderCreate' => $this->orderCreate
7295
]
7396
);
7497
}
@@ -108,6 +131,8 @@ public function testGetForm()
108131
->willReturn($order);
109132
$order->method('getStoreId')
110133
->willReturn($storeId);
134+
$this->sessionQuote->method('getStoreId')
135+
->willReturn($storeId);
111136
$this->countriesCollection->method('loadByStore')
112137
->with($storeId)
113138
->willReturn($this->countriesCollection);

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

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,29 @@
99

1010
use Magento\Framework\App\Filesystem\DirectoryList;
1111
use Magento\Framework\Filesystem;
12+
use Magento\Framework\Exception\FileSystemException;
1213
use Magento\Framework\Filesystem\Directory\WriteInterface;
1314
use Magento\TestFramework\Helper\Bootstrap;
1415

1516
class FileTest extends \PHPUnit\Framework\TestCase
1617
{
1718
/**
18-
* @var \Magento\Framework\Filesystem\Driver\File
19+
* @var File
1920
*/
20-
protected $driver;
21+
private $driver;
2122

2223
/**
23-
* @var string
24+
* @var String
2425
*/
25-
protected $absolutePath;
26+
private $absolutePath;
2627

2728
/**
28-
* get relative path for test
29+
* @var String
30+
*/
31+
private $generatedPath;
32+
33+
/**
34+
* Returns relative path for the test.
2935
*
3036
* @param $relativePath
3137
* @return string
@@ -36,16 +42,26 @@ protected function getTestPath($relativePath)
3642
}
3743

3844
/**
39-
* Set up
45+
* @inheritdoc
4046
*/
4147
public function setUp()
4248
{
43-
$this->driver = new \Magento\Framework\Filesystem\Driver\File();
49+
$this->driver = new File();
4450
$this->absolutePath = dirname(__DIR__) . '/_files/';
51+
$this->generatedPath = $this->getTestPath('generated');
52+
$this->removeGeneratedDirectory();
53+
}
54+
55+
/**
56+
* @inheritdoc
57+
*/
58+
protected function tearDown()
59+
{
60+
$this->removeGeneratedDirectory();
4561
}
4662

4763
/**
48-
* test read recursively read
64+
* Tests directory recursive read.
4965
*/
5066
public function testReadDirectoryRecursively()
5167
{
@@ -63,7 +79,7 @@ public function testReadDirectoryRecursively()
6379
}
6480

6581
/**
66-
* test exception
82+
* Tests directory reading exception.
6783
*
6884
* @expectedException \Magento\Framework\Exception\FileSystemException
6985
*/
@@ -72,6 +88,11 @@ public function testReadDirectoryRecursivelyFailure()
7288
$this->driver->readDirectoryRecursively($this->getTestPath('not-existing-directory'));
7389
}
7490

91+
/**
92+
* Tests of directory creating.
93+
*
94+
* @throws FileSystemException
95+
*/
7596
public function testCreateDirectory()
7697
{
7798
$generatedPath = $this->getTestPath('generated/roo/bar/baz/foo');
@@ -123,4 +144,39 @@ public function createFileDataProvider()
123144
]
124145
];
125146
}
147+
148+
/**
149+
* Tests creation and removing of symlinks.
150+
*
151+
* @throws FileSystemException
152+
* @return void
153+
*/
154+
public function testSymlinks()
155+
{
156+
$sourceDirectory = $this->generatedPath . '/source';
157+
$destinationDirectory = $this->generatedPath . '/destination';
158+
159+
$this->driver->createDirectory($sourceDirectory);
160+
$this->driver->createDirectory($destinationDirectory);
161+
162+
$linkName = $destinationDirectory . '/link';
163+
164+
self::assertTrue($this->driver->isWritable($destinationDirectory));
165+
self::assertTrue($this->driver->symlink($sourceDirectory, $linkName));
166+
self::assertTrue($this->driver->isExists($linkName));
167+
self::assertTrue($this->driver->deleteDirectory($linkName));
168+
}
169+
170+
/**
171+
* Remove generated directories.
172+
*
173+
* @throws FileSystemException
174+
* @return void
175+
*/
176+
private function removeGeneratedDirectory()
177+
{
178+
if (is_dir($this->generatedPath)) {
179+
$this->driver->deleteDirectory($this->generatedPath);
180+
}
181+
}
126182
}

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
/**
1515
* Class File
16+
*
1617
* @package Magento\Framework\Filesystem\Driver
1718
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
1819
*/
@@ -405,7 +406,14 @@ public function deleteDirectory($path)
405406
$this->deleteFile($entity->getPathname());
406407
}
407408
}
408-
$result = @rmdir($this->getScheme() . $path);
409+
410+
$fullPath = $this->getScheme() . $path;
411+
if (is_link($fullPath)) {
412+
$result = @unlink($fullPath);
413+
} else {
414+
$result = @rmdir($fullPath);
415+
}
416+
409417
if (!$result) {
410418
throw new FileSystemException(
411419
new \Magento\Framework\Phrase(
@@ -836,6 +844,8 @@ public function fileUnlock($resource)
836844
}
837845

838846
/**
847+
* Returns an absolute path for the given one.
848+
*
839849
* @param string $basePath
840850
* @param string $path
841851
* @param string|null $scheme
@@ -872,7 +882,8 @@ public function getRelativePath($basePath, $path = null)
872882
}
873883

874884
/**
875-
* Fixes path separator
885+
* Fixes path separator.
886+
*
876887
* Utility method.
877888
*
878889
* @param string $path

lib/web/fotorama/fotorama.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2562,7 +2562,7 @@ fotoramaVersion = '4.6.4';
25622562
thisData.t > rightLimit : thisData.l > rightLimit;
25632563
specialMeasures.w = thisData.w;
25642564

2565-
if (thisData.l + thisData.w < leftLimit
2565+
if ((opts.navdir !== 'vertical' && thisData.l + thisData.w < leftLimit)
25662566
|| exceedLimit
25672567
|| callFit(thisData.$img, specialMeasures)) return;
25682568

lib/web/magnifier/magnifier.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,15 @@
554554
thumbObj.src = thumb.src;
555555
}
556556

557+
/**
558+
* Hide magnifier when mouse exceeds image bounds.
559+
*/
560+
function onMouseLeave() {
561+
onThumbLeave();
562+
isOverThumb = false;
563+
$magnifierPreview.addClass(MagnifyCls.magnifyHidden);
564+
}
565+
557566
function onMousemove(e) {
558567
pos.x = e.clientX;
559568
pos.y = e.clientY;
@@ -564,15 +573,9 @@
564573
isOverThumb = inBounds;
565574
}
566575

567-
if (inBounds && isOverThumb) {
568-
if(gMode === 'outside'){
569-
$magnifierPreview.removeClass(MagnifyCls.magnifyHidden);
570-
}
576+
if (inBounds && isOverThumb && gMode === 'outside') {
577+
$magnifierPreview.removeClass(MagnifyCls.magnifyHidden);
571578
move();
572-
} else {
573-
onThumbLeave();
574-
isOverThumb = false;
575-
$magnifierPreview.addClass(MagnifyCls.magnifyHidden);
576579
}
577580
}
578581

@@ -589,6 +592,8 @@
589592
});
590593

591594
$box.on('mousemove', onMousemove);
595+
$box.on('mouseleave', onMouseLeave);
596+
592597
_init($box, customUserOptions);
593598
}
594599
}(jQuery));

0 commit comments

Comments
 (0)