Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
All Data Structures Namespaces Files Functions Variables Pages
SwitcherPluginTest.php
Go to the documentation of this file.
1 <?php
7 
8 use Magento\Paypal\Block\Adminhtml\Store\SwitcherPlugin as StoreSwitcherBlockPlugin;
12 use Magento\Paypal\Model\Config\StructurePlugin as ConfigStructurePlugin;
13 
14 class SwitcherPluginTest extends \PHPUnit\Framework\TestCase
15 {
19  private $plugin;
20 
24  private $objectManagerHelper;
25 
29  private $subjectMock;
30 
34  private $requestMock;
35 
36  protected function setUp()
37  {
38  $this->subjectMock = $this->getMockBuilder(StoreSwitcherBlock::class)
39  ->disableOriginalConstructor()
40  ->getMock();
41  $this->requestMock = $this->getMockBuilder(RequestInterface::class)
42  ->getMockForAbstractClass();
43 
44  $this->objectManagerHelper = new ObjectManagerHelper($this);
45  $this->plugin = $this->objectManagerHelper->getObject(StoreSwitcherBlockPlugin::class);
46  }
47 
54  public function testBeforeGetUrl($countryParam, $getUrlParams)
55  {
56  $this->requestMock->expects(static::once())
57  ->method('getParam')
58  ->with(ConfigStructurePlugin::REQUEST_PARAM_COUNTRY)
59  ->willReturn($countryParam);
60  $this->subjectMock->expects(static::any())
61  ->method('getRequest')
62  ->willReturn($this->requestMock);
63 
64  $this->assertEquals(['', $getUrlParams], $this->plugin->beforeGetUrl($this->subjectMock, '', []));
65  }
66 
70  public function beforeGetUrlDataProvider()
71  {
72  return [
73  ['any value', [ConfigStructurePlugin::REQUEST_PARAM_COUNTRY => null]],
74  [null, []]
75  ];
76  }
77 }