Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Recent versions of Laravel support fake temporary URLs for the
fake storage disk.
  • Loading branch information
mzur committed Apr 14, 2022
1 parent d28a1bf commit b74fb3c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/Http/Controllers/Api/StorageRequestFileControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Bus;
use Mockery;
use RuntimeException;
use Storage;

class StorageRequestFileControllerTest extends ApiTestCase
Expand Down Expand Up @@ -256,6 +257,10 @@ public function testShow() {

config(['user_storage.pending_disk' => 'test']);
$disk = Storage::fake('test');
$disk->buildTemporaryUrlsUsing(function () {
// Act as if the storage disk driver does not support temporary URLs.
throw new RuntimeException;
});
$disk->put("request-{$id}/a.jpg", 'abc');
$disk->put("request-{$id}/c.jpg", 'abc');

Expand All @@ -282,6 +287,10 @@ public function testShowApproved() {

config(['user_storage.storage_disk' => 'test']);
$disk = Storage::fake('test');
$disk->buildTemporaryUrlsUsing(function () {
// Act as if the storage disk driver does not support temporary URLs.
throw new RuntimeException;
});
$disk->put("user-{$request->user_id}/a.jpg", 'abc');

$this->beGlobalAdmin();
Expand Down Expand Up @@ -311,6 +320,10 @@ public function testShowUrlEncode() {

config(['user_storage.pending_disk' => 'test']);
$disk = Storage::fake('test');
$disk->buildTemporaryUrlsUsing(function () {
// Act as if the storage disk driver does not support temporary URLs.
throw new RuntimeException;
});
$disk->put("request-{$id}/my dir/a.jpg", 'abc');

$this->beGlobalAdmin();
Expand Down

0 comments on commit b74fb3c

Please sign in to comment.