|
@@ 73-85 (lines=13) @@
|
| 70 |
|
/** |
| 71 |
|
* @covers VDB\Spider\Downloader\Downloader::download() |
| 72 |
|
*/ |
| 73 |
|
public function testDownloadFailed() |
| 74 |
|
{ |
| 75 |
|
$requestHandler = $this->getMock('VDB\Spider\RequestHandler\RequestHandlerInterface'); |
| 76 |
|
$requestHandler |
| 77 |
|
->expects($this->any()) |
| 78 |
|
->method('request') |
| 79 |
|
->will($this->throwException(new \Exception)); |
| 80 |
|
$this->downloader->setRequestHandler($requestHandler); |
| 81 |
|
|
| 82 |
|
$resource = $this->downloader->download(new DiscoveredUri(new Uri('http://foobar.org'))); |
| 83 |
|
|
| 84 |
|
$this->assertFalse($resource); |
| 85 |
|
} |
| 86 |
|
|
| 87 |
|
/** |
| 88 |
|
* @covers VDB\Spider\Downloader\Downloader::download() |
|
@@ 91-103 (lines=13) @@
|
| 88 |
|
* @covers VDB\Spider\Downloader\Downloader::download() |
| 89 |
|
* @covers VDB\Spider\Downloader\Downloader::matchesPostfetchFilter() |
| 90 |
|
*/ |
| 91 |
|
public function testFilter() |
| 92 |
|
{ |
| 93 |
|
$filterAlwaysMatch = $this->getMock('VDB\Spider\Filter\PostFetchFilterInterface'); |
| 94 |
|
$filterAlwaysMatch |
| 95 |
|
->expects($this->any()) |
| 96 |
|
->method('match') |
| 97 |
|
->will($this->returnValue(true)); |
| 98 |
|
$this->downloader->addPostFetchFilter($filterAlwaysMatch); |
| 99 |
|
|
| 100 |
|
$resource = $this->downloader->download(new DiscoveredUri(new Uri('http://foobar.org'))); |
| 101 |
|
|
| 102 |
|
$this->assertFalse($resource); |
| 103 |
|
} |
| 104 |
|
} |
| 105 |
|
|