diff --git a/src/Downloaders/HttpFacadeDownloader.php b/src/Downloaders/HttpFacadeDownloader.php new file mode 100644 index 000000000..d56bba8f1 --- /dev/null +++ b/src/Downloaders/HttpFacadeDownloader.php @@ -0,0 +1,21 @@ +throw(fn () => throw new UnreachableUrl($url)) + ->sink($temporaryFile) + ->get($url); + + return $temporaryFile; + } +} diff --git a/tests/Downloader/HttpFacadeDownloaderTest.php b/tests/Downloader/HttpFacadeDownloaderTest.php new file mode 100644 index 000000000..05d179c78 --- /dev/null +++ b/tests/Downloader/HttpFacadeDownloaderTest.php @@ -0,0 +1,28 @@ +with('Spatie MediaLibrary') + ->once() + ->andReturnSelf() + ->getMock() + ->shouldReceive('throw') + ->once() + ->andReturnSelf() + ->getMock() + ->shouldReceive('sink') + ->once() + ->andReturnSelf() + ->getMock() + ->shouldReceive('get') + ->with($url) + ->once(); + + $downloader = new \Spatie\MediaLibrary\Downloaders\HttpFacadeDownloader(); + + $result = $downloader->getTempFile($url); + + expect($result)->toBeString(); +});