/** * @dataProvider getScopeDataProvider * * @param string $scopeType * @param string $scope * @param array $data * @param string|null $cachedData */ public function testGetScope($scopeType, $scope, array $data, $cachedData) { $scopeCode = $scope instanceof \Magento\Framework\App\ScopeInterface ? $scope->getCode() : $scope; $cacheKey = "test_cache_id|{$scopeType}|{$scopeCode}"; $this->_readerPool->expects( $this->any() )->method( 'getReader' )->with( $scopeType )->will( $this->returnValue($this->_reader) ); $this->_cache->expects($this->once())->method('load')->with($cacheKey)->will($this->returnValue($cachedData)); if (!$cachedData) { $this->_reader->expects($this->once())->method('read')->with('testScope')->will($this->returnValue($data)); $this->_cache->expects( $this->once() )->method( 'save' )->with( serialize($data), $cacheKey, [\Magento\Framework\App\Config\ScopePool::CACHE_TAG] ); } $configData = $this->getMockBuilder('\Magento\Framework\App\Config\Data') ->disableOriginalConstructor() ->getMock(); $this->_dataFactory->expects( $this->once() )->method( 'create' )->with( ['data' => $data] )->will( $this->returnValue($configData) ); $this->assertInstanceOf( '\Magento\Framework\App\Config\DataInterface', $this->_object->getScope($scopeType, $scope) ); // second call to check caching $this->assertInstanceOf( '\Magento\Framework\App\Config\DataInterface', $this->_object->getScope($scopeType, $scope) ); }