Skip to content

Commit aa27856

Browse files
author
Oleksii Korshenko
authored
Merge pull request #932 from magento-engcom/develop-prs
Public Pull Requests: #7598 #8886 #7568
2 parents c2a9d42 + 78d4e6b commit aa27856

File tree

4 files changed

+101
-15
lines changed

4 files changed

+101
-15
lines changed

app/code/Magento/Catalog/Block/Product/ListProduct.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function __construct(
8484
}
8585

8686
/**
87-
* Retrieve loaded category collection
87+
* Retrieve loaded product collection
8888
*
8989
* The goal of this method is to choose whether the existing collection should be returned
9090
* or a new one should be initialized.
@@ -357,7 +357,7 @@ private function initializeProductCollection()
357357
// if the product is associated with any category
358358
if ($categories->count()) {
359359
// show products from this category
360-
$this->setCategoryId(current($categories->getIterator()));
360+
$this->setCategoryId(current($categories->getIterator())->getId());
361361
}
362362
}
363363

app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php

Lines changed: 92 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,26 @@ class ListProductTest extends \PHPUnit_Framework_TestCase
4949
* @var \Magento\Framework\Url\Helper\Data | \PHPUnit_Framework_MockObject_MockObject
5050
*/
5151
protected $urlHelperMock;
52+
53+
/**
54+
* @var \Magento\Catalog\Model\ResourceModel\Category | \PHPUnit_Framework_MockObject_MockObject
55+
*/
56+
protected $catCollectionMock;
57+
58+
/**
59+
* @var \Magento\Catalog\Model\ResourceModel\Product | \PHPUnit_Framework_MockObject_MockObject
60+
*/
61+
protected $prodCollectionMock;
62+
63+
/**
64+
* @var \Magento\Framework\View\LayoutInterface | \PHPUnit_Framework_MockObject_MockObject
65+
*/
66+
protected $layoutMock;
67+
68+
/**
69+
* @var \Magento\Catalog\Block\Product\ProductList\Toolbar | \PHPUnit_Framework_MockObject_MockObject
70+
*/
71+
protected $toolbarMock;
5272

5373
protected function setUp()
5474
{
@@ -92,6 +112,34 @@ protected function setUp()
92112
'',
93113
false
94114
);
115+
$this->catCollectionMock = $this->getMock(
116+
\Magento\Catalog\Model\ResourceModel\Category\Collection::class,
117+
[],
118+
[],
119+
'',
120+
false
121+
);
122+
$this->prodCollectionMock = $this->getMock(
123+
\Magento\Catalog\Model\ResourceModel\Product\Collection::class,
124+
[],
125+
[],
126+
'',
127+
false
128+
);
129+
$this->layoutMock = $this->getMock(
130+
\Magento\Framework\View\LayoutInterface::class,
131+
[],
132+
[],
133+
'',
134+
false
135+
);
136+
$this->toolbarMock = $this->getMock(
137+
\Magento\Catalog\Block\Product\ProductList\Toolbar::class,
138+
[],
139+
[],
140+
'',
141+
false
142+
);
95143

96144
$this->urlHelperMock = $this->getMockBuilder(\Magento\Framework\Url\Helper\Data::class)
97145
->disableOriginalConstructor()->getMock();
@@ -105,6 +153,8 @@ protected function setUp()
105153
'urlHelper' => $this->urlHelperMock,
106154
]
107155
);
156+
$this->block->setToolbarBlockName('mock');
157+
$this->block->setLayout($this->layoutMock);
108158
}
109159

110160
protected function tearDown()
@@ -121,26 +171,59 @@ public function testGetIdentities()
121171
->method('getIdentities')
122172
->will($this->returnValue([$productTag]));
123173

