Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigTest.php
Go to the documentation of this file.
1 <?php
7 
12 
13 class ConfigTest extends \PHPUnit\Framework\TestCase
14 {
18  private $scopeCodeResolver;
19 
23  private $configType;
24 
28  private $scope;
29 
33  private $appConfig;
34 
35  public function setUp()
36  {
37  $this->scopeCodeResolver = $this->getMockBuilder(ScopeCodeResolver::class)
38  ->disableOriginalConstructor()
39  ->getMock();
40  $this->configType = $this->getMockBuilder(ConfigTypeInterface::class)
41  ->getMockForAbstractClass();
42  $this->scope = $this->getMockBuilder(ScopeInterface::class)
43  ->getMockForAbstractClass();
44 
45  $this->appConfig = new Config($this->scopeCodeResolver, ['system' => $this->configType]);
46  }
47 
55  public function testGetValue($scope, $scopeCode = null)
56  {
57  $path = 'path';
58  if (!is_string($scope)) {
59  $this->scopeCodeResolver->expects($this->once())
60  ->method('resolve')
61  ->with('stores', $scopeCode)
62  ->willReturn('myStore');
63  } elseif (!$scopeCode) {
64  $this->scope->expects($this->once())
65  ->method('getCode')
66  ->willReturn('myWebsite');
67  }
68  $this->configType->expects($this->once())
69  ->method('get')
70  ->with($scope =='store' ? 'stores/path' : 'websites/myWebsite/path')
71  ->willReturn(true);
72 
73  $this->assertTrue($this->appConfig->getValue($path, $scope, $scopeCode ?: $this->scope));
74  }
75 
79  public function getValueDataProvider()
80  {
81  return [
82  ['store', 1],
83  ['website'],
84  ];
85  }
86 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
testGetValue($scope, $scopeCode=null)
Definition: ConfigTest.php:55