8 class DataTest extends \PHPUnit\Framework\TestCase
28 private $storeResolver;
33 private $storeManager;
38 private $eventManagerMock;
43 private $scopeConfigMock;
47 $this->eventManagerMock = $this->getMockBuilder(\
Magento\Framework\Event\ManagerInterface::class)
48 ->getMockForAbstractClass();
50 $this->scopeConfigMock = $this->getMockBuilder(\
Magento\Framework\
App\Config\ScopeConfigInterface::class)
51 ->getMockForAbstractClass();
53 $this->context = $this->getMockBuilder(\
Magento\Framework\View\Element\Context::class)
54 ->disableOriginalConstructor()
57 $this->context->expects($this->any())
58 ->method(
'getEventManager')
59 ->willReturn($this->eventManagerMock);
61 $this->context->expects($this->any())
62 ->method(
'getScopeConfig')
63 ->willReturn($this->scopeConfigMock);
65 $this->robots = $this->getMockBuilder(\
Magento\Robots\Model\Robots::class)
66 ->disableOriginalConstructor()
69 $this->storeResolver = $this->getMockBuilder(\
Magento\Store\Model\StoreResolver::class)
70 ->disableOriginalConstructor()
73 $this->storeManager = $this->getMockBuilder(\
Magento\Store\Model\StoreManagerInterface::class)
74 ->getMockForAbstractClass();
76 $this->block = new \Magento\Robots\Block\Data(
93 $this->scopeConfigMock->expects($this->once())->method(
'getValue')->willReturn(
false);
95 $this->robots->expects($this->once())
99 $this->assertEquals(
$data . PHP_EOL, $this->block->toHtml());
109 $storeMock = $this->getMockBuilder(\
Magento\Store\Api\Data\StoreInterface::class)->getMock();
111 $this->storeManager->expects($this->once())
113 ->willReturn($storeMock);
115 $storeMock->expects($this->once())
122 $this->assertEquals($expected, $this->block->getIdentities());
133 $this->eventManagerMock->expects($this->any())
137 'view_block_abstract_to_html_before',
139 'block' => $this->block,
143 'view_block_abstract_to_html_after',
145 'block' => $this->block,
146 'transport' =>
new \
Magento\Framework\DataObject([
'html' =>
$data]),
initEventManagerMock($data)