getObject(\Magento\Framework\View\Element\Template\Context::class); $httpContext = $this->getMockBuilder(\Magento\Framework\App\Http\Context::class) ->disableOriginalConstructor() ->setMethods(['getValue']) ->getMock(); $httpContext->expects($this->once()) ->method('getValue') ->will($this->returnValue(true)); /** @var \Magento\Sales\Block\Guest\Link $link */ $link = $objectManagerHelper->getObject( \Magento\Sales\Block\Guest\Link::class, [ 'context' => $context, 'httpContext' => $httpContext, ] ); $this->assertEquals('', $link->toHtml()); } }