22 $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
32 public function testToHtml($isAuthenticated, $isRegistrationAllowed,
$result)
34 $context = $this->_objectManager->getObject(\
Magento\Framework\View\Element\Template\Context::class);
36 $httpContext = $this->getMockBuilder(\
Magento\Framework\
App\Http\Context::class)
37 ->disableOriginalConstructor()
38 ->setMethods([
'getValue'])
40 $httpContext->expects($this->any())
42 ->with(Context::CONTEXT_AUTH)
43 ->will($this->returnValue($isAuthenticated));
45 $registrationMock = $this->getMockBuilder(\
Magento\Customer\Model\Registration::class)
46 ->disableOriginalConstructor()
47 ->setMethods([
'isAllowed'])
49 $registrationMock->expects($this->any())
51 ->will($this->returnValue($isRegistrationAllowed));
54 $link = $this->_objectManager->getObject(
55 \
Magento\Customer\Block\Account\RegisterLink::class,
57 'context' => $context,
58 'httpContext' => $httpContext,
59 'registration' => $registrationMock,
81 $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
82 $helper = $this->getMockBuilder(
83 \
Magento\Customer\Model\Url::class
84 )->disableOriginalConstructor()->setMethods(
88 $helper->expects($this->any())->method(
'getRegisterUrl')->will($this->returnValue(
'register url'));
90 $context = $this->_objectManager->getObject(\
Magento\Framework\View\Element\Template\Context::class);
92 $block = $this->_objectManager->getObject(
93 \
Magento\Customer\Block\Account\RegisterLink::class,
94 [
'context' => $context,
'customerUrl' =>
$helper]
96 $this->assertEquals(
'register url',
$block->getHref());