Use Storage::fake in tests

This commit is contained in:
Pig Fang 2019-04-03 23:16:23 +08:00
parent 13559e229d
commit d6abaccdf9
9 changed files with 15 additions and 84 deletions

View File

@ -66,7 +66,6 @@ MAIL_PASSWORD = null
CACHE_DRIVER = file CACHE_DRIVER = file
SESSION_DRIVER = file SESSION_DRIVER = file
QUEUE_DRIVER = sync QUEUE_DRIVER = sync
FS_DRIVER = local
REDIS_HOST = 127.0.0.1 REDIS_HOST = 127.0.0.1
REDIS_PASSWORD = null REDIS_PASSWORD = null

View File

@ -28,7 +28,6 @@ MAIL_ENCRYPTION = ssl
CACHE_DRIVER = array CACHE_DRIVER = array
SESSION_DRIVER = array SESSION_DRIVER = array
QUEUE_DRIVER = sync QUEUE_DRIVER = sync
FS_DRIVER = memory
REDIS_HOST = 127.0.0.1 REDIS_HOST = 127.0.0.1
REDIS_PASSWORD = null REDIS_PASSWORD = null

View File

@ -1,23 +0,0 @@
<?php
namespace App\Providers;
use Storage;
use League\Flysystem\Filesystem;
use Illuminate\Support\ServiceProvider;
use League\Flysystem\Memory\MemoryAdapter;
class MemoryServiceProvider extends ServiceProvider
{
public function boot()
{
Storage::extend('memory', function ($app, $config) {
return new Filesystem(new MemoryAdapter());
});
}
public function register()
{
//
}
}

View File

@ -31,7 +31,6 @@
"phpdocumentor/reflection-docblock": "3.2.2", "phpdocumentor/reflection-docblock": "3.2.2",
"phpunit/phpunit": "~7.0", "phpunit/phpunit": "~7.0",
"laravel/browser-kit-testing": "~4.0", "laravel/browser-kit-testing": "~4.0",
"league/flysystem-memory": "^1.0",
"barryvdh/laravel-ide-helper": "^2.6", "barryvdh/laravel-ide-helper": "^2.6",
"laravel/tinker": "^1.0", "laravel/tinker": "^1.0",
"barryvdh/laravel-debugbar": "^3.2" "barryvdh/laravel-debugbar": "^3.2"

