Use "memory" driver for testing

This commit is contained in:
Pig Fang 2017-11-17 14:00:29 +08:00
parent 6cd5fce271
commit 7d48c6a609
10 changed files with 152 additions and 92 deletions

View File

@ -67,6 +67,7 @@ MAIL_ENCRYPTION = ssl
CACHE_DRIVER = file
SESSION_DRIVER = file
QUEUE_DRIVER = sync
FS_DRIVER = local
REDIS_HOST = 127.0.0.1
REDIS_PASSWORD = null

View File

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

View File

@ -0,0 +1,23 @@
<?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

@ -21,7 +21,8 @@
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*",
"barryvdh/laravel-debugbar": "^2.3"
"barryvdh/laravel-debugbar": "^2.3",
"league/flysystem-memory": "^1.0"
},
"autoload": {
"classmap": [

188
composer.lock generated
View File

@ -4,8 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "ca7b01bddec85ddc69c737deef9d5d4b",
"content-hash": "80623bc8ebd1101cdd3b9ba86629b68c",
"content-hash": "77b253a290c0333475877f10d93e8510",
"packages": [
{
"name": "classpreloader/classpreloader",
@ -59,7 +58,7 @@
"class",
"preload"
],
"time": "2016-09-16 12:50:15"
"time": "2016-09-16T12:50:15+00:00"
},
{
"name": "devitek/yaml-translation",
@ -97,7 +96,7 @@
}
],
"description": "Add YAML file support to Laravel TranslationServiceProvider",
"time": "2016-08-20 17:12:37"
"time": "2016-08-20T17:12:37+00:00"
},
{
"name": "dnoegel/php-xdg-base-dir",
@ -130,7 +129,7 @@
"MIT"
],
"description": "implementation of xdg base directory specification for php",
"time": "2014-10-24 07:27:01"
"time": "2014-10-24T07:27:01+00:00"
},
{
"name": "doctrine/inflector",
@ -142,7 +141,7 @@
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/doctrine/inflector/90b2128806bfde671b6952ab8bea493942c1fdae.zip",
"url": "https://packagist.phpcomposer.com/files/doctrine/inflector/90b2128806bfde671b6952ab8bea493942c1fdae.zip",
"reference": "90b2128806bfde671b6952ab8bea493942c1fdae",
"shasum": ""
},
@ -197,7 +196,7 @@
"singularize",
"string"
],
"time": "2015-11-06 14:35:42"
"time": "2015-11-06T14:35:42+00:00"
},
{
"name": "erusev/parsedown",
@ -239,7 +238,7 @@
"markdown",
"parser"
],
"time": "2017-05-14 14:47:48"
"time": "2017-05-14T14:47:48+00:00"
},
{
"name": "filp/whoops",
@ -300,7 +299,7 @@
"throwable",
"whoops"
],
"time": "2017-10-15 13:05:10"
"time": "2017-10-15T13:05:10+00:00"
},
{
"name": "gregwar/captcha",
@ -348,7 +347,7 @@
"captcha",
"spam"
],
"time": "2017-09-27 06:58:14"
"time": "2017-09-27T06:58:14+00:00"
},
{
"name": "jakub-onderka/php-console-color",
@ -391,7 +390,7 @@
"homepage": "http://www.acci.cz"
}
],
"time": "2014-04-08 15:00:19"
"time": "2014-04-08T15:00:19+00:00"
},
{
"name": "jakub-onderka/php-console-highlighter",
@ -435,7 +434,7 @@
"homepage": "http://www.acci.cz/"
}
],
"time": "2015-04-20 18:58:01"
"time": "2015-04-20T18:58:01+00:00"
},
{
"name": "jeremeamia/SuperClosure",
@ -493,7 +492,7 @@
"serialize",
"tokenizer"
],
"time": "2016-12-07 09:37:55"
"time": "2016-12-07T09:37:55+00:00"
},
{
"name": "laravel/framework",
@ -623,7 +622,7 @@
"framework",
"laravel"
],
"time": "2016-08-26 11:44:52"
"time": "2016-08-26T11:44:52+00:00"
},
{
"name": "league/flysystem",
@ -706,7 +705,7 @@
"sftp",
"storage"
],
"time": "2017-08-06 17:41:04"
"time": "2017-08-06T17:41:04+00:00"
},
{
"name": "league/fractal",
@ -770,7 +769,7 @@
"league",
"rest"
],
"time": "2017-06-12 11:04:56"
"time": "2017-06-12T11:04:56+00:00"
},
{
"name": "monolog/monolog",
@ -848,7 +847,7 @@
"logging",
"psr-3"
],
"time": "2017-06-19 01:22:40"
"time": "2017-06-19T01:22:40+00:00"
},
{
"name": "mtdowling/cron-expression",
@ -892,7 +891,7 @@
"cron",
"schedule"
],
"time": "2017-01-23 04:29:33"
"time": "2017-01-23T04:29:33+00:00"
},
{
"name": "nesbot/carbon",
@ -945,7 +944,7 @@
"datetime",
"time"
],
"time": "2017-01-16 07:55:07"
"time": "2017-01-16T07:55:07+00:00"
},
{
"name": "nikic/php-parser",
@ -996,7 +995,7 @@
"parser",
"php"
],
"time": "2016-09-16 12:04:44"
"time": "2016-09-16T12:04:44+00:00"
},
{
"name": "paragonie/random_compat",
@ -1044,7 +1043,7 @@
"pseudorandom",
"random"
],
"time": "2017-03-13 16:22:52"
"time": "2017-03-13T16:22:52+00:00"
},
{
"name": "predis/predis",
@ -1094,7 +1093,7 @@
"predis",
"redis"
],
"time": "2016-06-16 16:22:20"
"time": "2016-06-16T16:22:20+00:00"
},
{
"name": "printempw/laravel-datatables-lite",
@ -1151,7 +1150,7 @@
"laravel4",
"laravel5"
],
"time": "2017-01-14 09:28:45"
"time": "2017-01-14T09:28:45+00:00"
},
{
"name": "psr/log",
@ -1198,7 +1197,7 @@
"psr",
"psr-3"
],
"time": "2016-10-10 12:19:37"
"time": "2016-10-10T12:19:37+00:00"
},
{
"name": "psy/psysh",
@ -1270,7 +1269,7 @@
"interactive",
"shell"
],
"time": "2016-03-09 05:03:14"
"time": "2016-03-09T05:03:14+00:00"
},
{
"name": "swiftmailer/swiftmailer",
@ -1324,7 +1323,7 @@
"mail",
"mailer"
],
"time": "2017-05-01 15:54:03"
"time": "2017-05-01T15:54:03+00:00"
},
{
"name": "swiggles/memcache",
@ -1375,7 +1374,7 @@
"laravel 5",
"memcache"
],
"time": "2016-12-07 18:25:37"
"time": "2016-12-07T18:25:37+00:00"
},
{
"name": "symfony/console",
@ -1435,7 +1434,7 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2016-07-30 07:22:48"
"time": "2016-07-30T07:22:48+00:00"
},
{
"name": "symfony/debug",
@ -1492,7 +1491,7 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2016-07-30 07:22:48"
"time": "2016-07-30T07:22:48+00:00"
},
{
"name": "symfony/event-dispatcher",
@ -1555,7 +1554,7 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2017-10-02 06:42:24"
"time": "2017-10-02T06:42:24+00:00"
},
{
"name": "symfony/finder",
@ -1604,7 +1603,7 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2016-06-29 05:40:00"
"time": "2016-06-29T05:40:00+00:00"
},
{
"name": "symfony/http-foundation",
@ -1657,7 +1656,7 @@
],
"description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com",
"time": "2016-07-17 13:54:30"
"time": "2016-07-17T13:54:30+00:00"
},
{
"name": "symfony/http-kernel",
@ -1739,7 +1738,7 @@
],
"description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com",
"time": "2016-07-30 09:10:37"
"time": "2016-07-30T09:10:37+00:00"
},
{
"name": "symfony/polyfill-mbstring",
@ -1798,7 +1797,7 @@
"portable",
"shim"
],
"time": "2017-10-11 12:05:26"
"time": "2017-10-11T12:05:26+00:00"
},
{
"name": "symfony/polyfill-php56",
@ -1854,7 +1853,7 @@
"portable",
"shim"
],
"time": "2017-10-11 12:05:26"
"time": "2017-10-11T12:05:26+00:00"
},
{
"name": "symfony/polyfill-util",
@ -1906,7 +1905,7 @@
"polyfill",
"shim"
],
"time": "2017-10-11 12:05:26"
"time": "2017-10-11T12:05:26+00:00"
},
{
"name": "symfony/process",
@ -1955,7 +1954,7 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2016-07-28 11:13:34"
"time": "2016-07-28T11:13:34+00:00"
},
{
"name": "symfony/routing",
@ -2030,7 +2029,7 @@
"uri",
"url"
],
"time": "2016-06-29 05:40:00"
"time": "2016-06-29T05:40:00+00:00"
},
{
"name": "symfony/translation",
@ -2094,7 +2093,7 @@
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
"time": "2016-07-30 07:22:48"
"time": "2016-07-30T07:22:48+00:00"
},
{
"name": "symfony/var-dumper",
@ -2157,7 +2156,7 @@
"debug",
"dump"
],
"time": "2016-07-26 08:03:56"
"time": "2016-07-26T08:03:56+00:00"
},
{
"name": "symfony/yaml",
@ -2212,7 +2211,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2017-10-05 14:43:42"
"time": "2017-10-05T14:43:42+00:00"
},
{
"name": "vlucas/phpdotenv",
@ -2262,7 +2261,7 @@
"env",
"environment"
],
"time": "2016-09-01 10:05:43"
"time": "2016-09-01T10:05:43+00:00"
}
],
"packages-dev": [
@ -2313,7 +2312,7 @@
"profiler",
"webprofiler"
],
"time": "2017-07-21 11:56:48"
"time": "2017-07-21T11:56:48+00:00"
},
{
"name": "doctrine/instantiator",
@ -2367,7 +2366,7 @@
"constructor",
"instantiate"
],
"time": "2015-06-14 21:17:01"
"time": "2015-06-14T21:17:01+00:00"
},
{
"name": "fzaninotto/faker",
@ -2417,7 +2416,7 @@
"faker",
"fixtures"
],
"time": "2017-08-15 16:48:10"
"time": "2017-08-15T16:48:10+00:00"
},
{
"name": "hamcrest/hamcrest-php",
@ -2462,7 +2461,58 @@
"keywords": [
"test"
],
"time": "2015-05-11 14:41:42"
"time": "2015-05-11T14:41:42+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://files.phpcomposer.com/files/thephpleague/flysystem-memory/1cabecd08a8caec92a96a953c0d93b5ce83b07a2.zip",
"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",
@ -2523,7 +2573,7 @@
"debug",
"debugbar"
],
"time": "2017-01-05 08:46:19"
"time": "2017-01-05T08:46:19+00:00"
},
{
"name": "mockery/mockery",
@ -2588,7 +2638,7 @@
"test double",
"testing"
],
"time": "2017-02-28 12:52:32"
"time": "2017-02-28T12:52:32+00:00"
},
{
"name": "phpdocumentor/reflection-common",
@ -2642,7 +2692,7 @@
"reflection",
"static analysis"
],
"time": "2017-09-11 18:02:19"
"time": "2017-09-11T18:02:19+00:00"
},
{
"name": "phpdocumentor/reflection-docblock",
@ -2687,7 +2737,7 @@
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"time": "2017-08-08 06:39:58"
"time": "2017-08-08T06:39:58+00:00"
},
{
"name": "phpdocumentor/type-resolver",
@ -2734,7 +2784,7 @@
"email": "me@mikevanriel.com"
}
],
"time": "2017-06-03 08:32:36"
"time": "2017-06-03T08:32:36+00:00"
},
{
"name": "phpspec/prophecy",
@ -2797,7 +2847,7 @@
"spy",
"stub"
],
"time": "2017-09-04 11:05:03"
"time": "2017-09-04T11:05:03+00:00"
},
{
"name": "phpunit/php-code-coverage",
@ -2859,7 +2909,7 @@
"testing",
"xunit"
],
"time": "2015-10-06 15:47:00"
"time": "2015-10-06T15:47:00+00:00"
},
{
"name": "phpunit/php-file-iterator",
@ -2906,7 +2956,7 @@
"filesystem",
"iterator"
],
"time": "2016-10-03 07:40:28"
"time": "2016-10-03T07:40:28+00:00"
},
{
"name": "phpunit/php-text-template",
@ -2947,7 +2997,7 @@
"keywords": [
"template"
],
"time": "2015-06-21 13:50:34"
"time": "2015-06-21T13:50:34+00:00"
},
{
"name": "phpunit/php-timer",
@ -2996,7 +3046,7 @@
"keywords": [
"timer"
],
"time": "2017-02-26 11:10:40"
"time": "2017-02-26T11:10:40+00:00"
},
{
"name": "phpunit/php-token-stream",
@ -3045,7 +3095,7 @@
"keywords": [
"tokenizer"
],
"time": "2017-02-27 10:12:30"
"time": "2017-02-27T10:12:30+00:00"
},
{
"name": "phpunit/phpunit",
@ -3117,7 +3167,7 @@
"testing",
"xunit"
],
"time": "2017-06-21 08:07:12"
"time": "2017-06-21T08:07:12+00:00"
},
{
"name": "phpunit/phpunit-mock-objects",
@ -3173,7 +3223,7 @@
"mock",
"xunit"
],
"time": "2015-10-02 06:51:40"
"time": "2015-10-02T06:51:40+00:00"
},
{
"name": "sebastian/comparator",
@ -3237,7 +3287,7 @@
"compare",
"equality"
],
"time": "2017-01-29 09:50:25"
"time": "2017-01-29T09:50:25+00:00"
},
{
"name": "sebastian/diff",
@ -3289,7 +3339,7 @@
"keywords": [
"diff"
],
"time": "2017-05-22 07:24:03"
"time": "2017-05-22T07:24:03+00:00"
},
{
"name": "sebastian/environment",
@ -3339,7 +3389,7 @@
"environment",
"hhvm"
],
"time": "2016-08-18 05:49:44"
"time": "2016-08-18T05:49:44+00:00"
},
{
"name": "sebastian/exporter",
@ -3406,7 +3456,7 @@
"export",
"exporter"
],
"time": "2016-06-17 09:04:28"
"time": "2016-06-17T09:04:28+00:00"
},
{
"name": "sebastian/global-state",
@ -3457,7 +3507,7 @@
"keywords": [
"global state"
],
"time": "2015-10-12 03:26:01"
"time": "2015-10-12T03:26:01+00:00"
},
{
"name": "sebastian/recursion-context",
@ -3510,7 +3560,7 @@
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"time": "2016-10-03 07:41:43"
"time": "2016-10-03T07:41:43+00:00"
},
{
"name": "sebastian/version",
@ -3545,7 +3595,7 @@
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
"time": "2015-06-21 13:59:46"
"time": "2015-06-21T13:59:46+00:00"
},
{
"name": "symfony/css-selector",
@ -3598,7 +3648,7 @@
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
"time": "2016-06-29 05:40:00"
"time": "2016-06-29T05:40:00+00:00"
},
{
"name": "symfony/dom-crawler",
@ -3654,7 +3704,7 @@
],
"description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com",
"time": "2016-07-30 07:22:48"
"time": "2016-07-30T07:22:48+00:00"
},
{
"name": "webmozart/assert",
@ -3704,7 +3754,7 @@
"check",
"validate"
],
"time": "2016-11-23 20:04:58"
"time": "2016-11-23T20:04:58+00:00"
}
],
"aliases": [],

View File

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

View File

@ -59,7 +59,7 @@ return [
],
'textures' => [
'driver' => 'local',
'driver' => menv('FS_DRIVER', 'local'),
'root' => storage_path('textures'),
'visibility' => 'public',
],
@ -70,6 +70,10 @@ return [
'visibility' => 'public',
],
'testing' => [
'driver' => 'memory'
],
's3' => [
'driver' => 's3',
'key' => 'your-key',

View File

@ -1,3 +1,2 @@
*
!textures
!.gitignore

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -11,24 +11,6 @@ class TextureControllerTest extends TestCase
{
use DatabaseTransactions;
protected function setUp()
{
parent::setUp();
config(['filesystems.disks.textures.root' => storage_path('testing/textures')]);
}
protected function tearDown()
{
collect(Storage::disk('textures')->files())
->reject(function ($filename) {
return $filename == '.gitignore';
})
->each(function ($filename) {
Storage::disk('textures')->delete($filename);
});
parent::tearDown();
}
public function testJson()
{
$steve = factory(Texture::class)->create();