@@ 194-211 (lines=18) @@ | ||
191 | * |
|
192 | * Behaviour as explained here: https://en.wikipedia.org/wiki/Depth-first_search#Example |
|
193 | */ |
|
194 | public function testCrawlDFSDefaultBehaviour() |
|
195 | { |
|
196 | $this->spider->getDiscovererSet()->maxDepth = 10; |
|
197 | ||
198 | $this->spider->crawl(); |
|
199 | ||
200 | $expected = array( |
|
201 | $this->linkA, |
|
202 | $this->linkE, |
|
203 | $this->linkF, |
|
204 | $this->linkC, |
|
205 | $this->linkG, |
|
206 | $this->linkB, |
|
207 | $this->linkD |
|
208 | ); |
|
209 | ||
210 | $this->assertEquals($expected, $this->statsHandler->getPersisted()); |
|
211 | } |
|
212 | ||
213 | /** |
|
214 | * @covers VDB\Spider\Spider::crawl |
|
@@ 217-235 (lines=19) @@ | ||
214 | * @covers VDB\Spider\Spider::crawl |
|
215 | * |
|
216 | */ |
|
217 | public function testCrawlBFSDefaultBehaviour() |
|
218 | { |
|
219 | $this->spider->getQueueManager()->setTraversalAlgorithm(InMemoryQueueManager::ALGORITHM_BREADTH_FIRST); |
|
220 | $this->spider->getDiscovererSet()->maxDepth = 1000; |
|
221 | ||
222 | $this->spider->crawl(); |
|
223 | ||
224 | $expected = array( |
|
225 | $this->linkA, |
|
226 | $this->linkB, |
|
227 | $this->linkC, |
|
228 | $this->linkE, |
|
229 | $this->linkD, |
|
230 | $this->linkF, |
|
231 | $this->linkG |
|
232 | ); |
|
233 | ||
234 | $this->assertEquals($expected, $this->statsHandler->getPersisted()); |
|
235 | } |
|
236 | ||
237 | /** |
|
238 | * @covers VDB\Spider\Spider::crawl |