123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace Composer\Test\Mock;
- use Composer\Util\HttpDownloader;
- use Composer\Util\Http\Response;
- use Composer\Downloader\TransportException;
- class HttpDownloaderMock extends HttpDownloader
- {
- protected $contentMap;
-
- public function __construct(array $contentMap)
- {
- $this->contentMap = $contentMap;
- }
- public function get($fileUrl, $options = array())
- {
- if (!empty($this->contentMap[$fileUrl])) {
- return new Response(array('url' => $fileUrl), 200, array(), $this->contentMap[$fileUrl]);
- }
- throw new TransportException('The "'.$fileUrl.'" file could not be downloaded (NOT FOUND)', 404);
- }
- }
|