Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ScopeFallbackResolverTest.php
Go to the documentation of this file.
1 <?php
7 
14 
15 class ScopeFallbackResolverTest extends \PHPUnit\Framework\TestCase
16 {
18  protected $model;
19 
21  protected $storeManagerMock;
22 
23  protected function setUp()
24  {
25  $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
26  ->getMockForAbstractClass();
27 
28  $this->model = new ScopeFallbackResolver($this->storeManagerMock);
29  }
30 
41  public function testGetFallbackScope($scope, $scopeId, $forConfig, $websiteId, $groupId, $result)
42  {
44  $groupMock = $this->getMockBuilder(\Magento\Store\Api\Data\GroupInterface::class)
45  ->getMockForAbstractClass();
46  $groupMock->expects($this->any())
47  ->method('getWebsiteId')
48  ->willReturn($websiteId);
49 
51  $storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
52  ->getMockForAbstractClass();
53  $storeMock->expects($this->any())
54  ->method('getWebsiteId')
55  ->willReturn($websiteId);
56  $storeMock->expects($this->any())
57  ->method('getStoreGroupId')
58  ->willReturn($groupId);
59 
60  $this->storeManagerMock->expects($this->any())
61  ->method('getGroup')
62  ->with($scopeId)
63  ->willReturn($groupMock);
64  $this->storeManagerMock->expects($this->any())
65  ->method('getStore')
66  ->with($scopeId)
67  ->willReturn($storeMock);
68 
69  $this->assertEquals($result, $this->model->getFallbackScope($scope, $scopeId, $forConfig));
70  }
71 
75  public function dataProviderGetFallbackScope()
76  {
77  return [
78  [ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, true, null, null, [null, null]],
79  [ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0, false, 1, 2, [null, null]],
80  [ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 1, false, 0, 0, [null, null]],
95  ];
96  }
97 }