1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Sitemap\Test\Unit\Model;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Sitemap\Model\SitemapConfigReader;
use Magento\Store\Model\ScopeInterface;
class SitemapConfigReaderTest extends \PHPUnit\Framework\TestCase
{
public function testGetValidPaths()
{
$scopeConfigMock = $this->getScopeConfigMock();
$configReader = new SitemapConfigReader($scopeConfigMock);
$this->assertEquals(['path1', 'path2'], $configReader->getValidPaths());
}
/**
* @return \PHPUnit_Framework_MockObject_MockObject
*/
private function getScopeConfigMock(): \PHPUnit_Framework_MockObject_MockObject
{
$scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
$scopeConfigMock->expects($this->any())
->method('getValue')
->willReturnMap([
[SitemapConfigReader::XML_PATH_SITEMAP_VALID_PATHS, ScopeInterface::SCOPE_STORE, null, ['path1']],
[SitemapConfigReader::XML_PATH_PUBLIC_FILES_VALID_PATHS, ScopeInterface::SCOPE_STORE, null, ['path2']],
]);
return $scopeConfigMock;
}
}