layoutFactoryMock = $this->createMock(LayoutFactory::class); $this->helper = $objectManager->getObject( Message::class, [ 'layoutFactory' => $this->layoutFactoryMock, 'skipMessageCheck' => ['onepage_checkout'] ] ); } /** * Make sure that isMessagesAllowed is not called */ public function testGetInlineForCheckout() { $expectedHtml = 'here'; $layoutMock = $this->createMock(Layout::class); $entityMock = $this->createMock(DataObject::class); $inlineMock = $this->getMockBuilder(Inline::class) ->addMethods(['setId', 'setDontDisplayContainer']) ->onlyMethods(['setEntity', 'setCheckoutType', 'toHtml']) ->disableOriginalConstructor() ->getMock(); $this->layoutFactoryMock->expects($this->once())->method('create')->willReturn($layoutMock); $layoutMock->expects($this->once())->method('createBlock')->willReturn($inlineMock); $inlineMock->expects($this->once())->method('setId')->willReturnSelf(); $inlineMock->expects($this->once())->method('setDontDisplayContainer')->willReturnSelf(); $inlineMock->expects($this->once())->method('setEntity')->with($entityMock)->willReturnSelf(); $inlineMock->expects($this->once())->method('setCheckoutType')->willReturnSelf(); $inlineMock->expects($this->once())->method('toHtml')->willReturn($expectedHtml); $this->assertEquals($expectedHtml, $this->helper->getInline('onepage_checkout', $entityMock)); } }