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
|
|
|
|
34
|
|
|
protected function getApp() |
35
|
|
|
{ |
36
|
|
|
$app = new Application(__DIR__); |
37
|
|
|
Facade::setFacadeApplication($app); |
38
|
|
|
$app->register(FilesystemServiceProvider::class); |
39
|
|
|
|
40
|
|
|
$filesystems = [ |
41
|
|
|
'default' => 'bos', |
42
|
|
|
'disks' => [ |
43
|
|
|
'bos' => [ |
44
|
|
|
'driver' => 'bos', |
45
|
|
|
'access_key' => env('BOS_KEY'), |
46
|
|
|
'secret_key' => env('BOS_SECRET'), |
47
|
|
|
'region' => 'gz', |
48
|
|
|
'bucket' => 'xinningsu', |
49
|
|
|
], |
50
|
|
|
'bos2' => [ |
51
|
|
|
'driver' => 'bos', |
52
|
|
|
'access_key' => env('BOS_KEY'), |
53
|
|
|
'secret_key' => env('BOS_SECRET'), |
54
|
|
|
'region' => 'gz', |
55
|
|
|
'bucket' => 'xinningsu', |
56
|
|
|
'disable_asserts' => false, |
57
|
|
|
'case_sensitive' => true, |
58
|
|
|
'options' => ['connect_timeout' => 10], |
59
|
|
|
], |
60
|
|
|
], |
61
|
|
|
|
62
|
|
|
]; |
63
|
|
|
$config = new Repository(); |
64
|
|
|
$config->set('filesystems', $filesystems); |
65
|
|
|
$app->instance('config', $config); |
66
|
|
|
|
67
|
|
|
return $app; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|