Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ScopeDefinerTest.php
Go to the documentation of this file.
1 <?php
7 
10 
11 class ScopeDefinerTest extends \PHPUnit\Framework\TestCase
12 {
16  protected $_model;
17 
21  protected $_requestMock;
22 
23  protected function setUp()
24  {
25  $this->_requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class);
26  $objectManager = new ObjectManager($this);
27  $this->_model = $objectManager->getObject(
28  \Magento\Config\Model\Config\ScopeDefiner::class,
29  ['request' => $this->_requestMock]
30  );
31  }
32 
34  {
35  $this->assertEquals(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $this->_model->getScope());
36  }
37 
39  {
40  $this->_requestMock->expects(
41  $this->any()
42  )->method(
43  'getParam'
44  )->will(
45  $this->returnValueMap([['website', null, 'someWebsite'], ['store', null, 'someStore']])
46  );
47  $this->assertEquals(\Magento\Store\Model\ScopeInterface::SCOPE_STORE, $this->_model->getScope());
48  }
49 
51  {
52  $this->_requestMock->expects(
53  $this->any()
54  )->method(
55  'getParam'
56  )->will(
57  $this->returnValueMap([['website', null, 'someWebsite'], ['store', null, null]])
58  );
59  $this->assertEquals(\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE, $this->_model->getScope());
60  }
61 }
$objectManager
Definition: bootstrap.php:17