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