diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/ConfigTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/ConfigTest.php index 62938aceae2cc7f54019a3df538626bb8303e92b..63823943537492dc6a9d55054c9aa0597136b4f8 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/ConfigTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/ConfigTest.php @@ -27,6 +27,11 @@ class ConfigTest extends \PHPUnit_Framework_TestCase */ private $readerMock; + /** + * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $serializerMock; + /** * @var array */ @@ -39,7 +44,6 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->scopeMock = $this->getMock(\Magento\Framework\Config\ScopeInterface::class); $this->cacheMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); @@ -50,7 +54,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase '', false ); - $serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); $this->resourcesConfig = [ 'mainResourceName' => ['name' => 'mainResourceName', 'extends' => 'anotherResourceName'], @@ -64,12 +68,12 @@ class ConfigTest extends \PHPUnit_Framework_TestCase 'validResource' => ['connection' => 'validConnectionName'], ]; - $jsonString = json_encode($this->resourcesConfig); + $serializedData = 'serialized data'; $this->cacheMock->expects($this->any()) ->method('load') - ->willReturn($jsonString); - $serializerMock->method('unserialize') - ->with($jsonString) + ->willReturn($serializedData); + $this->serializerMock->method('unserialize') + ->with($serializedData) ->willReturn($this->resourcesConfig); /** @@ -86,15 +90,15 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->scopeMock, $this->cacheMock, $deploymentConfigMock, - 'cacheId' + 'cacheId', + $this->serializerMock ); - $objectManager->setBackwardCompatibleProperty($this->config, 'serializer', $serializerMock); } /** - * @dataProvider getConnectionNameDataProvider * @param string $resourceName * @param string $connectionName + * @dataProvider getConnectionNameDataProvider */ public function testGetConnectionName($resourceName, $connectionName) { @@ -117,7 +121,8 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->scopeMock, $this->cacheMock, $deploymentConfigMock, - 'cacheId' + 'cacheId', + $this->serializerMock ); } diff --git a/lib/internal/Magento/Framework/Config/Data/Scoped.php b/lib/internal/Magento/Framework/Config/Data/Scoped.php index 644c2649e4982ecf4b71d624191998942018bc9d..5e7bd441bbb296ac99d48c691995c8c9b5f4d376 100644 --- a/lib/internal/Magento/Framework/Config/Data/Scoped.php +++ b/lib/internal/Magento/Framework/Config/Data/Scoped.php @@ -104,12 +104,12 @@ class Scoped extends \Magento\Framework\Config\Data if (false == isset($this->_loadedScopes[$scopeCode])) { if ($scopeCode !== 'primary' && ($data = $this->_cache->load($scopeCode . '::' . $this->_cacheId)) ) { - $data = $this->getSerializer()->unserialize($data); + $data = $this->serializer->unserialize($data); } else { $data = $this->_reader->read($scopeCode); if ($scopeCode !== 'primary') { $this->_cache->save( - $this->getSerializer()->serialize($data), + $this->serializer->serialize($data), $scopeCode . '::' . $this->_cacheId ); }