63
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "2a99bbb70d29bc4590fd5b3733a4fdef", "content-hash": "5769a880a46dbd1f1eda8eebd2857ddc",
"packages": [ "packages": [
{ {
"name": "composer/semver", "name": "composer/semver",
@ -1081,16 +1081,16 @@
}, },
{ {
"name": "league/flysystem", "name": "league/flysystem",
"version": "1.0.50", "version": "1.0.51",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/thephpleague/flysystem.git", "url": "https://github.com/thephpleague/flysystem.git",
"reference": "dab4e7624efa543a943be978008f439c333f2249" "reference": "755ba7bf3fb9031e6581d091db84d78275874396"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/dab4e7624efa543a943be978008f439c333f2249", "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/755ba7bf3fb9031e6581d091db84d78275874396",
"reference": "dab4e7624efa543a943be978008f439c333f2249", "reference": "755ba7bf3fb9031e6581d091db84d78275874396",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1161,7 +1161,7 @@
"sftp", "sftp",
"storage" "storage"
], ],
"time": "2019-02-01T08:50:36+00:00" "time": "2019-03-30T13:22:34+00:00"
}, },
{ {
"name": "mews/captcha", "name": "mews/captcha",
@ -3996,57 +3996,6 @@
], ],
"time": "2018-10-12T19:39:35+00:00" "time": "2018-10-12T19:39:35+00:00"
}, },
{
"name": "league/flysystem-memory",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem-memory.git",
"reference": "1cabecd08a8caec92a96a953c0d93b5ce83b07a2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem-memory/zipball/1cabecd08a8caec92a96a953c0d93b5ce83b07a2",
"reference": "1cabecd08a8caec92a96a953c0d93b5ce83b07a2",
"shasum": ""
},
"require": {
"league/flysystem": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"League\\Flysystem\\Memory\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Chris Leppanen",
"email": "chris.leppanen@gmail.com",
"role": "Developer"
}
],
"description": "An in-memory adapter for Flysystem.",
"homepage": "https://github.com/thephpleague/flysystem-memory",
"keywords": [
"Flysystem",
"adapter",
"memory"
],
"time": "2016-06-04T03:57:11+00:00"
},
{ {
"name": "maximebf/debugbar", "name": "maximebf/debugbar",
"version": "v1.15.0", "version": "v1.15.0",

View File

@ -179,7 +179,6 @@ return [
App\Providers\AppServiceProvider::class, App\Providers\AppServiceProvider::class,
App\Providers\PluginServiceProvider::class, App\Providers\PluginServiceProvider::class,
App\Providers\EventServiceProvider::class, App\Providers\EventServiceProvider::class,
App\Providers\MemoryServiceProvider::class,
App\Providers\RouteServiceProvider::class, App\Providers\RouteServiceProvider::class,
App\Providers\ResponseMacroServiceProvider::class, App\Providers\ResponseMacroServiceProvider::class,
App\Providers\TranslationServiceProvider::class, App\Providers\TranslationServiceProvider::class,

View File

@ -18,6 +18,7 @@ class CacheAvatarPreviewTest extends TestCase
public function testHandle() public function testHandle()
{ {
Storage::fake('textures');
Event::listen(GetAvatarPreview::class, CacheAvatarPreview::class); Event::listen(GetAvatarPreview::class, CacheAvatarPreview::class);
$texture = factory(Texture::class)->create(); $texture = factory(Texture::class)->create();

View File

@ -18,6 +18,7 @@ class CacheSkinPreviewTest extends TestCase
public function testHandle() public function testHandle()
{ {
Storage::fake('textures');
Event::listen(GetSkinPreview::class, CacheSkinPreview::class); Event::listen(GetSkinPreview::class, CacheSkinPreview::class);
$skin = factory(Texture::class)->create(); $skin = factory(Texture::class)->create();

View File

@ -103,6 +103,7 @@ class TextureControllerTest extends TestCase
public function testTexture() public function testTexture()
{ {
Storage::fake('textures');
$steve = factory(Texture::class)->create(); $steve = factory(Texture::class)->create();
Storage::disk('textures')->put($steve->hash, ''); Storage::disk('textures')->put($steve->hash, '');
$this->get('/textures/nope') $this->get('/textures/nope')
@ -121,6 +122,7 @@ class TextureControllerTest extends TestCase
public function testTextureWithApi() public function testTextureWithApi()
{ {
Storage::fake('textures');
$steve = factory(Texture::class)->create(); $steve = factory(Texture::class)->create();
Storage::disk('textures')->put($steve->hash, ''); Storage::disk('textures')->put($steve->hash, '');
@ -141,6 +143,7 @@ class TextureControllerTest extends TestCase
public function testSkin() public function testSkin()
{ {
Storage::fake('textures');
$skin = factory(Texture::class)->create(); $skin = factory(Texture::class)->create();
$player = factory(Player::class)->create(); $player = factory(Player::class)->create();
@ -184,6 +187,7 @@ class TextureControllerTest extends TestCase
public function testAvatar() public function testAvatar()
{ {
Storage::fake('textures');
$base64_email = base64_encode('a@b.c'); $base64_email = base64_encode('a@b.c');
$this->get("/avatar/$base64_email.png") $this->get("/avatar/$base64_email.png")
->assertHeader('Content-Type', 'image/png'); ->assertHeader('Content-Type', 'image/png');
@ -210,6 +214,7 @@ class TextureControllerTest extends TestCase
public function testAvatarWithSize() public function testAvatarWithSize()
{ {
Storage::fake('textures');
$steve = factory(Texture::class)->create(); $steve = factory(Texture::class)->create();
$png = base64_decode(\App\Http\Controllers\TextureController::getDefaultSteveSkin()); $png = base64_decode(\App\Http\Controllers\TextureController::getDefaultSteveSkin());
Storage::disk('textures')->put($steve->hash, $png); Storage::disk('textures')->put($steve->hash, $png);
@ -228,6 +233,7 @@ class TextureControllerTest extends TestCase
public function testPreview() public function testPreview()
{ {
Storage::fake('textures');
$steve = factory(Texture::class)->create(); $steve = factory(Texture::class)->create();
$cape = factory(Texture::class, 'cape')->create(); $cape = factory(Texture::class, 'cape')->create();
@ -268,6 +274,7 @@ class TextureControllerTest extends TestCase
public function testRaw() public function testRaw()
{ {
Storage::fake('textures');
$steve = factory(Texture::class)->create(); $steve = factory(Texture::class)->create();
Storage::disk('textures')->put($steve->hash, ''); Storage::disk('textures')->put($steve->hash, '');