-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using throw config of filesystem disks when faking (#53779)
* Using throw config of filesystem disks when faking * CS fix * Further CS fixes * Further CS fixes * Further CS fixes * Added dock blocks * Added dots * formatting --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
- Loading branch information
1 parent
da5e4e4
commit a53d179
Showing
2 changed files
with
94 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Support; | ||
|
||
use Illuminate\Support\Facades\Config; | ||
use Illuminate\Support\Facades\Storage; | ||
use League\Flysystem\UnableToReadFile; | ||
use Orchestra\Testbench\TestCase; | ||
|
||
class StorageFacadeTest extends TestCase | ||
{ | ||
public function testFake_whenDiskNotConfigured_doesNotThrowExceptionOnError() | ||
{ | ||
$result = Storage::fake('test')->get('nonExistentFile'); | ||
|
||
$this->assertNull($result); | ||
} | ||
|
||
public function testFake_whenThrowSetToDisk_throwsExceptionOnError() | ||
{ | ||
Config::set('filesystems.disks.test', ['throw' => true]); | ||
|
||
$this->expectException(UnableToReadFile::class); | ||
Storage::fake('test')->get('nonExistentFile'); | ||
} | ||
|
||
public function testFake_whenThrowOverwritten_usesOverwrite() | ||
{ | ||
Config::set('filesystems.disks.test', ['throw' => true]); | ||
|
||
$result = Storage::fake('test', ['throw' => false])->get('nonExistentFile'); | ||
$this->assertNull($result); | ||
} | ||
|
||
public function testPersistentFake_whenDiskNotConfigured_doesNotThrowExceptionOnError() | ||
{ | ||
$result = Storage::persistentFake('test')->get('nonExistentFile'); | ||
|
||
$this->assertNull($result); | ||
} | ||
|
||
public function testPersistentFake_whenThrowSetToDisk_throwsExceptionOnError() | ||
{ | ||
Config::set('filesystems.disks.test', ['throw' => true]); | ||
|
||
$this->expectException(UnableToReadFile::class); | ||
Storage::persistentFake('test')->get('nonExistentFile'); | ||
} | ||
|
||
public function testPersistentFake_whenThrowOverwritten_usesOverwrite() | ||
{ | ||
Config::set('filesystems.disks.test', ['throw' => true]); | ||
|
||
$result = Storage::persistentFake('test', ['throw' => false])->get('nonExistentFile'); | ||
$this->assertNull($result); | ||
} | ||
} |