| @@ 175-192 (lines=18) @@ | ||
| 172 | * |
|
| 173 | * Behaviour as explained here: https://en.wikipedia.org/wiki/Depth-first_search#Example |
|
| 174 | */ |
|
| 175 | public function testCrawlDFSDefaultBehaviour() |
|
| 176 | { |
|
| 177 | $this->spider->getDiscovererSet()->maxDepth = 10; |
|
| 178 | ||
| 179 | $this->spider->crawl(); |
|
| 180 | ||
| 181 | $expected = array( |
|
| 182 | $this->linkA, |
|
| 183 | $this->linkE, |
|
| 184 | $this->linkF, |
|
| 185 | $this->linkC, |
|
| 186 | $this->linkG, |
|
| 187 | $this->linkB, |
|
| 188 | $this->linkD |
|
| 189 | ); |
|
| 190 | ||
| 191 | $this->compareUriArray($expected, $this->spider->getDownloader()->getPersistenceHandler()); |
|
| 192 | } |
|
| 193 | ||
| 194 | /** |
|
| 195 | * @covers VDB\Spider\Spider |
|
| @@ 197-215 (lines=19) @@ | ||
| 194 | /** |
|
| 195 | * @covers VDB\Spider\Spider |
|
| 196 | */ |
|
| 197 | public function testCrawlBFSDefaultBehaviour() |
|
| 198 | { |
|
| 199 | $this->spider->getQueueManager()->setTraversalAlgorithm(InMemoryQueueManager::ALGORITHM_BREADTH_FIRST); |
|
| 200 | $this->spider->getDiscovererSet()->maxDepth = 1000; |
|
| 201 | ||
| 202 | $this->spider->crawl(); |
|
| 203 | ||
| 204 | $expected = array( |
|
| 205 | $this->linkA, |
|
| 206 | $this->linkB, |
|
| 207 | $this->linkC, |
|
| 208 | $this->linkE, |
|
| 209 | $this->linkD, |
|
| 210 | $this->linkF, |
|
| 211 | $this->linkG |
|
| 212 | ); |
|
| 213 | ||
| 214 | $this->compareUriArray($expected, $this->spider->getDownloader()->getPersistenceHandler()); |
|
| 215 | } |
|
| 216 | ||
| 217 | private function compareUriArray($expected, $actual) |
|
| 218 | { |
|