@@ 73-85 (lines=13) @@ | ||
70 | /** |
|
71 | * @covers VDB\Spider\Downloader\Downloader |
|
72 | */ |
|
73 | public function testDownloadFailed() |
|
74 | { |
|
75 | $requestHandler = $this->getMockBuilder('VDB\Spider\RequestHandler\RequestHandlerInterface')->getMock(); |
|
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 |
|
@@ 90-102 (lines=13) @@ | ||
87 | /** |
|
88 | * @covers VDB\Spider\Downloader\Downloader |
|
89 | */ |
|
90 | public function testFilterNotMatches() |
|
91 | { |
|
92 | $filterNeverMatch = $this->getMockBuilder('VDB\Spider\Filter\PostFetchFilterInterface')->getMock(); |
|
93 | $filterNeverMatch |
|
94 | ->expects($this->any()) |
|
95 | ->method('match') |
|
96 | ->will($this->returnValue(false)); |
|
97 | $this->downloader->addPostFetchFilter($filterNeverMatch); |
|
98 | ||
99 | $resource = $this->downloader->download(new DiscoveredUri(new Uri('http://foobar.org'))); |
|
100 | ||
101 | $this->assertInstanceOf('VDB\\Spider\\Resource', $resource); |
|
102 | } |
|
103 | ||
104 | /** |
|
105 | * @covers VDB\Spider\Downloader\Downloader |
|
@@ 107-119 (lines=13) @@ | ||
104 | /** |
|
105 | * @covers VDB\Spider\Downloader\Downloader |
|
106 | */ |
|
107 | public function testFilterMatches() |
|
108 | { |
|
109 | $filterAlwaysMatch = $this->getMockBuilder('VDB\Spider\Filter\PostFetchFilterInterface')->getMock(); |
|
110 | $filterAlwaysMatch |
|
111 | ->expects($this->any()) |
|
112 | ->method('match') |
|
113 | ->will($this->returnValue(true)); |
|
114 | $this->downloader->addPostFetchFilter($filterAlwaysMatch); |
|
115 | ||
116 | $resource = $this->downloader->download(new DiscoveredUri(new Uri('http://foobar.org'))); |
|
117 | ||
118 | $this->assertFalse($resource); |
|
119 | } |
|
120 | } |
|
121 |