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