From e27e0816abd366891d9c8aee605371e4f1e0321e Mon Sep 17 00:00:00 2001 From: WJdeBaas Date: Fri, 25 Nov 2016 14:42:02 +0100 Subject: [PATCH 1/4] Minor Update Mysql.php Add support for MySQL UNSIGNED TYPE_NUMERIC and TYPE_DECIMAL as according to their documentation http://dev.mysql.com/doc/refman/5.7/en/numeric-type-overview.html --- lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php index 9af29ab2c458d..45d717d1d4218 100644 --- a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php +++ b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php @@ -2369,6 +2369,9 @@ protected function _getColumnDefinition($options, $ddlType = null) } } $cType .= sprintf('(%d,%d)', $precision, $scale); + if (!empty($options['UNSIGNED'])) { + $cUnsigned = true; + } break; case Table::TYPE_TEXT: case Table::TYPE_BLOB: From 1415a845743c446ae2bf0e4f67733ed903e955db Mon Sep 17 00:00:00 2001 From: dmanners Date: Fri, 3 Mar 2017 14:13:54 +0000 Subject: [PATCH 2/4] Fix type with app/code/Magento/Email/Test/Unit/Model/TemplateTest.php --- app/code/Magento/Email/Test/Unit/Model/TemplateTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php b/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php index 6fdd487751beb..11baf7bdff82b 100644 --- a/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php +++ b/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php @@ -87,7 +87,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Framework\Serialize\Serializer\Json|\PHPUnit_Framework_MockObject_MockObject */ - private $serilizerMock; + private $serializerMock; protected function setUp() { @@ -144,7 +144,7 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->serilizerMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)->getMock(); + $this->serializerMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)->getMock(); } /** @@ -172,7 +172,7 @@ protected function getModelMock(array $mockedMethods = []) $this->urlModel, $this->filterFactory, [], - $this->serilizerMock + $this->serializerMock ]) ->getMock(); } @@ -542,7 +542,7 @@ public function testGetVariablesOptionArray($withGroup, $templateVariables, $exp $model = $this->getModelMock(); $model->setData('orig_template_variables', $templateVariables); - $this->serilizerMock->expects($this->any())->method('unserialize') + $this->serializerMock->expects($this->any())->method('unserialize') ->willReturn( json_decode($templateVariables, true) ); From 2b06a484f9020a5d3398d8e09f5e526701ab9629 Mon Sep 17 00:00:00 2001 From: evgk Date: Wed, 15 Mar 2017 05:53:24 -0400 Subject: [PATCH 3/4] Update against mainline --- app/code/Magento/Catalog/Block/Product/ListProduct.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Product/ListProduct.php b/app/code/Magento/Catalog/Block/Product/ListProduct.php index 258937b8767f7..8400a2c03c52a 100644 --- a/app/code/Magento/Catalog/Block/Product/ListProduct.php +++ b/app/code/Magento/Catalog/Block/Product/ListProduct.php @@ -84,7 +84,7 @@ public function __construct( } /** - * Retrieve loaded category collection + * Retrieve loaded product collection * * The goal of this method is to choose whether the existing collection should be returned * or a new one should be initialized. @@ -357,7 +357,7 @@ private function initializeProductCollection() // if the product is associated with any category if ($categories->count()) { // show products from this category - $this->setCategoryId(current($categories->getIterator())); + $this->setCategoryId(current($categories->getIterator())->getId()); } } From 877c9c79d30ebd0ad1ea4d08507a4c8afd45c213 Mon Sep 17 00:00:00 2001 From: evgk Date: Wed, 15 Mar 2017 05:53:49 -0400 Subject: [PATCH 4/4] A fix to make the new toolbar logic compatible with the test --- .../Unit/Block/Product/ListProductTest.php | 101 ++++++++++++++++-- 1 file changed, 92 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php index d4de92e38fc2f..cdc355bb73360 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php @@ -49,6 +49,26 @@ class ListProductTest extends \PHPUnit_Framework_TestCase * @var \Magento\Framework\Url\Helper\Data | \PHPUnit_Framework_MockObject_MockObject */ protected $urlHelperMock; + + /** + * @var \Magento\Catalog\Model\ResourceModel\Category | \PHPUnit_Framework_MockObject_MockObject + */ + protected $catCollectionMock; + + /** + * @var \Magento\Catalog\Model\ResourceModel\Product | \PHPUnit_Framework_MockObject_MockObject + */ + protected $prodCollectionMock; + + /** + * @var \Magento\Framework\View\LayoutInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $layoutMock; + + /** + * @var \Magento\Catalog\Block\Product\ProductList\Toolbar | \PHPUnit_Framework_MockObject_MockObject + */ + protected $toolbarMock; protected function setUp() { @@ -92,6 +112,34 @@ protected function setUp() '', false ); + $this->catCollectionMock = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Category\Collection::class, + [], + [], + '', + false + ); + $this->prodCollectionMock = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Product\Collection::class, + [], + [], + '', + false + ); + $this->layoutMock = $this->getMock( + \Magento\Framework\View\LayoutInterface::class, + [], + [], + '', + false + ); + $this->toolbarMock = $this->getMock( + \Magento\Catalog\Block\Product\ProductList\Toolbar::class, + [], + [], + '', + false + ); $this->urlHelperMock = $this->getMockBuilder(\Magento\Framework\Url\Helper\Data::class) ->disableOriginalConstructor()->getMock(); @@ -105,6 +153,8 @@ protected function setUp() 'urlHelper' => $this->urlHelperMock, ] ); + $this->block->setToolbarBlockName('mock'); + $this->block->setLayout($this->layoutMock); } protected function tearDown() @@ -121,26 +171,59 @@ public function testGetIdentities() ->method('getIdentities') ->will($this->returnValue([$productTag])); - $itemsCollection = new \ReflectionProperty( - \Magento\Catalog\Block\Product\ListProduct::class, - '_productCollection' - ); - $itemsCollection->setAccessible(true); - $itemsCollection->setValue($this->block, [$this->productMock]); + $this->productMock->expects($this->once()) + ->method('getCategoryCollection') + ->will($this->returnValue($this->catCollectionMock)); + + $this->catCollectionMock->expects($this->once()) + ->method('load') + ->will($this->returnValue($this->catCollectionMock)); + + $this->catCollectionMock->expects($this->once()) + ->method('setPage') + ->will($this->returnValue($this->catCollectionMock)); + + $this->catCollectionMock->expects($this->once()) + ->method('count') + ->will($this->returnValue(1)); + + $this->registryMock->expects($this->any()) + ->method('registry') + ->will($this->returnValue($this->productMock)); $currentCategory = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); - $currentCategory->expects($this->once()) + $currentCategory->expects($this->any()) ->method('getId') ->will($this->returnValue('1')); - $this->layerMock->expects($this->once()) + $this->catCollectionMock->expects($this->once()) + ->method('getIterator') + ->will($this->returnValue([$currentCategory])); + + $this->prodCollectionMock->expects($this->any()) + ->method('getIterator') + ->will($this->returnValue(new \ArrayIterator([$this->productMock]))); + + $this->layerMock->expects($this->any()) ->method('getCurrentCategory') ->will($this->returnValue($currentCategory)); + $this->layerMock->expects($this->once()) + ->method('getProductCollection') + ->will($this->returnValue($this->prodCollectionMock)); + + $this->layoutMock->expects($this->once()) + ->method('getBlock') + ->will($this->returnValue($this->toolbarMock)); + $this->assertEquals( - [$productTag, $categoryTag ], + [$productTag, $categoryTag], $this->block->getIdentities() ); + $this->assertEquals( + '1', + $this->block->getCategoryId() + ); } public function testGetAddToCartPostParams()