|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Config\Repository; |
|
6
|
|
|
use Illuminate\Filesystem\FilesystemServiceProvider; |
|
7
|
|
|
use Illuminate\Foundation\Application; |
|
8
|
|
|
use Illuminate\Support\Facades\Facade; |
|
9
|
|
|
use Illuminate\Support\Facades\Storage; |
|
10
|
|
|
use PHPUnit\Framework\TestCase; |
|
11
|
|
|
use Sulao\LaravelFilesystem\BaiduBos\BaiduBosServiceProvider; |
|
12
|
|
|
|
|
13
|
|
|
class ProviderTest extends TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
public function testProvider() |
|
16
|
|
|
{ |
|
17
|
|
|
$app = $this->getApp(); |
|
18
|
|
|
$app->register(BaiduBosServiceProvider::class); |
|
19
|
|
|
$app->boot(); |
|
20
|
|
|
|
|
21
|
|
|
$this->assertTrue( |
|
22
|
|
|
Storage::disk('bos')->put('laravel_bos.txt', 'laravel bos') |
|
23
|
|
|
); |
|
24
|
|
|
|
|
25
|
|
|
$this->assertTrue( |
|
26
|
|
|
Storage::disk('bos2')->exists('laravel_bos.txt') |
|
27
|
|
|
); |
|
28
|
|
|
|
|
29
|
|
|
$this->assertTrue( |
|
30
|
|
|
Storage::delete('laravel_bos.txt') |
|
31
|
|
|
); |
|
32
|
|
|
|
|
33
|
|
|
$this->assertFalse( |
|
34
|
|
|
Storage::disk('bos2')->exists('laravel_bos.txt') |
|
35
|
|
|
); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
protected function getApp() |
|
39
|
|
|
{ |
|
40
|
|
|
$app = new Application(__DIR__); |
|
41
|
|
|
Facade::setFacadeApplication($app); |
|
42
|
|
|
$app->register(FilesystemServiceProvider::class); |
|
43
|
|
|
|
|
44
|
|
|
$filesystems = [ |
|
45
|
|
|
'default' => 'bos', |
|
46
|
|
|
'disks' => [ |
|
47
|
|
|
'bos' => [ |
|
48
|
|
|
'driver' => 'bos', |
|
49
|
|
|
'access_key' => env('BOS_KEY'), |
|
50
|
|
|
'secret_key' => env('BOS_SECRET'), |
|
51
|
|
|
'region' => 'gz', |
|
52
|
|
|
'bucket' => 'xinningsu', |
|
53
|
|
|
], |
|
54
|
|
|
'bos2' => [ |
|
55
|
|
|
'driver' => 'bos', |
|
56
|
|
|
'access_key' => env('BOS_KEY'), |
|
57
|
|
|
'secret_key' => env('BOS_SECRET'), |
|
58
|
|
|
'region' => 'gz', |
|
59
|
|
|
'bucket' => 'xinningsu', |
|
60
|
|
|
'disable_asserts' => false, |
|
61
|
|
|
'case_sensitive' => true, |
|
62
|
|
|
'options' => ['connect_timeout' => 10], |
|
63
|
|
|
], |
|
64
|
|
|
], |
|
65
|
|
|
|
|
66
|
|
|
]; |
|
67
|
|
|
$config = new Repository(); |
|
68
|
|
|
$config->set('filesystems', $filesystems); |
|
69
|
|
|
$app->instance('config', $config); |
|
70
|
|
|
|
|
71
|
|
|
return $app; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|