1 | <?php |
||
23 | abstract class AbstractSitemapServiceTestCase extends TestCase |
||
24 | { |
||
25 | /** |
||
26 | * @var MockObject&RouterInterface |
||
27 | */ |
||
28 | protected $router; |
||
29 | |||
30 | /** |
||
31 | * @var SitemapServiceInterface |
||
32 | */ |
||
33 | protected $service; |
||
34 | |||
35 | /** |
||
36 | * @var array[] |
||
37 | */ |
||
38 | private $urls = []; |
||
39 | |||
40 | protected function setUp(): void |
||
46 | |||
47 | abstract protected function createService(): SitemapServiceInterface; |
||
48 | |||
49 | final protected function process(SitemapDefinitionInterface $sitemap): void |
||
82 | |||
83 | final protected function assertSitemap(string $location, int $priority, string $changeFreq, DateTime $lastMod = null): void |
||
87 | |||
88 | final protected function assertSitemapCount(int $count): void |
||
92 | |||
93 | private function getUrlIndex(UrlInterface $url): int |
||
103 | |||
104 | private function assertLastmod(?array $data, UrlInterface $url): void |
||
105 | { |
||
106 | if (null === $data['lastmod'] && null === $url->getLastMod()) { |
||
107 | return; |
||
108 | } |
||
109 | |||
110 | \assert($data['lastmod'] instanceof \DateTime); |
||
111 | |||
112 | if (null === $url->getLastMod() || $url->getLastMod() > $data['lastmod'] || $url->getLastMod() < $data['lastmod']) { |
||
113 | throw new AssertionFailedError( |
||
114 | sprintf("The url '%s' was expected with a different lastmod.", $url->getLoc()) |
||
115 | ); |
||
116 | } |
||
117 | } |
||
118 | |||
119 | private function assertPriority(UrlInterface $url, ?array $data): void |
||
132 | |||
133 | private function assertChangeFreq(UrlInterface $url, ?array $data): void |
||
146 | } |
||
147 |