1 | <?php |
||
22 | abstract class AbstractSitemapServiceTestCase extends TestCase |
||
23 | { |
||
24 | protected $router; |
||
25 | |||
26 | /** |
||
27 | * @var SitemapServiceInterface |
||
28 | */ |
||
29 | protected $service; |
||
30 | |||
31 | /** |
||
32 | * @var array[] |
||
33 | */ |
||
34 | private $urls = []; |
||
35 | |||
36 | /** |
||
37 | * {@inheritdoc} |
||
38 | */ |
||
39 | protected function setUp(): void |
||
45 | |||
46 | /** |
||
47 | * @return SitemapServiceInterface |
||
48 | */ |
||
49 | abstract protected function createService(): SitemapServiceInterface; |
||
50 | |||
51 | /** |
||
52 | * @param SitemapDefinitionInterface $sitemap |
||
53 | */ |
||
54 | final protected function process(SitemapDefinitionInterface $sitemap): void |
||
55 | { |
||
56 | $result = $this->service->execute($sitemap); |
||
57 | |||
58 | $count = \count($this->urls); |
||
59 | static::assertCount($count, $result); |
||
|
|||
60 | |||
61 | if (0 === $count) { |
||
62 | return; |
||
63 | } |
||
64 | |||
65 | /** @var UrlInterface $url */ |
||
66 | foreach ($result as $url) { |
||
67 | $index = $this->getUrlIndex($url); |
||
68 | |||
69 | if (-1 === $index) { |
||
70 | throw new AssertionFailedError(sprintf("The url '%s' was not expected to be called.", $url->getLoc())); |
||
71 | } |
||
72 | |||
73 | $data = &$this->urls[$index]; |
||
74 | |||
75 | $this->assertPriority($url, $data); |
||
76 | $this->assertChangeFreq($url, $data); |
||
77 | $this->assertLastmod($data, $url); |
||
78 | ++$data['count']; |
||
79 | } |
||
80 | |||
81 | foreach ($this->urls as $data) { |
||
82 | if (0 === $data['count']) { |
||
83 | throw new AssertionFailedError(sprintf("The url '%s' was expected to be called actually was not called", $data['location'])); |
||
84 | } |
||
85 | } |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @param string $location |
||
90 | * @param int $priority |
||
91 | * @param string $changeFreq |
||
92 | * @param DateTime|null $lastMod |
||
93 | */ |
||
94 | final protected function assertSitemap(string $location, int $priority, string $changeFreq, DateTime $lastMod = null): void |
||
98 | |||
99 | /** |
||
100 | * @param int $count |
||
101 | */ |
||
102 | final protected function assertSitemapCount(int $count): void |
||
106 | |||
107 | /** |
||
108 | * @param UrlInterface $url |
||
109 | * |
||
110 | * @return int |
||
111 | */ |
||
112 | private function getUrlIndex(UrlInterface $url): int |
||
122 | |||
123 | /** |
||
124 | * @param array|null $data |
||
125 | * @param UrlInterface $url |
||
126 | */ |
||
127 | private function assertLastmod(?array $data, UrlInterface $url): void |
||
141 | |||
142 | /** |
||
143 | * @param UrlInterface $url |
||
144 | * @param array|null $data |
||
145 | */ |
||
146 | private function assertPriority(UrlInterface $url, ?array $data): void |
||
159 | |||
160 | /** |
||
161 | * @param UrlInterface $url |
||
162 | * @param array|null $data |
||
163 | */ |
||
164 | private function assertChangeFreq(UrlInterface $url, ?array $data): void |
||
177 | } |
||
178 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: