-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAGETWO-69540: Fix for #5897: getIdentities relies on uninitialized c…
…ollection #9777
- Loading branch information
Showing
4 changed files
with
137 additions
and
14 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
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
79 changes: 79 additions & 0 deletions
79
dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ProductList/UpsellTest.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,79 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Catalog\Block\Product\ProductList; | ||
|
||
/** | ||
* Test class for \Magento\Catalog\Block\Product\List\Upsell. | ||
* | ||
* @magentoDataFixture Magento/Catalog/_files/products_upsell.php | ||
*/ | ||
class UpsellTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \Magento\Catalog\Block\Product\ProductList\Upsell | ||
*/ | ||
protected $block; | ||
|
||
/** | ||
* @var \Magento\Catalog\Api\Data\ProductInterface | ||
*/ | ||
protected $product; | ||
|
||
/** | ||
* @var \Magento\Catalog\Api\Data\ProductInterface | ||
*/ | ||
protected $upsellProduct; | ||
|
||
protected function setUp() | ||
{ | ||
/** @var $objectManager \Magento\TestFramework\ObjectManager */ | ||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); | ||
\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND); | ||
|
||
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ | ||
$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); | ||
|
||
$this->upsellProduct = $productRepository->get('simple'); | ||
$this->product = $productRepository->get('simple_with_upsell'); | ||
$objectManager->get(\Magento\Framework\Registry::class)->register('product', $this->product); | ||
|
||
$this->block = $objectManager->get(\Magento\Framework\View\LayoutInterface::class) | ||
->createBlock(\Magento\Catalog\Block\Product\ProductList\Upsell::class); | ||
|
||
$this->block->setLayout($objectManager->get(\Magento\Framework\View\LayoutInterface::class)); | ||
$this->block->setTemplate('Magento_Catalog::product/list/items.phtml'); | ||
$this->block->setType('upsell'); | ||
$this->block->addChild('addto', \Magento\Catalog\Block\Product\ProductList\Item\Container::class); | ||
$this->block->getChildBlock( | ||
'addto' | ||
)->addChild( | ||
'compare', | ||
\Magento\Catalog\Block\Product\ProductList\Item\AddTo\Compare::class, | ||
['template' => 'Magento_Catalog::product/list/addto/compare.phtml'] | ||
); | ||
} | ||
|
||
/** | ||
* @magentoAppIsolation enabled | ||
*/ | ||
public function testAll() | ||
{ | ||
$html = $this->block->toHtml(); | ||
$this->assertNotEmpty($html); | ||
$this->assertContains('Simple Up Sell', $html); | ||
$this->assertCount(1, $this->block->getItems()); | ||
} | ||
|
||
/** | ||
* @magentoAppIsolation enabled | ||
*/ | ||
public function testGetIdentities() | ||
{ | ||
$expectedTags = ['cat_p_' . $this->upsellProduct->getId(), 'cat_p']; | ||
$tags = $this->block->getIdentities(); | ||
$this->assertEquals($expectedTags, $tags); | ||
} | ||
} |