createMock(\Magento\Paypal\Model\Config::class); $paypalConfig->expects($this->any())->method('getBmlPublisherId')->will($this->returnValue($publisherId)); $paypalConfig->expects($this->any())->method('getBmlDisplay')->will($this->returnValue($display)); $paypalConfig->expects($this->any())->method('getBmlPosition')->will($this->returnValue($configPosition)); $paypalConfig->expects($this->any()) ->method('isMethodAvailable') ->willReturnMap( [ [ $methodWppBml, true, ], [ $methodWppPeBml, true, ], ] ); /** @var \Magento\Framework\View\LayoutInterface $layout */ $layout = Bootstrap::getObjectManager()->get(\Magento\Framework\View\LayoutInterface::class); $block = $layout->createBlock( \Magento\Paypal\Block\Bml\Banners::class, '', [ 'paypalConfig' => $paypalConfig, 'data' => ['position' => $position] ] ); $block->setTemplate('bml.phtml'); $html = $block->toHtml(); if ($isEmptyHtml) { $this->assertEmpty($html); } else { $this->assertContains('data-pp-pubid="' . $block->getPublisherId() . '"', $html); $this->assertContains('data-pp-placementtype="' . $block->getSize() . '"', $html); } } /** * @return array */ public function testToHtmlDataProvider() { return [ [ 'publisherId' => 1, 'display' => 1, 'position' => 100, 'configPosition' => 100, 'isEmptyHtml' => false, 'methodWppBml' => 'paypal_express_bml', 'methodWppPeBml' => 'payflow_express_bml', ], [ 'publisherId' => 0, 'display' => 1, 'position' => 100, 'configPosition' => 100, 'isEmptyHtml' => true, 'methodWppBml' => 'paypal_express_bml', 'methodWppPeBml' => 'payflow_express_bml', ], [ 'publisherId' => 1, 'display' => 0, 'position' => 100, 'configPosition' => 100, 'isEmptyHtml' => true, 'methodWppBml' => 'paypal_express_bml', 'methodWppPeBml' => 'payflow_express_bml', ], [ 'publisherId' => 1, 'display' => 0, 'position' => 10, 'configPosition' => 100, 'isEmptyHtml' => true, 'methodWppBml' => 'paypal_express_bml', 'methodWppPeBml' => 'payflow_express_bml', ] ]; } }