Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ScopeResolverTest.php
Go to the documentation of this file.
1 <?php
8 
9 class ScopeResolverTest extends \PHPUnit\Framework\TestCase
10 {
14  protected $scopeResolverMock;
15 
19  protected $_object;
20 
21  protected function setUp()
22  {
23  $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
24  $this->scopeResolverMock = $this->getMockBuilder(
25  \Magento\Framework\App\ScopeResolverInterface::class
26  )->getMock();
27  $this->_object = $objectManager->getObject(
28  \Magento\Framework\Url\ScopeResolver::class,
29  ['scopeResolver' => $this->scopeResolverMock]
30  );
31  }
32 
37  public function testGetScope($scopeId)
38  {
39  $scopeMock = $this->getMockBuilder(\Magento\Framework\Url\ScopeInterface::class)->getMock();
40  $this->scopeResolverMock->expects(
41  $this->at(0)
42  )->method(
43  'getScope'
44  )->with(
45  $scopeId
46  )->will(
47  $this->returnValue($scopeMock)
48  );
49  $this->_object->getScope($scopeId);
50  }
51 
56  public function testGetScopeException()
57  {
58  $this->_object->getScope();
59  }
60 
64  public function getScopeDataProvider()
65  {
66  return [[null], [1]];
67  }
68 
69  public function testGetScopes()
70  {
71  $this->scopeResolverMock->expects($this->once())->method('getScopes');
72  $this->_object->getScopes();
73  }
74 }
$objectManager
Definition: bootstrap.php:17