31 $this->paymentHelperMock = $this->createMock(\
Magento\Payment\Helper\Data::class);
32 $this->randomMock = $this->createMock(\
Magento\Framework\Math\Random::class);
33 $this->paypalShortcutHelperMock = $this->createMock(\
Magento\Paypal\Helper\Shortcut\ValidatorInterface::class);
35 $this->objectManagerHelper =
new ObjectManagerHelper($this);
36 $this->shortcut = $this->objectManagerHelper->getObject(
37 \
Magento\Paypal\Block\Bml\Shortcut::class,
39 'paymentData' => $this->paymentHelperMock,
40 'mathRandom' => $this->randomMock,
41 'shortcutValidator' => $this->paypalShortcutHelperMock,
48 $this->assertFalse($this->shortcut->isOrPositionBefore());
49 $this->shortcut->setShowOrPosition(
CatalogBlock\ShortcutButtons::POSITION_BEFORE);
50 $this->assertTrue($this->shortcut->isOrPositionBefore());
55 $this->assertFalse($this->shortcut->isOrPositionAfter());
56 $this->shortcut->setShowOrPosition(
CatalogBlock\ShortcutButtons::POSITION_AFTER);
57 $this->assertTrue($this->shortcut->isOrPositionAfter());
62 $this->assertEmpty($this->shortcut->getAlias());
68 $paymentMethodCode =
'';
69 $this->shortcut->setIsInCatalogProduct($isInCatalog);
71 $this->paypalShortcutHelperMock->expects($this->once())->method(
'validate')
72 ->with($paymentMethodCode, $isInCatalog)->will($this->returnValue(
false));
74 $this->assertEmpty($this->shortcut->toHtml());
80 $paymentMethodCode =
'';
82 $this->shortcut->setIsInCatalogProduct($isInCatalog);
83 $expressMethod = $this->getMockBuilder(\
Magento\Paypal\Model\Express::class)->disableOriginalConstructor()
84 ->setMethods([])->getMock();
86 $this->paypalShortcutHelperMock->expects($this->once())->method(
'validate')
87 ->with($paymentMethodCode, $isInCatalog)->will($this->returnValue(
true));
88 $this->paymentHelperMock->expects($this->once())->method(
'getMethodInstance')->with($bmlMethodCode)
89 ->will($this->returnValue($expressMethod));
90 $expressMethod->expects($this->once())->method(
'isAvailable')->will($this->returnValue(
false));
92 $this->assertEmpty($this->shortcut->toHtml());
98 $paymentMethodCode =
'';
101 $this->shortcut->setIsInCatalogProduct($isInCatalog);
102 $expressMethod = $this->getMockBuilder(\
Magento\Paypal\Model\Express::class)->disableOriginalConstructor()
103 ->setMethods([])->getMock();
105 'is_in_catalog_product' => $isInCatalog,
106 'shortcut_html_id' => $hash,
107 'checkout_url' =>
null,
108 'image_url' =>
'https://www.paypalobjects.com/webstatic/en_US/i/buttons/ppcredit-logo-medium.png',
109 'additional_link_image' => [
110 'href' =>
'https://www.securecheckout.billmelater.com/paycapture-content/' 111 .
'fetch?hash=AU826TU8&content=/bmlweb/ppwpsiw.html',
112 'src' =>
'https://www.paypalobjects.com/webstatic/en_US/btn/btn_bml_text.png',
116 $this->paypalShortcutHelperMock->expects($this->once())->method(
'validate')
117 ->with($paymentMethodCode, $isInCatalog)->will($this->returnValue(
true));
118 $this->paymentHelperMock->expects($this->once())->method(
'getMethodInstance')->with($bmlMethodCode)
119 ->will($this->returnValue($expressMethod));
120 $expressMethod->expects($this->once())->method(
'isAvailable')->will($this->returnValue(
true));
121 $this->randomMock->expects($this->once())->method(
'getUniqueHash')->with(
'ec_shortcut_bml_')
122 ->will($this->returnValue($hash));
124 $this->assertEmpty($this->shortcut->toHtml());
125 $this->assertContains($expectedData, $this->shortcut->getData());
testToHtmlWrongValidation()
testToHtmlMethodNotAvailable()
$paypalShortcutHelperMock
testToHtmlMethodSetBmlData()