forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - magento#20739: [Backport] issue fixed magento#20563 Go to shipping information, Update qty & Addresses� (by @amol2jcommerce) - magento#20744: [Backport] recent-order-product-title-misaligned (by @amol2jcommerce) - magento#20270: [Backport] Fixed-Widget-option-labels-are-misalinged (by @amol2jcommerce) - magento#20613: [Backport] admin-order-info-issue2.2 (by @dipti2jcommerce) - magento#20418: [Backport] issue fixed magento#20304 No space between step title and saved address in c� (by @shikhamis11) - magento#20285: [Backport]magento#20222 Canary islands in ups carrier 2.2 (by @duckchip) - magento#18809: [Backport] catalog:images:resize total images count calculates incorrectly magento#18387 (by @vpodorozh) - magento#19461: [Backport 2.2] issue magento#18931 fixed. (by @JeroenVanLeusden) - magento#19655: Fixed - Shipping issue on PayPal Express magento#14712 (by @ssp58bleuciel) Fixed GitHub Issues: - magento#20563: Go to shipping information, Update qty & Addresses and Enter a new address button Not aligned from left and right in 767px screen size (reported by @swetacedcoss) has been fixed in magento#20739 by @amol2jcommerce in 2.2-develop branch Related commits: 1. 6e7281d - magento#20500: Recent Order Product Title Misaligned in Sidebar (reported by @parag2jcommerce) has been fixed in magento#20744 by @amol2jcommerce in 2.2-develop branch Related commits: 1. a971270 2. 81d8781 3. 73cb5c8 - magento#20113: Widget option labels are misalinged (reported by @yashwant2jcommerce) has been fixed in magento#20270 by @amol2jcommerce in 2.2-develop branch Related commits: 1. 936d71f 2. 935d3d2 - magento#20609: Currency rate value not align proper in order information tab when we create creditmemo from admin (reported by @dipti2jcommerce) has been fixed in magento#20613 by @dipti2jcommerce in 2.2-develop branch Related commits: 1. 7bf7ce1 - magento#20304: No space between step title and saved address in checkout (reported by @swetacedcoss) has been fixed in magento#20418 by @shikhamis11 in 2.2-develop branch Related commits: 1. 16d7461 - magento#18387: catalog:images:resize fails to process all images -> Possible underlying Magento/Framework/DB/Query/Generator issue (reported by @gwharton) has been fixed in magento#18809 by @vpodorozh in 2.2-develop branch Related commits: 1. f114f2a 2. 95eeb9f 3. 84590de 4. 4653d3e 5. d2e5345 6. 2539a71 7. 76bd089 8. b81b550 9. 051d82d 10. 10a1a88 - magento#18931: Product added to shopping cart / comparison list message not translated by default (reported by @arnoudhgz) has been fixed in magento#19461 by @JeroenVanLeusden in 2.2-develop branch Related commits: 1. 3b521b0 - magento#14712: Shipping issue on PayPal Express (reported by @raymond62) has been fixed in magento#19655 by @ssp58bleuciel in 2.2-develop branch Related commits: 1. 8a059e6 2. 8bdcca9 3. c3d5010
- Loading branch information
Showing
15 changed files
with
289 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
237 changes: 237 additions & 0 deletions
237
app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/ImageTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,237 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product; | ||
|
||
use Magento\Catalog\Model\ResourceModel\Product\Image; | ||
use Magento\Framework\DB\Adapter\AdapterInterface; | ||
use Magento\Framework\DB\Query\Generator; | ||
use Magento\Framework\DB\Select; | ||
use Magento\Framework\App\ResourceConnection; | ||
use Magento\Catalog\Model\ResourceModel\Product\Gallery; | ||
use PHPUnit_Framework_MockObject_MockObject as MockObject; | ||
use Magento\Framework\DB\Query\BatchIteratorInterface; | ||
|
||
class ImageTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager | ||
*/ | ||
protected $objectManager; | ||
|
||
/** | ||
* @var AdapterInterface | MockObject | ||
*/ | ||
protected $connectionMock; | ||
|
||
/** | ||
* @var Generator | MockObject | ||
*/ | ||
protected $generatorMock; | ||
|
||
/** | ||
* @var ResourceConnection | MockObject | ||
*/ | ||
protected $resourceMock; | ||
|
||
protected function setUp() | ||
{ | ||
$this->objectManager = | ||
new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); | ||
$this->connectionMock = $this->createMock(AdapterInterface::class); | ||
$this->resourceMock = $this->createMock(ResourceConnection::class); | ||
$this->resourceMock->method('getConnection') | ||
->willReturn($this->connectionMock); | ||
$this->resourceMock->method('getTableName') | ||
->willReturnArgument(0); | ||
$this->generatorMock = $this->createMock(Generator::class); | ||
} | ||
|
||
/** | ||
* @return MockObject | ||
*/ | ||
protected function getVisibleImagesSelectMock(): MockObject | ||
{ | ||
$selectMock = $this->getMockBuilder(Select::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$selectMock->expects($this->once()) | ||
->method('distinct') | ||
->willReturnSelf(); | ||
$selectMock->expects($this->once()) | ||
->method('from') | ||
->with( | ||
['images' => Gallery::GALLERY_TABLE], | ||
'value as filepath' | ||
)->willReturnSelf(); | ||
$selectMock->expects($this->once()) | ||
->method('where') | ||
->with('disabled = 0') | ||
->willReturnSelf(); | ||
|
||
return $selectMock; | ||
} | ||
|
||
/** | ||
* @param int $imagesCount | ||
* @dataProvider dataProvider | ||
*/ | ||
public function testGetCountAllProductImages(int $imagesCount) | ||
{ | ||
$selectMock = $this->getVisibleImagesSelectMock(); | ||
$selectMock->expects($this->exactly(2)) | ||
->method('reset') | ||
->withConsecutive( | ||
['columns'], | ||
['distinct'] | ||
)->willReturnSelf(); | ||
$selectMock->expects($this->once()) | ||
->method('columns') | ||
->with(new \Zend_Db_Expr('count(distinct value)')) | ||
->willReturnSelf(); | ||
|
||
$this->connectionMock->expects($this->once()) | ||
->method('select') | ||
->willReturn($selectMock); | ||
$this->connectionMock->expects($this->once()) | ||
->method('fetchOne') | ||
->with($selectMock) | ||
->willReturn($imagesCount); | ||
|
||
$imageModel = $this->objectManager->getObject( | ||
Image::class, | ||
[ | ||
'generator' => $this->generatorMock, | ||
'resourceConnection' => $this->resourceMock | ||
] | ||
); | ||
|
||
$this->assertSame( | ||
$imagesCount, | ||
$imageModel->getCountAllProductImages() | ||
); | ||
} | ||
|
||
/** | ||
* @param int $imagesCount | ||
* @param int $batchSize | ||
* @dataProvider dataProvider | ||
*/ | ||
public function testGetAllProductImages( | ||
int $imagesCount, | ||
int $batchSize | ||
) { | ||
$this->connectionMock->expects($this->once()) | ||
->method('select') | ||
->willReturn($this->getVisibleImagesSelectMock()); | ||
|
||
$batchCount = (int)ceil($imagesCount / $batchSize); | ||
$fetchResultsCallback = $this->getFetchResultCallbackForBatches($imagesCount, $batchSize); | ||
$this->connectionMock->expects($this->exactly($batchCount)) | ||
->method('fetchAll') | ||
->will($this->returnCallback($fetchResultsCallback)); | ||
|
||
/** @var Select | MockObject $selectMock */ | ||
$selectMock = $this->getMockBuilder(Select::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->generatorMock->expects($this->once()) | ||
->method('generate') | ||
->with( | ||
'value_id', | ||
$selectMock, | ||
$batchSize, | ||
BatchIteratorInterface::NON_UNIQUE_FIELD_ITERATOR | ||
)->will( | ||
$this->returnCallback( | ||
$this->getBatchIteratorCallback($selectMock, $batchCount) | ||
) | ||
); | ||
|
||
$imageModel = $this->objectManager->getObject( | ||
Image::class, | ||
[ | ||
'generator' => $this->generatorMock, | ||
'resourceConnection' => $this->resourceMock, | ||
'batchSize' => $batchSize | ||
] | ||
); | ||
|
||
$this->assertCount($imagesCount, $imageModel->getAllProductImages()); | ||
} | ||
|
||
/** | ||
* @param int $imagesCount | ||
* @param int $batchSize | ||
* @return \Closure | ||
*/ | ||
protected function getFetchResultCallbackForBatches( | ||
int $imagesCount, | ||
int $batchSize | ||
): \Closure { | ||
$fetchResultsCallback = function () use (&$imagesCount, $batchSize) { | ||
$batchSize = | ||
($imagesCount >= $batchSize) ? $batchSize : $imagesCount; | ||
$imagesCount -= $batchSize; | ||
|
||
$getFetchResults = function ($batchSize): array { | ||
$result = []; | ||
$count = $batchSize; | ||
while ($count) { | ||
$count--; | ||
$result[$count] = $count; | ||
} | ||
|
||
return $result; | ||
}; | ||
|
||
return $getFetchResults($batchSize); | ||
}; | ||
|
||
return $fetchResultsCallback; | ||
} | ||
|
||
/** | ||
* @param Select | MockObject $selectMock | ||
* @param int $batchCount | ||
* @return \Closure | ||
*/ | ||
protected function getBatchIteratorCallback( | ||
MockObject $selectMock, | ||
int $batchCount | ||
): \Closure { | ||
$iteratorCallback = function () use ($batchCount, $selectMock): array { | ||
$result = []; | ||
$count = $batchCount; | ||
while ($count) { | ||
$count--; | ||
$result[$count] = $selectMock; | ||
} | ||
|
||
return $result; | ||
}; | ||
|
||
return $iteratorCallback; | ||
} | ||
|
||
/** | ||
* Data Provider | ||
* @return array | ||
*/ | ||
public function dataProvider(): array | ||
{ | ||
return [ | ||
[300, 300], | ||
[300, 100], | ||
[139, 100], | ||
[67, 10], | ||
[154, 47], | ||
[0, 100] | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -488,6 +488,7 @@ | |
|
||
.product-items-names { | ||
.product-item { | ||
display: flex; | ||
margin-bottom: @indent__s; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -563,6 +563,7 @@ | |
|
||
.product-items-names { | ||
.product-item { | ||
display: flex; | ||
margin-bottom: @indent__s; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.