| @@ 174-191 (lines=18) @@ | ||
| 171 | * |
|
| 172 | * Behaviour as explained here: https://en.wikipedia.org/wiki/Depth-first_search#Example |
|
| 173 | */ |
|
| 174 | public function testCrawlDFSDefaultBehaviour() |
|
| 175 | { |
|
| 176 | $this->spider->getQueueManager()->maxDepth = 10; |
|
| 177 | ||
| 178 | $this->spider->crawl(); |
|
| 179 | ||
| 180 | $expected = array( |
|
| 181 | $this->linkA, |
|
| 182 | $this->linkE, |
|
| 183 | $this->linkF, |
|
| 184 | $this->linkC, |
|
| 185 | $this->linkG, |
|
| 186 | $this->linkB, |
|
| 187 | $this->linkD |
|
| 188 | ); |
|
| 189 | ||
| 190 | $this->assertEquals($expected, $this->statsHandler->getPersisted()); |
|
| 191 | } |
|
| 192 | ||
| 193 | /** |
|
| 194 | * @covers VDB\Spider\Spider::crawl |
|
| @@ 197-215 (lines=19) @@ | ||
| 194 | * @covers VDB\Spider\Spider::crawl |
|
| 195 | * |
|
| 196 | */ |
|
| 197 | public function testCrawlBFSDefaultBehaviour() |
|
| 198 | { |
|
| 199 | $this->spider->getQueueManager()->setTraversalAlgorithm(InMemoryQueueManager::ALGORITHM_BREADTH_FIRST); |
|
| 200 | $this->spider->getQueueManager()->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->assertEquals($expected, $this->statsHandler->getPersisted()); |
|
| 215 | } |
|
| 216 | ||
| 217 | /** |
|
| 218 | * @covers VDB\Spider\Spider::crawl |
|