9 class DataTest extends \PHPUnit\Framework\TestCase
24 private $serializerMock;
28 $this->readerMock = $this->createMock(\
Magento\Framework\Config\ReaderInterface::class);
29 $this->cacheMock = $this->createMock(\
Magento\Framework\Config\CacheInterface::class);
30 $this->serializerMock = $this->createMock(\
Magento\Framework\
Serialize\SerializerInterface::class);
37 $this->cacheMock->expects($this->once())
40 $this->readerMock->expects($this->once())
43 $this->serializerMock->expects($this->once())
46 $config = new \Magento\Framework\Config\Data(
53 $this->assertEquals(
'b',
$config->get(
'a'));
54 $this->assertEquals(
null,
$config->get(
'a/b'));
55 $this->assertEquals(33,
$config->get(
'a/b', 33));
61 $serializedData =
'{"a":"b"}';
63 $this->cacheMock->expects($this->once())
65 ->willReturn($serializedData);
66 $this->readerMock->expects($this->never())
68 $this->serializerMock->expects($this->once())
69 ->method(
'unserialize')
70 ->with($serializedData)
72 $config = new \Magento\Framework\Config\Data(
79 $this->assertEquals(
'b',
$config->get(
'a'));
86 $this->cacheMock->expects($this->once())
88 ->willReturn($serializedData);
89 $this->serializerMock->expects($this->once())
90 ->method(
'unserialize')
91 ->with($serializedData)
93 $this->cacheMock->expects($this->once())
96 $config = new \Magento\Framework\Config\Data(
100 $this->serializerMock