124-
$itemsCollection = new \ReflectionProperty(
125-
\Magento\Catalog\Block\Product\ListProduct::class,
126-
'_productCollection'
127-
);
128-
$itemsCollection->setAccessible(true);
129-
$itemsCollection->setValue($this->block, [$this->productMock]);
174+
$this->productMock->expects($this->once())
175+
->method('getCategoryCollection')
176+
->will($this->returnValue($this->catCollectionMock));
177+
178+
$this->catCollectionMock->expects($this->once())
179+
->method('load')
180+
->will($this->returnValue($this->catCollectionMock));
181+
182+
$this->catCollectionMock->expects($this->once())
183+
->method('setPage')
184+
->will($this->returnValue($this->catCollectionMock));
185+
186+
$this->catCollectionMock->expects($this->once())
187+
->method('count')
188+
->will($this->returnValue(1));
189+
190+
$this->registryMock->expects($this->any())
191+
->method('registry')
192+
->will($this->returnValue($this->productMock));
130193

131194
$currentCategory = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false);
132-
$currentCategory->expects($this->once())
195+
$currentCategory->expects($this->any())
133196
->method('getId')
134197
->will($this->returnValue('1'));
135198

136-
$this->layerMock->expects($this->once())
199+
$this->catCollectionMock->expects($this->once())
200+
->method('getIterator')
201+
->will($this->returnValue([$currentCategory]));
202+
203+
$this->prodCollectionMock->expects($this->any())
204+
->method('getIterator')
205+
->will($this->returnValue(new \ArrayIterator([$this->productMock])));
206+
207+
$this->layerMock->expects($this->any())
137208
->method('getCurrentCategory')
138209
->will($this->returnValue($currentCategory));
139210

211+
$this->layerMock->expects($this->once())
212+
->method('getProductCollection')
213+
->will($this->returnValue($this->prodCollectionMock));
214+
215+
$this->layoutMock->expects($this->once())
216+
->method('getBlock')
217+
->will($this->returnValue($this->toolbarMock));
218+
140219
$this->assertEquals(
141-
[$productTag, $categoryTag ],
220+
[$productTag, $categoryTag],
142221
$this->block->getIdentities()
143222
);
223+
$this->assertEquals(
224+
'1',
225+
$this->block->getCategoryId()
226+
);
144227
}
145228

146229
public function testGetAddToCartPostParams()

app/code/Magento/Email/Test/Unit/Model/TemplateTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase
8787
/**
8888
* @var \Magento\Framework\Serialize\Serializer\Json|\PHPUnit_Framework_MockObject_MockObject
8989
*/
90-
private $serilizerMock;
90+
private $serializerMock;
9191

9292
protected function setUp()
9393
{
@@ -144,7 +144,7 @@ protected function setUp()
144144
->disableOriginalConstructor()
145145
->getMock();
146146

147-
$this->serilizerMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)->getMock();
147+
$this->serializerMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)->getMock();
148148
}
149149

150150
/**
@@ -172,7 +172,7 @@ protected function getModelMock(array $mockedMethods = [])
172172
$this->urlModel,
173173
$this->filterFactory,
174174
[],
175-
$this->serilizerMock
175+
$this->serializerMock
176176
])
177177
->getMock();
178178
}
@@ -542,7 +542,7 @@ public function testGetVariablesOptionArray($withGroup, $templateVariables, $exp
542542
$model = $this->getModelMock();
543543
$model->setData('orig_template_variables', $templateVariables);
544544

545-
$this->serilizerMock->expects($this->any())->method('unserialize')
545+
$this->serializerMock->expects($this->any())->method('unserialize')
546546
->willReturn(
547547
json_decode($templateVariables, true)
548548
);

lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,6 +2373,9 @@ protected function _getColumnDefinition($options, $ddlType = null)
23732373
}
23742374
}
23752375
$cType .= sprintf('(%d,%d)', $precision, $scale);
2376+
if (!empty($options['UNSIGNED'])) {
2377+
$cUnsigned = true;
2378+
}
23762379
break;
23772380
case Table::TYPE_TEXT:
23782381
case Table::TYPE_BLOB:

0 commit comments

Comments
 (0)