File: StorageFacadeTest.php

package info (click to toggle)
php-laravel-framework 11.44.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 22,184 kB
  • sloc: php: 265,914; sh: 167; javascript: 51; makefile: 46
file content (57 lines) | stat: -rw-r--r-- 1,759 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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);
    }
}