13 private $objectManager;
38 private $serializerMock;
42 $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
43 $this->_readerMock = $this->createMock(\
Magento\Framework\Config\ReaderInterface::class);
44 $this->_configScopeMock = $this->createMock(\
Magento\Framework\Config\ScopeInterface::class);
45 $this->_cacheMock = $this->createMock(\
Magento\Framework\Config\CacheInterface::class);
46 $this->serializerMock = $this->createMock(\
Magento\Framework\
Serialize\SerializerInterface::class);
48 $this->_model = $this->objectManager->getObject(
51 'reader' => $this->_readerMock,
52 'configScope' => $this->_configScopeMock,
53 'cache' => $this->_cacheMock,
55 'serializer' => $this->serializerMock
70 'key_1.1' => [
'key_1.1.1' =>
'value_1.1.1'],
71 'key_1.2' => [
'some' =>
'arrayValue'],
74 $this->_cacheMock->expects($this->once())
77 $this->_readerMock->expects($this->once())
80 $this->_model->merge($testData);
81 $this->assertEquals($expectedValue, $this->_model->get(
$path, $default));
90 [
'key_1/key_1.1/key_1.1.1',
'value_1.1.1',
'error'],
91 [
'key_1/key_1.2', [
'some' =>
'arrayValue'],
'error'],
94 [
'key_1.1' => [
'key_1.1.1' =>
'value_1.1.1'],
'key_1.2' => [
'some' =>
'arrayValue']],
97 [
'key_1/notExistedKey',
'defaultValue',
'defaultValue']
103 $testValue = [
'some' =>
'testValue'];
104 $serializedData =
'serialized data';
107 $this->_configScopeMock->expects(
112 $this->returnValue(
'adminhtml')
116 $this->_cacheMock->expects(
123 $this->returnValue(
false)
127 $this->_readerMock->expects(
134 $this->returnValue($testValue)
137 $this->serializerMock->expects($this->once())
138 ->method(
'serialize')
140 ->willReturn($serializedData);
143 $this->_cacheMock->expects($this->once())
145 ->with($serializedData,
'adminhtml::tag');
148 $this->assertEquals(
'testValue', $this->_model->get(
'some'));
151 $this->assertEquals(
'testValue', $this->_model->get(
'some'));
156 $testValue = [
'some' =>
'testValue'];
157 $serializedData =
'serialized data';
160 $this->_configScopeMock->expects(
165 $this->returnValue(
'adminhtml')
168 $this->serializerMock->expects($this->once())
169 ->method(
'unserialize')
170 ->with($serializedData)
171 ->willReturn($testValue);
174 $this->_cacheMock->expects($this->once())
176 ->with(
'adminhtml::tag')
177 ->willReturn($serializedData);
180 $this->_readerMock->expects($this->never())->method(
'read');
183 $this->_cacheMock->expects($this->never())->method(
'save');
186 $this->assertEquals(
'testValue', $this->_model->get(
'some'));
189 $this->assertEquals(
'testValue', $this->_model->get(
'some'));
testGetScopeSwitchingWithNonCachedData()
getConfigByPathDataProvider()
testGetConfigByPath($path, $expectedValue, $default)
testGetScopeSwitchingWithCachedData()