Skip to content

Commit

Permalink
Merge pull request #932 from magento-engcom/develop-prs
Browse files Browse the repository at this point in the history
Public Pull Requests:
#7598
#8886
#7568
  • Loading branch information
Oleksii Korshenko committed Mar 16, 2017
2 parents c2a9d42 + 78d4e6b commit aa27856
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/code/Magento/Catalog/Block/Product/ListProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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());
}
}

Expand Down
101 changes: 92 additions & 9 deletions app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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();
Expand All @@ -105,6 +153,8 @@ protected function setUp()
'urlHelper' => $this->urlHelperMock,
]
);
$this->block->setToolbarBlockName('mock');
$this->block->setLayout($this->layoutMock);
}

protected function tearDown()
Expand All @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions app/code/Magento/Email/Test/Unit/Model/TemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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();
}

/**
Expand Down Expand Up @@ -172,7 +172,7 @@ protected function getModelMock(array $mockedMethods = [])
$this->urlModel,
$this->filterFactory,
[],
$this->serilizerMock
$this->serializerMock
])
->getMock();
}
Expand Down Expand Up @@ -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)
);
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -2373,6 +2373,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:
Expand Down

0 comments on commit aa27856

Please sign in to comment.