Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BannersTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class BannersTest extends \PHPUnit\Framework\TestCase
11 {
24  public function testToHtml(
25  $publisherId,
26  $display,
27  $position,
28  $configPosition,
29  $isEmptyHtml,
30  $methodWppBml,
31  $methodWppPeBml
32  ) {
34  $paypalConfig = $this->createMock(\Magento\Paypal\Model\Config::class);
35  $paypalConfig->expects($this->any())->method('getBmlPublisherId')->will($this->returnValue($publisherId));
36  $paypalConfig->expects($this->any())->method('getBmlDisplay')->will($this->returnValue($display));
37  $paypalConfig->expects($this->any())->method('getBmlPosition')->will($this->returnValue($configPosition));
38 
39  $paypalConfig->expects($this->any())
40  ->method('isMethodAvailable')
41  ->willReturnMap(
42  [
43  [
44  $methodWppBml,
45  true,
46  ],
47  [
48  $methodWppPeBml,
49  true,
50  ],
51  ]
52  );
53 
55  $layout = Bootstrap::getObjectManager()->get(\Magento\Framework\View\LayoutInterface::class);
56  $block = $layout->createBlock(
57  \Magento\Paypal\Block\Bml\Banners::class,
58  '',
59  [
60  'paypalConfig' => $paypalConfig,
61  'data' => ['position' => $position]
62  ]
63  );
64  $block->setTemplate('bml.phtml');
65  $html = $block->toHtml();
66 
67  if ($isEmptyHtml) {
68  $this->assertEmpty($html);
69  } else {
70  $this->assertContains('data-pp-pubid="' . $block->getPublisherId() . '"', $html);
71  $this->assertContains('data-pp-placementtype="' . $block->getSize() . '"', $html);
72  }
73  }
74 
78  public function testToHtmlDataProvider()
79  {
80  return [
81  [
82  'publisherId' => 1,
83  'display' => 1,
84  'position' => 100,
85  'configPosition' => 100,
86  'isEmptyHtml' => false,
87  'methodWppBml' => 'paypal_express_bml',
88  'methodWppPeBml' => 'payflow_express_bml',
89  ],
90  [
91  'publisherId' => 0,
92  'display' => 1,
93  'position' => 100,
94  'configPosition' => 100,
95  'isEmptyHtml' => true,
96  'methodWppBml' => 'paypal_express_bml',
97  'methodWppPeBml' => 'payflow_express_bml',
98  ],
99  [
100  'publisherId' => 1,
101  'display' => 0,
102  'position' => 100,
103  'configPosition' => 100,
104  'isEmptyHtml' => true,
105  'methodWppBml' => 'paypal_express_bml',
106  'methodWppPeBml' => 'payflow_express_bml',
107  ],
108  [
109  'publisherId' => 1,
110  'display' => 0,
111  'position' => 10,
112  'configPosition' => 100,
113  'isEmptyHtml' => true,
114  'methodWppBml' => 'paypal_express_bml',
115  'methodWppPeBml' => 'payflow_express_bml',
116  ]
117  ];
118  }
119 }
$block
Definition: block.php:8