14 class NewTest extends \PHPUnit\Framework\TestCase
21 protected function setUp()
27 ->get(\
Magento\Customer\Api\GroupManagementInterface::class);
28 $notLoggedInId = $groupManagement->getNotLoggedInGroup()->getId();
34 \
Magento\Customer\Model\Context::CONTEXT_GROUP,
47 $info = $this->_block->getCacheKeyInfo();
48 $keys = array_keys(
$info);
52 $this->assertSame(0, array_shift($keys));
53 $this->assertEquals(
'CATALOG_PRODUCT_NEW',
$info[0]);
55 $this->assertSame(1, array_shift($keys));
59 )->getStore()->getId(),
63 $this->assertSame(2, array_shift($keys));
69 $this->assertEquals($themeModel->getId() ?:
null,
$info[2]);
71 $this->assertSame(3, array_shift($keys));
74 \
Magento\Customer\Model\Session::class
75 )->getCustomerGroupId(),
79 $this->assertSame(
'template', array_shift($keys));
85 $this->assertSame(4, array_shift($keys));
86 $this->assertNotEquals(
'',
$info[4]);
93 $this->_block->getProductsCount()
95 $this->_block->setProductsCount(100);
96 $this->assertEquals(100, $this->_block->getProductsCount());
101 $this->assertEmpty($this->_block->getProductCollection());
103 $this->_block->setProductsCount(5);
104 $this->_block->setTemplate(
'product/widget/new/content/new_list.phtml');
105 $this->_block->setLayout(
111 $html = $this->_block->toHtml();
112 $this->assertNotEmpty($html);
113 $this->assertContains(
'New Product', $html);
114 $this->assertInstanceOf(
116 $this->_block->getProductCollection()
131 $requestParams = [
'test' =>
'data'];
133 $block->getRequest()->setParams($requestParams);
137 $this->assertEquals(
'CATALOG_PRODUCT_NEW',
$info[0]);
138 $this->assertEquals(json_encode($requestParams),
$info[8]);
testSetGetProductsCount()
const DEFAULT_PRODUCTS_COUNT
testNewWidgetGetCacheKeyInfo()
foreach( $_productCollection as $_product)() ?>" class $info
static getObjectManager()