From f503d97ea02b867ce2490256482d8fca04a42a47 Mon Sep 17 00:00:00 2001 From: Oliver Matla Date: Fri, 15 Mar 2024 16:39:41 +0100 Subject: [PATCH] [3.x] Add Laravel 11 Support (#82) * update composer dependencies * drop php 8.1 and Laravel 9, add php 8.3 and Laravel 11 * drop Laravel 10 support: Sanctum 4 will not work with Laravel 10, while Sanctum 3 will not work with Laravel 11. * fix structure test case * remove testing scaffold * add tests to feature folder * add test dump files * add base test case * handle file and resource issues * update phpunit config --- .env | 1 + .github/workflows/tests.yml | 4 +- README.md | 4 +- .../scaffolds/includes-protector/app/.gitkeep | 0 .../includes-protector/app/Console/.gitkeep | 0 .../app/Exceptions/.gitkeep | 0 .../app/Http/Controllers/.gitkeep | 0 .../app/Http/Middleware/.gitkeep | 0 .../includes-protector/app/Models/.gitkeep | 0 .../includes-protector/app/Providers/.gitkeep | 0 .../includes-protector/bootstrap/app.php | 22 -- .../bootstrap/cache/.gitignore | 2 - .../includes-protector/composer.json | 31 --- .../includes-protector/config/app.php | 253 ------------------ .../includes-protector/config/auth.php | 111 -------- .../config/broadcasting.php | 67 ----- .../includes-protector/config/cache.php | 110 -------- .../includes-protector/config/cors.php | 34 --- .../includes-protector/config/database.php | 157 ----------- .../includes-protector/config/filesystems.php | 76 ------ .../includes-protector/config/hashing.php | 52 ---- .../includes-protector/config/logging.php | 122 --------- .../includes-protector/config/mail.php | 118 -------- .../includes-protector/config/protector.php | 108 -------- .../includes-protector/config/queue.php | 93 ------- .../includes-protector/config/services.php | 34 --- .../includes-protector/config/session.php | 201 -------------- .../includes-protector/config/view.php | 36 --- .../includes-protector/database/.gitignore | 1 - .../database/factories/.gitkeep | 0 .../database/migrations/.gitkeep | 0 .../database/seeders/.gitkeep | 0 .../scaffolds/includes-protector/lang/en.json | 7 - .../includes-protector/lang/en/auth.php | 20 -- .../includes-protector/lang/en/pagination.php | 19 -- .../includes-protector/lang/en/passwords.php | 22 -- .../includes-protector/lang/en/validation.php | 169 ------------ ...12_000000_testbench_create_users_table.php | 35 --- ...testbench_create_password_resets_table.php | 31 --- ...000_testbench_create_failed_jobs_table.php | 35 --- .../includes-protector/public/.gitignore | 3 - .../includes-protector/public/index.php | 55 ---- .../resources/views/errors/503.blade.php | 43 --- .../resources/views/welcome.blade.php | 39 --- .../includes-protector/routes/.gitignore | 2 - Tests/scaffolds/includes-protector/server.php | 16 -- .../includes-protector/storage/app/.gitignore | 0 .../storage/app/public/.gitignore | 0 .../storage/framework/.gitignore | 2 - .../storage/framework/cache/.gitignore | 3 - .../storage/framework/data/.gitignore | 2 - .../storage/framework/sessions/.gitignore | 2 - .../storage/framework/testing/.gitignore | 2 - .../storage/framework/views/.gitignore | 2 - .../storage/logs/.gitignore | 2 - composer.json | 14 +- phpunit-ci.xml.dist | 59 ++-- phpunit.xml.dist | 69 +++-- src/Protector.php | 40 ++- Tests/BaseTest.php => tests/TestCase.php | 65 +++-- .../app/protector => tests/dumps}/dump.sql | 0 .../dumps}/dumpWithDifferentConnection.sql | 0 .../protector => tests/dumps}/dumpWithGit.sql | 0 .../dumps}/dumpWithIncorrectMetadata.sql | 0 .../dumps}/dumpWithoutMetadata.sql | 0 .../protector => tests/dumps}/emptyDump.sql | 0 {Tests => tests/feature}/ExceptionTest.php | 6 +- {Tests => tests/feature}/ExportDumpTest.php | 39 +-- .../feature}/ImportDumpCommandTest.php | 33 +-- {Tests => tests/feature}/ImportDumpTest.php | 76 ++---- {Tests => tests/feature}/RemoteDumpTest.php | 10 +- 71 files changed, 193 insertions(+), 2366 deletions(-) delete mode 100644 Tests/scaffolds/includes-protector/app/.gitkeep delete mode 100644 Tests/scaffolds/includes-protector/app/Console/.gitkeep delete mode 100644 Tests/scaffolds/includes-protector/app/Exceptions/.gitkeep delete mode 100644 Tests/scaffolds/includes-protector/app/Http/Controllers/.gitkeep delete mode 100644 Tests/scaffolds/includes-protector/app/Http/Middleware/.gitkeep delete mode 100644 Tests/scaffolds/includes-protector/app/Models/.gitkeep delete mode 100644 Tests/scaffolds/includes-protector/app/Providers/.gitkeep delete mode 100644 Tests/scaffolds/includes-protector/bootstrap/app.php delete mode 100644 Tests/scaffolds/includes-protector/bootstrap/cache/.gitignore delete mode 100644 Tests/scaffolds/includes-protector/composer.json delete mode 100644 Tests/scaffolds/includes-protector/config/app.php delete mode 100644 Tests/scaffolds/includes-protector/config/auth.php delete mode 100644 Tests/scaffolds/includes-protector/config/broadcasting.php delete mode 100644 Tests/scaffolds/includes-protector/config/cache.php delete mode 100644 Tests/scaffolds/includes-protector/config/cors.php delete mode 100644 Tests/scaffolds/includes-protector/config/database.php delete mode 100644 Tests/scaffolds/includes-protector/config/filesystems.php delete mode 100644 Tests/scaffolds/includes-protector/config/hashing.php delete mode 100644 Tests/scaffolds/includes-protector/config/logging.php delete mode 100644 Tests/scaffolds/includes-protector/config/mail.php delete mode 100644 Tests/scaffolds/includes-protector/config/protector.php delete mode 100644 Tests/scaffolds/includes-protector/config/queue.php delete mode 100644 Tests/scaffolds/includes-protector/config/services.php delete mode 100644 Tests/scaffolds/includes-protector/config/session.php delete mode 100644 Tests/scaffolds/includes-protector/config/view.php delete mode 100644 Tests/scaffolds/includes-protector/database/.gitignore delete mode 100644 Tests/scaffolds/includes-protector/database/factories/.gitkeep delete mode 100644 Tests/scaffolds/includes-protector/database/migrations/.gitkeep delete mode 100644 Tests/scaffolds/includes-protector/database/seeders/.gitkeep delete mode 100644 Tests/scaffolds/includes-protector/lang/en.json delete mode 100644 Tests/scaffolds/includes-protector/lang/en/auth.php delete mode 100644 Tests/scaffolds/includes-protector/lang/en/pagination.php delete mode 100644 Tests/scaffolds/includes-protector/lang/en/passwords.php delete mode 100644 Tests/scaffolds/includes-protector/lang/en/validation.php delete mode 100644 Tests/scaffolds/includes-protector/migrations/2014_10_12_000000_testbench_create_users_table.php delete mode 100644 Tests/scaffolds/includes-protector/migrations/2014_10_12_100000_testbench_create_password_resets_table.php delete mode 100644 Tests/scaffolds/includes-protector/migrations/2019_08_19_000000_testbench_create_failed_jobs_table.php delete mode 100644 Tests/scaffolds/includes-protector/public/.gitignore delete mode 100644 Tests/scaffolds/includes-protector/public/index.php delete mode 100644 Tests/scaffolds/includes-protector/resources/views/errors/503.blade.php delete mode 100644 Tests/scaffolds/includes-protector/resources/views/welcome.blade.php delete mode 100644 Tests/scaffolds/includes-protector/routes/.gitignore delete mode 100644 Tests/scaffolds/includes-protector/server.php delete mode 100644 Tests/scaffolds/includes-protector/storage/app/.gitignore delete mode 100644 Tests/scaffolds/includes-protector/storage/app/public/.gitignore delete mode 100644 Tests/scaffolds/includes-protector/storage/framework/.gitignore delete mode 100644 Tests/scaffolds/includes-protector/storage/framework/cache/.gitignore delete mode 100644 Tests/scaffolds/includes-protector/storage/framework/data/.gitignore delete mode 100644 Tests/scaffolds/includes-protector/storage/framework/sessions/.gitignore delete mode 100644 Tests/scaffolds/includes-protector/storage/framework/testing/.gitignore delete mode 100644 Tests/scaffolds/includes-protector/storage/framework/views/.gitignore delete mode 100644 Tests/scaffolds/includes-protector/storage/logs/.gitignore rename Tests/BaseTest.php => tests/TestCase.php (58%) rename {Tests/scaffolds/includes-protector/storage/app/protector => tests/dumps}/dump.sql (100%) rename {Tests/scaffolds/includes-protector/storage/app/protector => tests/dumps}/dumpWithDifferentConnection.sql (100%) rename {Tests/scaffolds/includes-protector/storage/app/protector => tests/dumps}/dumpWithGit.sql (100%) rename {Tests/scaffolds/includes-protector/storage/app/protector => tests/dumps}/dumpWithIncorrectMetadata.sql (100%) rename {Tests/scaffolds/includes-protector/storage/app/protector => tests/dumps}/dumpWithoutMetadata.sql (100%) rename {Tests/scaffolds/includes-protector/storage/app/protector => tests/dumps}/emptyDump.sql (100%) rename {Tests => tests/feature}/ExceptionTest.php (87%) rename {Tests => tests/feature}/ExportDumpTest.php (75%) rename {Tests => tests/feature}/ImportDumpCommandTest.php (85%) rename {Tests => tests/feature}/ImportDumpTest.php (70%) rename {Tests => tests/feature}/RemoteDumpTest.php (98%) diff --git a/.env b/.env index 8c1eb4a2..b872e8d9 100644 --- a/.env +++ b/.env @@ -1,3 +1,4 @@ +# env needed for sail APP_SERVICE=app DB_HOST=laravel-protector-mysql_testing-1 DB_DATABASE=protector_test diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9c08b825..b53b063d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,8 +23,8 @@ jobs: strategy: fail-fast: true matrix: - php: [ 8.1, 8.2 ] - laravel: [ 9.*, 10.* ] + php: [ 8.2, 8.3 ] + laravel: [ 11.* ] dependency-version: [ prefer-stable ] name: PHP ${{ matrix.php }} with Laravel ${{ matrix.laravel }} (${{ matrix.dependency-version }}) diff --git a/README.md b/README.md index 35a444b9..29c7f8b2 100644 --- a/README.md +++ b/README.md @@ -271,9 +271,9 @@ laravel/sanctum ^2.4 in your app to lock its version. Likelihood of impact: low -- Access to the formerly public methods getGitRevision(), getGitHeadDate() or getGitBranch() is now protected. +- Access to the formerly public methods `getGitRevision()`, `getGitHeadDate()` or `getGitBranch()` is now protected. You now need to call getMetaData() and extract the information from the returned array. - + ## Contributing Please see [CONTRIBUTING](CONTRIBUTING.md) for details. diff --git a/Tests/scaffolds/includes-protector/app/.gitkeep b/Tests/scaffolds/includes-protector/app/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Tests/scaffolds/includes-protector/app/Console/.gitkeep b/Tests/scaffolds/includes-protector/app/Console/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Tests/scaffolds/includes-protector/app/Exceptions/.gitkeep b/Tests/scaffolds/includes-protector/app/Exceptions/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Tests/scaffolds/includes-protector/app/Http/Controllers/.gitkeep b/Tests/scaffolds/includes-protector/app/Http/Controllers/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Tests/scaffolds/includes-protector/app/Http/Middleware/.gitkeep b/Tests/scaffolds/includes-protector/app/Http/Middleware/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Tests/scaffolds/includes-protector/app/Models/.gitkeep b/Tests/scaffolds/includes-protector/app/Models/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Tests/scaffolds/includes-protector/app/Providers/.gitkeep b/Tests/scaffolds/includes-protector/app/Providers/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Tests/scaffolds/includes-protector/bootstrap/app.php b/Tests/scaffolds/includes-protector/bootstrap/app.php deleted file mode 100644 index 8fba192b..00000000 --- a/Tests/scaffolds/includes-protector/bootstrap/app.php +++ /dev/null @@ -1,22 +0,0 @@ - ['APP_KEY="' . $APP_KEY . '"', 'DB_CONNECTION="' . $DB_CONNECTION . '"'], 'providers' => []]; - -$app = (new Commander($config, getcwd()))->laravel(); - -unset($APP_KEY, $DB_CONNECTION, $config); - -$router = $app->make('router'); - -collect(glob(__DIR__ . '/../routes/testbench-*.php')) - ->each(function ($routeFile) use ($app, $router) { - require $routeFile; - }); - - -return $app; diff --git a/Tests/scaffolds/includes-protector/bootstrap/cache/.gitignore b/Tests/scaffolds/includes-protector/bootstrap/cache/.gitignore deleted file mode 100644 index d6b7ef32..00000000 --- a/Tests/scaffolds/includes-protector/bootstrap/cache/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/Tests/scaffolds/includes-protector/composer.json b/Tests/scaffolds/includes-protector/composer.json deleted file mode 100644 index b1e6df9c..00000000 --- a/Tests/scaffolds/includes-protector/composer.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "laravel/laravel", - "description": "The Laravel Framework.", - "keywords": [ - "framework", - "laravel" - ], - "license": "MIT", - "type": "project", - "require": { - "laravel/framework": "~5.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "autoload": { - "classmap": [ - "database", - "tests/TestCase.php" - ], - "psr-4": { - "App\\": "app/" - } - }, - "extra": { - "laravel": { - "dont-discover": [] - } - }, - "minimum-stability": "dev" -} diff --git a/Tests/scaffolds/includes-protector/config/app.php b/Tests/scaffolds/includes-protector/config/app.php deleted file mode 100644 index 81e8957b..00000000 --- a/Tests/scaffolds/includes-protector/config/app.php +++ /dev/null @@ -1,253 +0,0 @@ - env('APP_NAME', 'Laravel'), - - /* - |-------------------------------------------------------------------------- - | Application Environment - |-------------------------------------------------------------------------- - | - | This value determines the "environment" your application is currently - | running in. This may determine how you prefer to configure various - | services the application utilizes. Set this in your ".env" file. - | - */ - - 'env' => env('APP_ENV', 'testing'), - - /* - |-------------------------------------------------------------------------- - | Application Debug Mode - |-------------------------------------------------------------------------- - | - | When your application is in debug mode, detailed error messages with - | stack traces will be shown on every error that occurs within your - | application. If disabled, a simple generic error page is shown. - | - */ - - 'debug' => (bool)env('APP_DEBUG', false), - - /* - |-------------------------------------------------------------------------- - | Application URL - |-------------------------------------------------------------------------- - | - | This URL is used by the console to properly generate URLs when using - | the Artisan command line tool. You should set this to the root of - | your application so that it is used when running Artisan tasks. - | - */ - - 'url' => env('APP_URL', 'http://localhost'), - - 'asset_url' => env('ASSET_URL'), - - /* - |-------------------------------------------------------------------------- - | Application Timezone - |-------------------------------------------------------------------------- - | - | Here you may specify the default timezone for your application, which - | will be used by the PHP date and date-time functions. We have gone - | ahead and set this to a sensible default for you out of the box. - | - */ - - 'timezone' => 'UTC', - - /* - |-------------------------------------------------------------------------- - | Application Locale Configuration - |-------------------------------------------------------------------------- - | - | The application locale determines the default locale that will be used - | by the translation service provider. You are free to set this value - | to any of the locales which will be supported by the application. - | - */ - - 'locale' => 'en', - - /* - |-------------------------------------------------------------------------- - | Application Fallback Locale - |-------------------------------------------------------------------------- - | - | The fallback locale determines the locale to use when the current one - | is not available. You may change the value to correspond to any of - | the language folders that are provided through your application. - | - */ - - 'fallback_locale' => 'en', - - /* - |-------------------------------------------------------------------------- - | Faker Locale - |-------------------------------------------------------------------------- - | - | This locale will be used by the Faker PHP library when generating fake - | data for your database seeds. For example, this will be used to get - | localized telephone numbers, street address information and more. - | - */ - - 'faker_locale' => 'en_US', - - /* - |-------------------------------------------------------------------------- - | Encryption Key - |-------------------------------------------------------------------------- - | - | This key is used by the Illuminate encrypter service and should be set - | to a random, 32 character string, otherwise these encrypted strings - | will not be safe. Please do this before deploying an application! - | - */ - - 'key' => env('APP_KEY'), - - 'cipher' => 'AES-256-CBC', - - /* - |-------------------------------------------------------------------------- - | Maintenance Mode Driver - |-------------------------------------------------------------------------- - | - | These configuration options determine the driver used to determine and - | manage Laravel's "maintenance mode" status. The "cache" driver will - | allow maintenance mode to be controlled across multiple machines. - | - | Supported drivers: "file", "cache" - | - */ - - 'maintenance' => [ - 'driver' => 'file', - // 'store' => 'redis', - ], - - /* - |-------------------------------------------------------------------------- - | Autoloaded Service Providers - |-------------------------------------------------------------------------- - | - | The service providers listed here will be automatically loaded on the - | request to your application. Feel free to add your own services to - | this array to grant expanded functionality to your applications. - | - */ - - 'providers' => [ - - /* - * Laravel Framework Service Providers... - */ - Illuminate\Auth\AuthServiceProvider::class, - Illuminate\Broadcasting\BroadcastServiceProvider::class, - Illuminate\Bus\BusServiceProvider::class, - Illuminate\Cache\CacheServiceProvider::class, - Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, - Illuminate\Cookie\CookieServiceProvider::class, - Illuminate\Database\DatabaseServiceProvider::class, - Illuminate\Encryption\EncryptionServiceProvider::class, - Illuminate\Filesystem\FilesystemServiceProvider::class, - Illuminate\Foundation\Providers\FoundationServiceProvider::class, - Illuminate\Hashing\HashServiceProvider::class, - Illuminate\Mail\MailServiceProvider::class, - Illuminate\Notifications\NotificationServiceProvider::class, - Illuminate\Pagination\PaginationServiceProvider::class, - Illuminate\Pipeline\PipelineServiceProvider::class, - Illuminate\Queue\QueueServiceProvider::class, - Illuminate\Redis\RedisServiceProvider::class, - Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, - Illuminate\Session\SessionServiceProvider::class, - Illuminate\Translation\TranslationServiceProvider::class, - Illuminate\Validation\ValidationServiceProvider::class, - Illuminate\View\ViewServiceProvider::class, - - /* - * Package Service Providers... - */ - - /* - * Application Service Providers... - */ - // App\Providers\AppServiceProvider::class, - // App\Providers\AuthServiceProvider::class, - // // App\Providers\BroadcastServiceProvider::class, - // App\Providers\EventServiceProvider::class, - // App\Providers\RouteServiceProvider::class, - - ], - - /* - |-------------------------------------------------------------------------- - | Class Aliases - |-------------------------------------------------------------------------- - | - | This array of class aliases will be registered when this application - | is started. However, feel free to register as many as you wish as - | the aliases are "lazy" loaded so they don't hinder performance. - | - */ - - 'aliases' => [ - - 'App' => Illuminate\Support\Facades\App::class, - 'Arr' => Illuminate\Support\Arr::class, - 'Artisan' => Illuminate\Support\Facades\Artisan::class, - 'Auth' => Illuminate\Support\Facades\Auth::class, - 'Blade' => Illuminate\Support\Facades\Blade::class, - 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, - 'Bus' => Illuminate\Support\Facades\Bus::class, - 'Cache' => Illuminate\Support\Facades\Cache::class, - 'Config' => Illuminate\Support\Facades\Config::class, - 'Cookie' => Illuminate\Support\Facades\Cookie::class, - 'Crypt' => Illuminate\Support\Facades\Crypt::class, - 'Date' => Illuminate\Support\Facades\Date::class, - 'DB' => Illuminate\Support\Facades\DB::class, - 'Eloquent' => Illuminate\Database\Eloquent\Model::class, - 'Event' => Illuminate\Support\Facades\Event::class, - 'File' => Illuminate\Support\Facades\File::class, - 'Gate' => Illuminate\Support\Facades\Gate::class, - 'Hash' => Illuminate\Support\Facades\Hash::class, - 'Http' => Illuminate\Support\Facades\Http::class, - 'Js' => Illuminate\Support\Js::class, - 'Lang' => Illuminate\Support\Facades\Lang::class, - 'Log' => Illuminate\Support\Facades\Log::class, - 'Mail' => Illuminate\Support\Facades\Mail::class, - 'Notification' => Illuminate\Support\Facades\Notification::class, - 'Password' => Illuminate\Support\Facades\Password::class, - 'Queue' => Illuminate\Support\Facades\Queue::class, - 'RateLimiter' => Illuminate\Support\Facades\RateLimiter::class, - 'Redirect' => Illuminate\Support\Facades\Redirect::class, - // 'Redis' => Illuminate\Support\Facades\Redis::class, - 'Request' => Illuminate\Support\Facades\Request::class, - 'Response' => Illuminate\Support\Facades\Response::class, - 'Route' => Illuminate\Support\Facades\Route::class, - 'Schema' => Illuminate\Support\Facades\Schema::class, - 'Session' => Illuminate\Support\Facades\Session::class, - 'Storage' => Illuminate\Support\Facades\Storage::class, - 'Str' => Illuminate\Support\Str::class, - 'URL' => Illuminate\Support\Facades\URL::class, - 'Validator' => Illuminate\Support\Facades\Validator::class, - 'View' => Illuminate\Support\Facades\View::class, - - ], - -]; diff --git a/Tests/scaffolds/includes-protector/config/auth.php b/Tests/scaffolds/includes-protector/config/auth.php deleted file mode 100644 index bbc09ec3..00000000 --- a/Tests/scaffolds/includes-protector/config/auth.php +++ /dev/null @@ -1,111 +0,0 @@ - [ - 'guard' => 'web', - 'passwords' => 'users', - ], - - /* - |-------------------------------------------------------------------------- - | Authentication Guards - |-------------------------------------------------------------------------- - | - | Next, you may define every authentication guard for your application. - | Of course, a great default configuration has been defined for you - | here which uses session storage and the Eloquent user provider. - | - | All authentication drivers have a user provider. This defines how the - | users are actually retrieved out of your database or other storage - | mechanisms used by this application to persist your user's data. - | - | Supported: "session" - | - */ - - 'guards' => [ - 'web' => [ - 'driver' => 'session', - 'provider' => 'users', - ], - ], - - /* - |-------------------------------------------------------------------------- - | User Providers - |-------------------------------------------------------------------------- - | - | All authentication drivers have a user provider. This defines how the - | users are actually retrieved out of your database or other storage - | mechanisms used by this application to persist your user's data. - | - | If you have multiple user tables or models you may configure multiple - | sources which represent each model / table. These sources may then - | be assigned to any extra authentication guards you have defined. - | - | Supported: "database", "eloquent" - | - */ - - 'providers' => [ - 'users' => [ - 'driver' => 'eloquent', - 'model' => Illuminate\Foundation\Auth\User::class, - ], - - // 'users' => [ - // 'driver' => 'database', - // 'table' => 'users', - // ], - ], - - /* - |-------------------------------------------------------------------------- - | Resetting Passwords - |-------------------------------------------------------------------------- - | - | You may specify multiple password reset configurations if you have more - | than one user table or model in the application and you want to have - | separate password reset settings based on the specific user types. - | - | The expire time is the number of minutes that each reset token will be - | considered valid. This security feature keeps tokens short-lived so - | they have less time to be guessed. You may change this as needed. - | - */ - - 'passwords' => [ - 'users' => [ - 'provider' => 'users', - 'table' => 'password_resets', - 'expire' => 60, - 'throttle' => 60, - ], - ], - - /* - |-------------------------------------------------------------------------- - | Password Confirmation Timeout - |-------------------------------------------------------------------------- - | - | Here you may define the amount of seconds before a password confirmation - | times out and the user is prompted to re-enter their password via the - | confirmation screen. By default, the timeout lasts for three hours. - | - */ - - 'password_timeout' => 10800, - -]; diff --git a/Tests/scaffolds/includes-protector/config/broadcasting.php b/Tests/scaffolds/includes-protector/config/broadcasting.php deleted file mode 100644 index 67fcbbd6..00000000 --- a/Tests/scaffolds/includes-protector/config/broadcasting.php +++ /dev/null @@ -1,67 +0,0 @@ - env('BROADCAST_DRIVER', 'null'), - - /* - |-------------------------------------------------------------------------- - | Broadcast Connections - |-------------------------------------------------------------------------- - | - | Here you may define all of the broadcast connections that will be used - | to broadcast events to other systems or over websockets. Samples of - | each available type of connection are provided inside this array. - | - */ - - 'connections' => [ - - 'pusher' => [ - 'driver' => 'pusher', - 'key' => env('PUSHER_APP_KEY'), - 'secret' => env('PUSHER_APP_SECRET'), - 'app_id' => env('PUSHER_APP_ID'), - 'options' => [ - 'cluster' => env('PUSHER_APP_CLUSTER'), - 'useTLS' => true, - ], - 'client_options' => [ - // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html - ], - ], - - 'ably' => [ - 'driver' => 'ably', - 'key' => env('ABLY_KEY'), - ], - - 'redis' => [ - 'driver' => 'redis', - 'connection' => 'default', - ], - - 'log' => [ - 'driver' => 'log', - ], - - 'null' => [ - 'driver' => 'null', - ], - - ], - -]; diff --git a/Tests/scaffolds/includes-protector/config/cache.php b/Tests/scaffolds/includes-protector/config/cache.php deleted file mode 100644 index 84b7d660..00000000 --- a/Tests/scaffolds/includes-protector/config/cache.php +++ /dev/null @@ -1,110 +0,0 @@ - env('CACHE_DRIVER', 'array'), - - /* - |-------------------------------------------------------------------------- - | Cache Stores - |-------------------------------------------------------------------------- - | - | Here you may define all of the cache "stores" for your application as - | well as their drivers. You may even define multiple stores for the - | same cache driver to group types of items stored in your caches. - | - | Supported drivers: "apc", "array", "database", "file", - | "memcached", "redis", "dynamodb", "octane", "null" - | - */ - - 'stores' => [ - - 'apc' => [ - 'driver' => 'apc', - ], - - 'array' => [ - 'driver' => 'array', - 'serialize' => false, - ], - - 'database' => [ - 'driver' => 'database', - 'table' => 'cache', - 'connection' => null, - 'lock_connection' => null, - ], - - 'file' => [ - 'driver' => 'file', - 'path' => storage_path('framework/cache/data'), - ], - - 'memcached' => [ - 'driver' => 'memcached', - 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), - 'sasl' => [ - env('MEMCACHED_USERNAME'), - env('MEMCACHED_PASSWORD'), - ], - 'options' => [ - // Memcached::OPT_CONNECT_TIMEOUT => 2000, - ], - 'servers' => [ - [ - 'host' => env('MEMCACHED_HOST', '127.0.0.1'), - 'port' => env('MEMCACHED_PORT', 11211), - 'weight' => 100, - ], - ], - ], - - 'redis' => [ - 'driver' => 'redis', - 'connection' => 'cache', - 'lock_connection' => 'default', - ], - - 'dynamodb' => [ - 'driver' => 'dynamodb', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), - 'endpoint' => env('DYNAMODB_ENDPOINT'), - ], - - 'octane' => [ - 'driver' => 'octane', - ], - - ], - - /* - |-------------------------------------------------------------------------- - | Cache Key Prefix - |-------------------------------------------------------------------------- - | - | When utilizing the APC, database, memcached, Redis, or DynamoDB cache - | stores there might be other applications using the same cache. For - | that reason, you may prefix every cache key to avoid collisions. - | - */ - - 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache_'), - -]; diff --git a/Tests/scaffolds/includes-protector/config/cors.php b/Tests/scaffolds/includes-protector/config/cors.php deleted file mode 100644 index 8a39e6da..00000000 --- a/Tests/scaffolds/includes-protector/config/cors.php +++ /dev/null @@ -1,34 +0,0 @@ - ['api/*', 'sanctum/csrf-cookie'], - - 'allowed_methods' => ['*'], - - 'allowed_origins' => ['*'], - - 'allowed_origins_patterns' => [], - - 'allowed_headers' => ['*'], - - 'exposed_headers' => [], - - 'max_age' => 0, - - 'supports_credentials' => false, - -]; diff --git a/Tests/scaffolds/includes-protector/config/database.php b/Tests/scaffolds/includes-protector/config/database.php deleted file mode 100644 index ad5cba23..00000000 --- a/Tests/scaffolds/includes-protector/config/database.php +++ /dev/null @@ -1,157 +0,0 @@ - env('DB_CONNECTION', 'mysql'), - - /* - |-------------------------------------------------------------------------- - | Database Connections - |-------------------------------------------------------------------------- - | - | Here are each of the database connections setup for your application. - | Of course, examples of configuring each database platform that is - | supported by Laravel is shown below to make development simple. - | - | - | All database work in Laravel is done through the PHP PDO facilities - | so make sure you have the driver for your particular database of - | choice installed on your machine before you begin development. - | - */ - - 'connections' => [ - - 'testing' => [ - 'driver' => 'sqlite', - 'database' => ':memory:', - 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', false), - ], - - 'sqlite' => [ - 'driver' => 'sqlite', - 'url' => env('DATABASE_URL'), - 'database' => env('DB_DATABASE', database_path('database.sqlite')), - 'prefix' => '', - 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), - ], - - 'mysql' => [ - 'driver' => 'mysql', - 'url' => env('DATABASE_URL'), - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '3306'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'unix_socket' => env('DB_SOCKET', ''), - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'prefix' => '', - 'prefix_indexes' => true, - 'strict' => true, - 'engine' => null, - 'options' => extension_loaded('pdo_mysql') ? array_filter([ - PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), - ]) : [], - ], - - 'pgsql' => [ - 'driver' => 'pgsql', - 'url' => env('DATABASE_URL'), - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '5432'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'prefix' => '', - 'prefix_indexes' => true, - 'search_path' => 'public', - 'sslmode' => 'prefer', - ], - - 'sqlsrv' => [ - 'driver' => 'sqlsrv', - 'url' => env('DATABASE_URL'), - 'host' => env('DB_HOST', 'localhost'), - 'port' => env('DB_PORT', '1433'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'prefix' => '', - 'prefix_indexes' => true, - // 'encrypt' => env('DB_ENCRYPT', 'yes'), - // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'), - ], - - ], - - /* - |-------------------------------------------------------------------------- - | Migration Repository Table - |-------------------------------------------------------------------------- - | - | This table keeps track of all the migrations that have already run for - | your application. Using this information, we can determine which of - | the migrations on disk haven't actually been run in the database. - | - */ - - 'migrations' => 'migrations', - - /* - |-------------------------------------------------------------------------- - | Redis Databases - |-------------------------------------------------------------------------- - | - | Redis is an open source, fast, and advanced key-value store that also - | provides a richer body of commands than a typical key-value system - | such as APC or Memcached. Laravel makes it easy to dig right in. - | - */ - - 'redis' => [ - - 'client' => env('REDIS_CLIENT', 'phpredis'), - - 'options' => [ - 'cluster' => env('REDIS_CLUSTER', 'redis'), - 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'), - ], - - 'default' => [ - 'url' => env('REDIS_URL'), - 'host' => env('REDIS_HOST', '127.0.0.1'), - 'username' => env('REDIS_USERNAME'), - 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), - 'database' => env('REDIS_DB', '0'), - ], - - 'cache' => [ - 'url' => env('REDIS_URL'), - 'host' => env('REDIS_HOST', '127.0.0.1'), - 'username' => env('REDIS_USERNAME'), - 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), - 'database' => env('REDIS_CACHE_DB', '1'), - ], - - ], - -]; diff --git a/Tests/scaffolds/includes-protector/config/filesystems.php b/Tests/scaffolds/includes-protector/config/filesystems.php deleted file mode 100644 index 4afc1fc6..00000000 --- a/Tests/scaffolds/includes-protector/config/filesystems.php +++ /dev/null @@ -1,76 +0,0 @@ - env('FILESYSTEM_DISK', 'local'), - - /* - |-------------------------------------------------------------------------- - | Filesystem Disks - |-------------------------------------------------------------------------- - | - | Here you may configure as many filesystem "disks" as you wish, and you - | may even configure multiple disks of the same driver. Defaults have - | been set up for each driver as an example of the required values. - | - | Supported Drivers: "local", "ftp", "sftp", "s3" - | - */ - - 'disks' => [ - - 'local' => [ - 'driver' => 'local', - 'root' => storage_path('app'), - 'throw' => false, - ], - - 'public' => [ - 'driver' => 'local', - 'root' => storage_path('app/public'), - 'url' => env('APP_URL') . '/storage', - 'visibility' => 'public', - 'throw' => false, - ], - - 's3' => [ - 'driver' => 's3', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'region' => env('AWS_DEFAULT_REGION'), - 'bucket' => env('AWS_BUCKET'), - 'url' => env('AWS_URL'), - 'endpoint' => env('AWS_ENDPOINT'), - 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), - 'throw' => false, - ], - - ], - - /* - |-------------------------------------------------------------------------- - | Symbolic Links - |-------------------------------------------------------------------------- - | - | Here you may configure the symbolic links that will be created when the - | `storage:link` Artisan command is executed. The array keys should be - | the locations of the links and the values should be their targets. - | - */ - - 'links' => [ - public_path('storage') => storage_path('app/public'), - ], - -]; diff --git a/Tests/scaffolds/includes-protector/config/hashing.php b/Tests/scaffolds/includes-protector/config/hashing.php deleted file mode 100644 index bcd3be4c..00000000 --- a/Tests/scaffolds/includes-protector/config/hashing.php +++ /dev/null @@ -1,52 +0,0 @@ - 'bcrypt', - - /* - |-------------------------------------------------------------------------- - | Bcrypt Options - |-------------------------------------------------------------------------- - | - | Here you may specify the configuration options that should be used when - | passwords are hashed using the Bcrypt algorithm. This will allow you - | to control the amount of time it takes to hash the given password. - | - */ - - 'bcrypt' => [ - 'rounds' => env('BCRYPT_ROUNDS', 10), - ], - - /* - |-------------------------------------------------------------------------- - | Argon Options - |-------------------------------------------------------------------------- - | - | Here you may specify the configuration options that should be used when - | passwords are hashed using the Argon algorithm. These will allow you - | to control the amount of time it takes to hash the given password. - | - */ - - 'argon' => [ - 'memory' => 65536, - 'threads' => 1, - 'time' => 4, - ], - -]; diff --git a/Tests/scaffolds/includes-protector/config/logging.php b/Tests/scaffolds/includes-protector/config/logging.php deleted file mode 100644 index 752af711..00000000 --- a/Tests/scaffolds/includes-protector/config/logging.php +++ /dev/null @@ -1,122 +0,0 @@ - env('LOG_CHANNEL', 'stack'), - - /* - |-------------------------------------------------------------------------- - | Deprecations Log Channel - |-------------------------------------------------------------------------- - | - | This option controls the log channel that should be used to log warnings - | regarding deprecated PHP and library features. This allows you to get - | your application ready for upcoming major versions of dependencies. - | - */ - - 'deprecations' => [ - 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), - 'trace' => false, - ], - - /* - |-------------------------------------------------------------------------- - | Log Channels - |-------------------------------------------------------------------------- - | - | Here you may configure the log channels for your application. Out of - | the box, Laravel uses the Monolog PHP logging library. This gives - | you a variety of powerful log handlers / formatters to utilize. - | - | Available Drivers: "single", "daily", "slack", "syslog", - | "errorlog", "monolog", - | "custom", "stack" - | - */ - - 'channels' => [ - 'stack' => [ - 'driver' => 'stack', - 'channels' => ['single'], - 'ignore_exceptions' => false, - ], - - 'single' => [ - 'driver' => 'single', - 'path' => storage_path('logs/laravel.log'), - 'level' => env('LOG_LEVEL', 'debug'), - ], - - 'daily' => [ - 'driver' => 'daily', - 'path' => storage_path('logs/laravel.log'), - 'level' => env('LOG_LEVEL', 'debug'), - 'days' => 14, - ], - - 'slack' => [ - 'driver' => 'slack', - 'url' => env('LOG_SLACK_WEBHOOK_URL'), - 'username' => 'Laravel Log', - 'emoji' => ':boom:', - 'level' => env('LOG_LEVEL', 'critical'), - ], - - 'papertrail' => [ - 'driver' => 'monolog', - 'level' => env('LOG_LEVEL', 'debug'), - 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class), - 'handler_with' => [ - 'host' => env('PAPERTRAIL_URL'), - 'port' => env('PAPERTRAIL_PORT'), - 'connectionString' => 'tls://' . env('PAPERTRAIL_URL') . ':' . env('PAPERTRAIL_PORT'), - ], - ], - - 'stderr' => [ - 'driver' => 'monolog', - 'level' => env('LOG_LEVEL', 'debug'), - 'handler' => StreamHandler::class, - 'formatter' => env('LOG_STDERR_FORMATTER'), - 'with' => [ - 'stream' => 'php://stderr', - ], - ], - - 'syslog' => [ - 'driver' => 'syslog', - 'level' => env('LOG_LEVEL', 'debug'), - ], - - 'errorlog' => [ - 'driver' => 'errorlog', - 'level' => env('LOG_LEVEL', 'debug'), - ], - - 'null' => [ - 'driver' => 'monolog', - 'handler' => NullHandler::class, - ], - - 'emergency' => [ - 'path' => storage_path('logs/laravel.log'), - ], - ], - -]; diff --git a/Tests/scaffolds/includes-protector/config/mail.php b/Tests/scaffolds/includes-protector/config/mail.php deleted file mode 100644 index 534395a3..00000000 --- a/Tests/scaffolds/includes-protector/config/mail.php +++ /dev/null @@ -1,118 +0,0 @@ - env('MAIL_MAILER', 'smtp'), - - /* - |-------------------------------------------------------------------------- - | Mailer Configurations - |-------------------------------------------------------------------------- - | - | Here you may configure all of the mailers used by your application plus - | their respective settings. Several examples have been configured for - | you and you are free to add your own as your application requires. - | - | Laravel supports a variety of mail "transport" drivers to be used while - | sending an e-mail. You will specify which one you are using for your - | mailers below. You are free to add additional mailers as required. - | - | Supported: "smtp", "sendmail", "mailgun", "ses", - | "postmark", "log", "array", "failover" - | - */ - - 'mailers' => [ - 'smtp' => [ - 'transport' => 'smtp', - 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), - 'port' => env('MAIL_PORT', 587), - 'encryption' => env('MAIL_ENCRYPTION', 'tls'), - 'username' => env('MAIL_USERNAME'), - 'password' => env('MAIL_PASSWORD'), - 'timeout' => null, - 'local_domain' => env('MAIL_EHLO_DOMAIN'), - ], - - 'ses' => [ - 'transport' => 'ses', - ], - - 'mailgun' => [ - 'transport' => 'mailgun', - ], - - 'postmark' => [ - 'transport' => 'postmark', - ], - - 'sendmail' => [ - 'transport' => 'sendmail', - 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'), - ], - - 'log' => [ - 'transport' => 'log', - 'channel' => env('MAIL_LOG_CHANNEL'), - ], - - 'array' => [ - 'transport' => 'array', - ], - - 'failover' => [ - 'transport' => 'failover', - 'mailers' => [ - 'smtp', - 'log', - ], - ], - ], - - /* - |-------------------------------------------------------------------------- - | Global "From" Address - |-------------------------------------------------------------------------- - | - | You may wish for all e-mails sent by your application to be sent from - | the same address. Here, you may specify a name and address that is - | used globally for all e-mails that are sent by your application. - | - */ - - 'from' => [ - 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), - 'name' => env('MAIL_FROM_NAME', 'Example'), - ], - - /* - |-------------------------------------------------------------------------- - | Markdown Mail Settings - |-------------------------------------------------------------------------- - | - | If you are using Markdown based email rendering, you may configure your - | theme and component paths here, allowing you to customize the design - | of the emails. Or, you may simply stick with the Laravel defaults! - | - */ - - 'markdown' => [ - 'theme' => 'default', - - 'paths' => [ - resource_path('views/vendor/mail'), - ], - ], - -]; diff --git a/Tests/scaffolds/includes-protector/config/protector.php b/Tests/scaffolds/includes-protector/config/protector.php deleted file mode 100644 index ea059493..00000000 --- a/Tests/scaffolds/includes-protector/config/protector.php +++ /dev/null @@ -1,108 +0,0 @@ - '%1$s %4$4d-%5$02d-%6$02d %7$02d-%8$02d %9$s.sql', - - /* - |-------------------------------------------------------------------------- - | Maximum Packet Length - |-------------------------------------------------------------------------- - | - | Here you may customize the maximum packet length for the MySQL-Dump. - | - */ - 'maxPacketLength' => '8M', - - /* - |-------------------------------------------------------------------------- - | Disk Configuration - |-------------------------------------------------------------------------- - | - | Here you may customize the base directory and the disk. - | By default the default filesystem disk stated in your filesystems-config will be used. - | - */ - 'baseDirectory' => 'protector', - // 'diskName' => 'protector', - - /* - |-------------------------------------------------------------------------- - | Remote Download Configuration - |-------------------------------------------------------------------------- - | - | Here you may configure the remote endpoint for downloading the dump. - | - */ - 'remoteEndpoint' => [ - 'serverUrl' => 'protector.invalid/protector/exportDump', - // Htaccess may only be used without Laravel Sanctum or basic auth has to be added to the server URL. - 'htaccessLogin' => '', - ], - - /* - |-------------------------------------------------------------------------- - | Dump Endpoint Route - |-------------------------------------------------------------------------- - | - | Here you may customize the route for the dump endpoint. - | - */ - 'dumpEndpointRoute' => '/protector/exportDump', - - /* - |-------------------------------------------------------------------------- - | Route Middleware - |-------------------------------------------------------------------------- - | - | Here you may customize middleware that will be applied. - | By default the auth:sanctum middleware is active and prevents the dump API from being public! - | - */ - 'routeMiddleware' => [ - 'auth:sanctum', - ], - - /* - |-------------------------------------------------------------------------- - | Chunk Size - |-------------------------------------------------------------------------- - | - | Here you may customize the chunk size used when streaming the database dump from the server. - | When Laravel Sanctum is active, this chunk size will also apply to the encryption and decryption. - | By default the chunk size is set to 20MB. - | - */ - 'chunkSize' => 20 * 1024 * 1024 -]; diff --git a/Tests/scaffolds/includes-protector/config/queue.php b/Tests/scaffolds/includes-protector/config/queue.php deleted file mode 100644 index 25ea5a81..00000000 --- a/Tests/scaffolds/includes-protector/config/queue.php +++ /dev/null @@ -1,93 +0,0 @@ - env('QUEUE_CONNECTION', 'sync'), - - /* - |-------------------------------------------------------------------------- - | Queue Connections - |-------------------------------------------------------------------------- - | - | Here you may configure the connection information for each server that - | is used by your application. A default configuration has been added - | for each back-end shipped with Laravel. You are free to add more. - | - | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" - | - */ - - 'connections' => [ - - 'sync' => [ - 'driver' => 'sync', - ], - - 'database' => [ - 'driver' => 'database', - 'table' => 'jobs', - 'queue' => 'default', - 'retry_after' => 90, - 'after_commit' => false, - ], - - 'beanstalkd' => [ - 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', - 'retry_after' => 90, - 'block_for' => 0, - 'after_commit' => false, - ], - - 'sqs' => [ - 'driver' => 'sqs', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), - 'queue' => env('SQS_QUEUE', 'default'), - 'suffix' => env('SQS_SUFFIX'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'after_commit' => false, - ], - - 'redis' => [ - 'driver' => 'redis', - 'connection' => 'default', - 'queue' => env('REDIS_QUEUE', 'default'), - 'retry_after' => 90, - 'block_for' => null, - 'after_commit' => false, - ], - - ], - - /* - |-------------------------------------------------------------------------- - | Failed Queue Jobs - |-------------------------------------------------------------------------- - | - | These options configure the behavior of failed queue job logging so you - | can control which database and table are used to store the jobs that - | have failed. You may change them to any database / table you wish. - | - */ - - 'failed' => [ - 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), - 'database' => env('DB_CONNECTION', 'mysql'), - 'table' => 'failed_jobs', - ], - -]; diff --git a/Tests/scaffolds/includes-protector/config/services.php b/Tests/scaffolds/includes-protector/config/services.php deleted file mode 100644 index 0ace530e..00000000 --- a/Tests/scaffolds/includes-protector/config/services.php +++ /dev/null @@ -1,34 +0,0 @@ - [ - 'domain' => env('MAILGUN_DOMAIN'), - 'secret' => env('MAILGUN_SECRET'), - 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), - 'scheme' => 'https', - ], - - 'postmark' => [ - 'token' => env('POSTMARK_TOKEN'), - ], - - 'ses' => [ - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - ], - -]; diff --git a/Tests/scaffolds/includes-protector/config/session.php b/Tests/scaffolds/includes-protector/config/session.php deleted file mode 100644 index 5a904929..00000000 --- a/Tests/scaffolds/includes-protector/config/session.php +++ /dev/null @@ -1,201 +0,0 @@ - env('SESSION_DRIVER', 'array'), - - /* - |-------------------------------------------------------------------------- - | Session Lifetime - |-------------------------------------------------------------------------- - | - | Here you may specify the number of minutes that you wish the session - | to be allowed to remain idle before it expires. If you want them - | to immediately expire on the browser closing, set that option. - | - */ - - 'lifetime' => env('SESSION_LIFETIME', 120), - - 'expire_on_close' => false, - - /* - |-------------------------------------------------------------------------- - | Session Encryption - |-------------------------------------------------------------------------- - | - | This option allows you to easily specify that all of your session data - | should be encrypted before it is stored. All encryption will be run - | automatically by Laravel and you can use the Session like normal. - | - */ - - 'encrypt' => false, - - /* - |-------------------------------------------------------------------------- - | Session File Location - |-------------------------------------------------------------------------- - | - | When using the native session driver, we need a location where session - | files may be stored. A default has been set for you but a different - | location may be specified. This is only needed for file sessions. - | - */ - - 'files' => storage_path('framework/sessions'), - - /* - |-------------------------------------------------------------------------- - | Session Database Connection - |-------------------------------------------------------------------------- - | - | When using the "database" or "redis" session drivers, you may specify a - | connection that should be used to manage these sessions. This should - | correspond to a connection in your database configuration options. - | - */ - - 'connection' => env('SESSION_CONNECTION'), - - /* - |-------------------------------------------------------------------------- - | Session Database Table - |-------------------------------------------------------------------------- - | - | When using the "database" session driver, you may specify the table we - | should use to manage the sessions. Of course, a sensible default is - | provided for you; however, you are free to change this as needed. - | - */ - - 'table' => 'sessions', - - /* - |-------------------------------------------------------------------------- - | Session Cache Store - |-------------------------------------------------------------------------- - | - | While using one of the framework's cache driven session backends you may - | list a cache store that should be used for these sessions. This value - | must match with one of the application's configured cache "stores". - | - | Affects: "apc", "dynamodb", "memcached", "redis" - | - */ - - 'store' => env('SESSION_STORE'), - - /* - |-------------------------------------------------------------------------- - | Session Sweeping Lottery - |-------------------------------------------------------------------------- - | - | Some session drivers must manually sweep their storage location to get - | rid of old sessions from storage. Here are the chances that it will - | happen on a given request. By default, the odds are 2 out of 100. - | - */ - - 'lottery' => [2, 100], - - /* - |-------------------------------------------------------------------------- - | Session Cookie Name - |-------------------------------------------------------------------------- - | - | Here you may change the name of the cookie used to identify a session - | instance by ID. The name specified here will get used every time a - | new session cookie is created by the framework for every driver. - | - */ - - 'cookie' => env( - 'SESSION_COOKIE', - Str::slug(env('APP_NAME', 'laravel'), '_') . '_session' - ), - - /* - |-------------------------------------------------------------------------- - | Session Cookie Path - |-------------------------------------------------------------------------- - | - | The session cookie path determines the path for which the cookie will - | be regarded as available. Typically, this will be the root path of - | your application but you are free to change this when necessary. - | - */ - - 'path' => '/', - - /* - |-------------------------------------------------------------------------- - | Session Cookie Domain - |-------------------------------------------------------------------------- - | - | Here you may change the domain of the cookie used to identify a session - | in your application. This will determine which domains the cookie is - | available to in your application. A sensible default has been set. - | - */ - - 'domain' => env('SESSION_DOMAIN'), - - /* - |-------------------------------------------------------------------------- - | HTTPS Only Cookies - |-------------------------------------------------------------------------- - | - | By setting this option to true, session cookies will only be sent back - | to the server if the browser has a HTTPS connection. This will keep - | the cookie from being sent to you when it can't be done securely. - | - */ - - 'secure' => env('SESSION_SECURE_COOKIE'), - - /* - |-------------------------------------------------------------------------- - | HTTP Access Only - |-------------------------------------------------------------------------- - | - | Setting this value to true will prevent JavaScript from accessing the - | value of the cookie and the cookie will only be accessible through - | the HTTP protocol. You are free to modify this option if needed. - | - */ - - 'http_only' => true, - - /* - |-------------------------------------------------------------------------- - | Same-Site Cookies - |-------------------------------------------------------------------------- - | - | This option determines how your cookies behave when cross-site requests - | take place, and can be used to mitigate CSRF attacks. By default, we - | will set this value to "lax" since this is a secure default value. - | - | Supported: "lax", "strict", "none", null - | - */ - - 'same_site' => 'lax', - -]; diff --git a/Tests/scaffolds/includes-protector/config/view.php b/Tests/scaffolds/includes-protector/config/view.php deleted file mode 100644 index 22b8a18d..00000000 --- a/Tests/scaffolds/includes-protector/config/view.php +++ /dev/null @@ -1,36 +0,0 @@ - [ - resource_path('views'), - ], - - /* - |-------------------------------------------------------------------------- - | Compiled View Path - |-------------------------------------------------------------------------- - | - | This option determines where all the compiled Blade templates will be - | stored for your application. Typically, this is within the storage - | directory. However, as usual, you are free to change this value. - | - */ - - 'compiled' => env( - 'VIEW_COMPILED_PATH', - realpath(storage_path('framework/views')) - ), - -]; diff --git a/Tests/scaffolds/includes-protector/database/.gitignore b/Tests/scaffolds/includes-protector/database/.gitignore deleted file mode 100644 index 9b19b93c..00000000 --- a/Tests/scaffolds/includes-protector/database/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.sqlite* diff --git a/Tests/scaffolds/includes-protector/database/factories/.gitkeep b/Tests/scaffolds/includes-protector/database/factories/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Tests/scaffolds/includes-protector/database/migrations/.gitkeep b/Tests/scaffolds/includes-protector/database/migrations/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Tests/scaffolds/includes-protector/database/seeders/.gitkeep b/Tests/scaffolds/includes-protector/database/seeders/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Tests/scaffolds/includes-protector/lang/en.json b/Tests/scaffolds/includes-protector/lang/en.json deleted file mode 100644 index 577680dd..00000000 --- a/Tests/scaffolds/includes-protector/lang/en.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "The :attribute must contain at least one letter.": "The :attribute must contain at least one letter.", - "The :attribute must contain at least one number.": "The :attribute must contain at least one number.", - "The :attribute must contain at least one symbol.": "The :attribute must contain at least one symbol.", - "The :attribute must contain at least one uppercase and one lowercase letter.": "The :attribute must contain at least one uppercase and one lowercase letter.", - "The given :attribute has appeared in a data leak. Please choose a different :attribute.": "The given :attribute has appeared in a data leak. Please choose a different :attribute." -} diff --git a/Tests/scaffolds/includes-protector/lang/en/auth.php b/Tests/scaffolds/includes-protector/lang/en/auth.php deleted file mode 100644 index 6598e2c0..00000000 --- a/Tests/scaffolds/includes-protector/lang/en/auth.php +++ /dev/null @@ -1,20 +0,0 @@ - 'These credentials do not match our records.', - 'password' => 'The provided password is incorrect.', - 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', - -]; diff --git a/Tests/scaffolds/includes-protector/lang/en/pagination.php b/Tests/scaffolds/includes-protector/lang/en/pagination.php deleted file mode 100644 index d4814118..00000000 --- a/Tests/scaffolds/includes-protector/lang/en/pagination.php +++ /dev/null @@ -1,19 +0,0 @@ - '« Previous', - 'next' => 'Next »', - -]; diff --git a/Tests/scaffolds/includes-protector/lang/en/passwords.php b/Tests/scaffolds/includes-protector/lang/en/passwords.php deleted file mode 100644 index 2345a56b..00000000 --- a/Tests/scaffolds/includes-protector/lang/en/passwords.php +++ /dev/null @@ -1,22 +0,0 @@ - 'Your password has been reset!', - 'sent' => 'We have emailed your password reset link!', - 'throttled' => 'Please wait before retrying.', - 'token' => 'This password reset token is invalid.', - 'user' => "We can't find a user with that email address.", - -]; diff --git a/Tests/scaffolds/includes-protector/lang/en/validation.php b/Tests/scaffolds/includes-protector/lang/en/validation.php deleted file mode 100644 index 724b5ace..00000000 --- a/Tests/scaffolds/includes-protector/lang/en/validation.php +++ /dev/null @@ -1,169 +0,0 @@ - 'The :attribute must be accepted.', - 'accepted_if' => 'The :attribute must be accepted when :other is :value.', - 'active_url' => 'The :attribute is not a valid URL.', - 'after' => 'The :attribute must be a date after :date.', - 'after_or_equal' => 'The :attribute must be a date after or equal to :date.', - 'alpha' => 'The :attribute must only contain letters.', - 'alpha_dash' => 'The :attribute must only contain letters, numbers, dashes and underscores.', - 'alpha_num' => 'The :attribute must only contain letters and numbers.', - 'array' => 'The :attribute must be an array.', - 'before' => 'The :attribute must be a date before :date.', - 'before_or_equal' => 'The :attribute must be a date before or equal to :date.', - 'between' => [ - 'array' => 'The :attribute must have between :min and :max items.', - 'file' => 'The :attribute must be between :min and :max kilobytes.', - 'numeric' => 'The :attribute must be between :min and :max.', - 'string' => 'The :attribute must be between :min and :max characters.', - ], - 'boolean' => 'The :attribute field must be true or false.', - 'confirmed' => 'The :attribute confirmation does not match.', - 'current_password' => 'The password is incorrect.', - 'date' => 'The :attribute is not a valid date.', - 'date_equals' => 'The :attribute must be a date equal to :date.', - 'date_format' => 'The :attribute does not match the format :format.', - 'declined' => 'The :attribute must be declined.', - 'declined_if' => 'The :attribute must be declined when :other is :value.', - 'different' => 'The :attribute and :other must be different.', - 'digits' => 'The :attribute must be :digits digits.', - 'digits_between' => 'The :attribute must be between :min and :max digits.', - 'dimensions' => 'The :attribute has invalid image dimensions.', - 'distinct' => 'The :attribute field has a duplicate value.', - 'email' => 'The :attribute must be a valid email address.', - 'ends_with' => 'The :attribute must end with one of the following: :values.', - 'enum' => 'The selected :attribute is invalid.', - 'exists' => 'The selected :attribute is invalid.', - 'file' => 'The :attribute must be a file.', - 'filled' => 'The :attribute field must have a value.', - 'gt' => [ - 'array' => 'The :attribute must have more than :value items.', - 'file' => 'The :attribute must be greater than :value kilobytes.', - 'numeric' => 'The :attribute must be greater than :value.', - 'string' => 'The :attribute must be greater than :value characters.', - ], - 'gte' => [ - 'array' => 'The :attribute must have :value items or more.', - 'file' => 'The :attribute must be greater than or equal to :value kilobytes.', - 'numeric' => 'The :attribute must be greater than or equal to :value.', - 'string' => 'The :attribute must be greater than or equal to :value characters.', - ], - 'image' => 'The :attribute must be an image.', - 'in' => 'The selected :attribute is invalid.', - 'in_array' => 'The :attribute field does not exist in :other.', - 'integer' => 'The :attribute must be an integer.', - 'ip' => 'The :attribute must be a valid IP address.', - 'ipv4' => 'The :attribute must be a valid IPv4 address.', - 'ipv6' => 'The :attribute must be a valid IPv6 address.', - 'json' => 'The :attribute must be a valid JSON string.', - 'lt' => [ - 'array' => 'The :attribute must have less than :value items.', - 'file' => 'The :attribute must be less than :value kilobytes.', - 'numeric' => 'The :attribute must be less than :value.', - 'string' => 'The :attribute must be less than :value characters.', - ], - 'lte' => [ - 'array' => 'The :attribute must not have more than :value items.', - 'file' => 'The :attribute must be less than or equal to :value kilobytes.', - 'numeric' => 'The :attribute must be less than or equal to :value.', - 'string' => 'The :attribute must be less than or equal to :value characters.', - ], - 'mac_address' => 'The :attribute must be a valid MAC address.', - 'max' => [ - 'array' => 'The :attribute must not have more than :max items.', - 'file' => 'The :attribute must not be greater than :max kilobytes.', - 'numeric' => 'The :attribute must not be greater than :max.', - 'string' => 'The :attribute must not be greater than :max characters.', - ], - 'mimes' => 'The :attribute must be a file of type: :values.', - 'mimetypes' => 'The :attribute must be a file of type: :values.', - 'min' => [ - 'array' => 'The :attribute must have at least :min items.', - 'file' => 'The :attribute must be at least :min kilobytes.', - 'numeric' => 'The :attribute must be at least :min.', - 'string' => 'The :attribute must be at least :min characters.', - ], - 'multiple_of' => 'The :attribute must be a multiple of :value.', - 'not_in' => 'The selected :attribute is invalid.', - 'not_regex' => 'The :attribute format is invalid.', - 'numeric' => 'The :attribute must be a number.', - 'password' => [ - 'letters' => 'The :attribute must contain at least one letter.', - 'mixed' => 'The :attribute must contain at least one uppercase and one lowercase letter.', - 'numbers' => 'The :attribute must contain at least one number.', - 'symbols' => 'The :attribute must contain at least one symbol.', - 'uncompromised' => 'The given :attribute has appeared in a data leak. Please choose a different :attribute.', - ], - 'present' => 'The :attribute field must be present.', - 'prohibited' => 'The :attribute field is prohibited.', - 'prohibited_if' => 'The :attribute field is prohibited when :other is :value.', - 'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.', - 'prohibits' => 'The :attribute field prohibits :other from being present.', - 'regex' => 'The :attribute format is invalid.', - 'required' => 'The :attribute field is required.', - 'required_array_keys' => 'The :attribute field must contain entries for: :values.', - 'required_if' => 'The :attribute field is required when :other is :value.', - 'required_unless' => 'The :attribute field is required unless :other is in :values.', - 'required_with' => 'The :attribute field is required when :values is present.', - 'required_with_all' => 'The :attribute field is required when :values are present.', - 'required_without' => 'The :attribute field is required when :values is not present.', - 'required_without_all' => 'The :attribute field is required when none of :values are present.', - 'same' => 'The :attribute and :other must match.', - 'size' => [ - 'array' => 'The :attribute must contain :size items.', - 'file' => 'The :attribute must be :size kilobytes.', - 'numeric' => 'The :attribute must be :size.', - 'string' => 'The :attribute must be :size characters.', - ], - 'starts_with' => 'The :attribute must start with one of the following: :values.', - 'string' => 'The :attribute must be a string.', - 'timezone' => 'The :attribute must be a valid timezone.', - 'unique' => 'The :attribute has already been taken.', - 'uploaded' => 'The :attribute failed to upload.', - 'url' => 'The :attribute must be a valid URL.', - 'uuid' => 'The :attribute must be a valid UUID.', - - /* - |-------------------------------------------------------------------------- - | Custom Validation Language Lines - |-------------------------------------------------------------------------- - | - | Here you may specify custom validation messages for attributes using the - | convention "attribute.rule" to name the lines. This makes it quick to - | specify a specific custom language line for a given attribute rule. - | - */ - - 'custom' => [ - 'attribute-name' => [ - 'rule-name' => 'custom-message', - ], - ], - - /* - |-------------------------------------------------------------------------- - | Custom Validation Attributes - |-------------------------------------------------------------------------- - | - | The following language lines are used to swap our attribute placeholder - | with something more reader friendly such as "E-Mail Address" instead - | of "email". This simply helps us make our message more expressive. - | - */ - - 'attributes' => [], - -]; diff --git a/Tests/scaffolds/includes-protector/migrations/2014_10_12_000000_testbench_create_users_table.php b/Tests/scaffolds/includes-protector/migrations/2014_10_12_000000_testbench_create_users_table.php deleted file mode 100644 index beb06a36..00000000 --- a/Tests/scaffolds/includes-protector/migrations/2014_10_12_000000_testbench_create_users_table.php +++ /dev/null @@ -1,35 +0,0 @@ -id(); - $table->string('name'); - $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); - $table->string('password'); - $table->rememberToken(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('users'); - } -}; diff --git a/Tests/scaffolds/includes-protector/migrations/2014_10_12_100000_testbench_create_password_resets_table.php b/Tests/scaffolds/includes-protector/migrations/2014_10_12_100000_testbench_create_password_resets_table.php deleted file mode 100644 index 440f4741..00000000 --- a/Tests/scaffolds/includes-protector/migrations/2014_10_12_100000_testbench_create_password_resets_table.php +++ /dev/null @@ -1,31 +0,0 @@ -string('email')->index(); - $table->string('token'); - $table->timestamp('created_at')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('password_resets'); - } -}; diff --git a/Tests/scaffolds/includes-protector/migrations/2019_08_19_000000_testbench_create_failed_jobs_table.php b/Tests/scaffolds/includes-protector/migrations/2019_08_19_000000_testbench_create_failed_jobs_table.php deleted file mode 100644 index 262db10b..00000000 --- a/Tests/scaffolds/includes-protector/migrations/2019_08_19_000000_testbench_create_failed_jobs_table.php +++ /dev/null @@ -1,35 +0,0 @@ -id(); - $table->string('uuid')->unique(); - $table->text('connection'); - $table->text('queue'); - $table->longText('payload'); - $table->longText('exception'); - $table->timestamp('failed_at')->useCurrent(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('failed_jobs'); - } -}; diff --git a/Tests/scaffolds/includes-protector/public/.gitignore b/Tests/scaffolds/includes-protector/public/.gitignore deleted file mode 100644 index d723e54d..00000000 --- a/Tests/scaffolds/includes-protector/public/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!index.php -!.gitignore diff --git a/Tests/scaffolds/includes-protector/public/index.php b/Tests/scaffolds/includes-protector/public/index.php deleted file mode 100644 index f3c2ebcd..00000000 --- a/Tests/scaffolds/includes-protector/public/index.php +++ /dev/null @@ -1,55 +0,0 @@ -make(Kernel::class); - -$response = $kernel->handle( - $request = Request::capture() -)->send(); - -$kernel->terminate($request, $response); diff --git a/Tests/scaffolds/includes-protector/resources/views/errors/503.blade.php b/Tests/scaffolds/includes-protector/resources/views/errors/503.blade.php deleted file mode 100644 index 6cc184a7..00000000 --- a/Tests/scaffolds/includes-protector/resources/views/errors/503.blade.php +++ /dev/null @@ -1,43 +0,0 @@ - - - Be right back. - - - - - - -
-
-
Be right back.
-
-
- - diff --git a/Tests/scaffolds/includes-protector/resources/views/welcome.blade.php b/Tests/scaffolds/includes-protector/resources/views/welcome.blade.php deleted file mode 100644 index 9e9e6ff5..00000000 --- a/Tests/scaffolds/includes-protector/resources/views/welcome.blade.php +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - -
-
-
Laravel 5
-
-
- - diff --git a/Tests/scaffolds/includes-protector/routes/.gitignore b/Tests/scaffolds/includes-protector/routes/.gitignore deleted file mode 100644 index d6b7ef32..00000000 --- a/Tests/scaffolds/includes-protector/routes/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/Tests/scaffolds/includes-protector/server.php b/Tests/scaffolds/includes-protector/server.php deleted file mode 100644 index 4b2c0d18..00000000 --- a/Tests/scaffolds/includes-protector/server.php +++ /dev/null @@ -1,16 +0,0 @@ - - - - - Tests - - - - - ./src - - - - - - - - - - - - - - - - - - - - - - + + + + tests/feature + + + + + + + + + + + + + + + + + + ./src + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 97f62f4c..dc3e1357 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,37 +1,36 @@ - - - - Tests - - - - - ./src - - - - - - - - - - - - - - - - - - - - - - + + + + tests/feature + + + + + + + + + + + + + + + + + + + + + + + + + + + + ./src + + diff --git a/src/Protector.php b/src/Protector.php index 31e120e0..d4549feb 100644 --- a/src/Protector.php +++ b/src/Protector.php @@ -38,6 +38,7 @@ use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; +use Throwable; class Protector { @@ -416,11 +417,18 @@ public function getMetaData(bool $refresh = false): array /** * Returns the last x lines from a file in correct order. + * + * @throws FileNotFoundException */ protected function tail(string $file, int $lines, int $buffer = 1024): array { // Open file-handle. $fileHandle = $this->getDisk()->readStream($file); + + if (!is_resource($fileHandle)) { + throw new FileNotFoundException($file); + } + // Jump to last character. fseek($fileHandle, 0, SEEK_END); @@ -557,14 +565,6 @@ protected function createDirectory(string $destinationPath, FilesystemAdapter $d sprintf('Could not create the non-existing destination path %s on given disk.', $destinationPath) ); } - - return; - } - - if (in_array($destinationPath, $disk->files($this->getBaseDirectory()))) { - throw new FailedCreatingDestinationPathException( - sprintf('Could not create directory %s, because a file with the same name exists.', $destinationPath) - ); } } @@ -653,12 +653,34 @@ protected function getPublicKey(Request $request): string return $publicKey; } - public function createTempFilePath(string $diskFilePath): string|false + /** + * Copies the specified dump to a local temporary file, in case the dump is stored remotely. + * + * @throws Exception + * @throws FileNotFoundException + */ + public function createTempFilePath(string $diskFilePath): string { $tempFilePath = tempnam('', 'protector'); + + if ($tempFilePath === false) { + throw new Exception('Could not create a temporary file for dump.'); + } + $handle = fopen($tempFilePath, 'w'); + + if ($handle === false) { + throw new Exception('Could not open temporary file for writing.'); + } + $stream = $this->getDisk()->readStream($diskFilePath); + if (!is_resource($stream)) { + fclose($handle); + + throw new FileNotFoundException($diskFilePath); + } + stream_copy_to_stream($stream, $handle); fclose($handle); diff --git a/Tests/BaseTest.php b/tests/TestCase.php similarity index 58% rename from Tests/BaseTest.php rename to tests/TestCase.php index fe75a83e..7d1a359b 100644 --- a/Tests/BaseTest.php +++ b/tests/TestCase.php @@ -1,12 +1,20 @@ protector = app('protector'); } - /** - * @return string - */ - protected function getBasePath(): string - { - return __DIR__ . '/scaffolds/includes-protector'; - } - /** * @param $app * @return string[] @@ -71,32 +71,27 @@ protected function setProtectedProperty(string $propertyName, mixed $value): voi $property->setValue($this->protector, $value); } - /** - * Provides a dynamic number of dumps, optionally a new filename can be specified as the array key. - * - * @param array $fileNames - * @return void - */ - protected function provideTestDumps(array $fileNames): void + protected function getFakeDumpDisk(): Filesystem { - $directoryName = 'testDumps'; - $disk = Storage::disk('local'); - - $disk->deleteDirectory($directoryName); - - Config::set('protector.baseDirectory', $directoryName); - $disk->makeDirectory($directoryName); - - foreach ($fileNames as $newFileName => $fileName) { - $disk->copy( - sprintf('protector%s%s', DIRECTORY_SEPARATOR, $fileName), - sprintf( - '%s%s%s', - $directoryName, - DIRECTORY_SEPARATOR, - is_string($newFileName) ? $newFileName : $fileName - ) - ); + $disk = $this->getDumpDisk(); + $baseDirectory = $this->protector->getBaseDirectory(); + + foreach (glob(getcwd() . '/tests/dumps/*.sql') as $filename) { + Storage::disk('local')->putFileAs($baseDirectory, $filename, basename($filename)); } + + return $disk; + } + + protected function getDumpDisk(): Filesystem + { + $diskName = config('protector.diskName', config('filesystems.default')); + + return Storage::fake($diskName); + } + + protected function clearDumpDirectory(): void + { + $this->getDumpDisk()->deleteDirectory($this->protector->getBaseDirectory()); } } diff --git a/Tests/scaffolds/includes-protector/storage/app/protector/dump.sql b/tests/dumps/dump.sql similarity index 100% rename from Tests/scaffolds/includes-protector/storage/app/protector/dump.sql rename to tests/dumps/dump.sql diff --git a/Tests/scaffolds/includes-protector/storage/app/protector/dumpWithDifferentConnection.sql b/tests/dumps/dumpWithDifferentConnection.sql similarity index 100% rename from Tests/scaffolds/includes-protector/storage/app/protector/dumpWithDifferentConnection.sql rename to tests/dumps/dumpWithDifferentConnection.sql diff --git a/Tests/scaffolds/includes-protector/storage/app/protector/dumpWithGit.sql b/tests/dumps/dumpWithGit.sql similarity index 100% rename from Tests/scaffolds/includes-protector/storage/app/protector/dumpWithGit.sql rename to tests/dumps/dumpWithGit.sql diff --git a/Tests/scaffolds/includes-protector/storage/app/protector/dumpWithIncorrectMetadata.sql b/tests/dumps/dumpWithIncorrectMetadata.sql similarity index 100% rename from Tests/scaffolds/includes-protector/storage/app/protector/dumpWithIncorrectMetadata.sql rename to tests/dumps/dumpWithIncorrectMetadata.sql diff --git a/Tests/scaffolds/includes-protector/storage/app/protector/dumpWithoutMetadata.sql b/tests/dumps/dumpWithoutMetadata.sql similarity index 100% rename from Tests/scaffolds/includes-protector/storage/app/protector/dumpWithoutMetadata.sql rename to tests/dumps/dumpWithoutMetadata.sql diff --git a/Tests/scaffolds/includes-protector/storage/app/protector/emptyDump.sql b/tests/dumps/emptyDump.sql similarity index 100% rename from Tests/scaffolds/includes-protector/storage/app/protector/emptyDump.sql rename to tests/dumps/emptyDump.sql diff --git a/Tests/ExceptionTest.php b/tests/feature/ExceptionTest.php similarity index 87% rename from Tests/ExceptionTest.php rename to tests/feature/ExceptionTest.php index 37e984c2..30ece6bb 100644 --- a/Tests/ExceptionTest.php +++ b/tests/feature/ExceptionTest.php @@ -1,14 +1,14 @@ disk = $this->getFakeDumpDisk(); - $this->disk = Storage::disk('local'); $this->baseDirectory = Config::get('protector.baseDirectory'); - $this->filePath = sprintf('%s/dump.sql', $this->baseDirectory); + $this->filePath = sprintf('%s/dump.sql', $this->baseDirectory); $this->emptyDumpPath = 'testDumps/dump.sql'; } @@ -33,10 +34,9 @@ protected function setUp(): void */ public function createDestinationFilePath() { - Config::set('protector.baseDirectory', 'noDumps'); $this->disk->deleteDirectory(Config::get('protector.baseDirectory')); - $filePath = $this->protector->createDestinationFilePath(__FUNCTION__); + $filePath = $this->protector->createDestinationFilePath(__FUNCTION__); $destinationFilePath = $this->disk->path($filePath); $this->runProtectedMethod('createDirectory', [$filePath, $this->disk]); @@ -48,28 +48,15 @@ public function createDestinationFilePath() */ public function createDestinationFilePathWithSubFolder() { - Config::set('protector.baseDirectory', 'noDumps'); - $this->disk->deleteDirectory(Config::get('protector.baseDirectory')); - $filePath = $this->protector->createDestinationFilePath(__FUNCTION__, __FUNCTION__); + $filePath = $this->protector->createDestinationFilePath(__FUNCTION__, __FUNCTION__); $destinationFilePath = $this->disk->path($filePath); $this->runProtectedMethod('createDirectory', [$filePath, $this->disk]); $this->assertDirectoryExists($destinationFilePath); } - /** - * @test - */ - public function failDirectoryCreationOnExistingFile() - { - $path = 'protector/dump.sql'; - - $this->expectException(FailedCreatingDestinationPathException::class); - $this->runProtectedMethod('createDirectory', [$path, $this->disk]); - } - /** * @test */ @@ -112,10 +99,10 @@ public function failGeneratingDumpWhenTryingToConnectToDatabase() { // Provide an database connection to a non-existing database. Config::set('database.connections.invalid', [ - 'driver' => 'mysql', - 'url' => env('DATABASE_URL'), - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '3306'), + 'driver' => 'mysql', + 'url' => env('DATABASE_URL'), + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '3306'), 'database' => 'invalid_database_name', 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), diff --git a/Tests/ImportDumpCommandTest.php b/tests/feature/ImportDumpCommandTest.php similarity index 85% rename from Tests/ImportDumpCommandTest.php rename to tests/feature/ImportDumpCommandTest.php index 9cb16237..60ae5838 100644 --- a/Tests/ImportDumpCommandTest.php +++ b/tests/feature/ImportDumpCommandTest.php @@ -1,22 +1,24 @@ disk = Storage::disk('local'); + $this->disk = $this->getFakeDumpDisk(); $this->serverUrl = $this->protector->getServerUrl(); $this->shouldDownloadDump = 'Do you want to download and import a fresh dump from the server or an existing local dump?'; @@ -35,14 +38,6 @@ protected function setUp(): void ); } - protected function tearDown(): void - { - parent::tearDown(); - - Config::set('protector.baseDirectory', 'testDumps'); - $this->disk->deleteDirectory(Config::get('protector.baseDirectory')); - } - /** * @test */ @@ -68,8 +63,6 @@ public function failOnOptionForceIncorrectlySet() */ public function failOnNoDumpHasSpecifiedConnection() { - $this->provideTestDumps(['dump.sql', 'secondDump.sql' => 'dump.sql']); - $this->expectException(InvalidConnectionException::class); $this->artisan('protector:import --connection=sqlite') @@ -105,7 +98,7 @@ public function getRemoteDumpOnImportDumpCommand() $this->artisan('protector:import --remote') ->expectsConfirmation($this->shouldImportDump); - $this->assertFileExists($this->disk->path('protector/remote_dump.sql')); + $this->assertFileExists($this->disk->path(static::$baseDirectory . '/remote_dump.sql')); } /** @@ -113,8 +106,6 @@ public function getRemoteDumpOnImportDumpCommand() */ public function canGetRemoteDumpWithFlushOptionEnabled() { - $this->provideTestDumps(['dump.sql', 'secondDump.sql' => 'dump.sql', 'thirdDump.sql' => 'dump.sql']); - Config::set('protector.remoteEndpoint.htaccessLogin', '1234:1234'); Config::set('protector.routeMiddleware', []); @@ -169,8 +160,6 @@ public function failOptionDumpOnNonExistingDump() */ public function canImportDumpOnOptionLatest() { - $this->provideTestDumps(['dump.sql']); - $this->artisan('protector:import --latest')->expectsConfirmation($this->shouldImportDump); $this->assertEquals( sprintf('%s%sdump.sql', $this->protector->getBaseDirectory(), DIRECTORY_SEPARATOR), @@ -183,7 +172,7 @@ public function canImportDumpOnOptionLatest() */ public function failChooseImportDumpOnNoFilesInBaseDirectory() { - $this->provideTestDumps([]); + $this->clearDumpDirectory(); $this->expectException(EmptyBaseDirectoryException::class); @@ -196,13 +185,13 @@ public function failChooseImportDumpOnNoFilesInBaseDirectory() */ public function chooseImportDumpWithOnlyOneFileInBaseDirectory() { - $this->provideTestDumps(['dump.sql']); + $this->protector->flush(static::$baseDirectory . '/dump.sql'); $this->assertCount(1, $this->protector->getDumpFiles()); $this->artisan('protector:import') ->expectsChoice($this->shouldDownloadDump, 2, ['Download remote dump', 'Import existing local dump']) - ->expectsOutput('Using file "testDumps/dump.sql" because there are no other dumps.') + ->expectsOutput('Using file "' . static::$baseDirectory . '/dump.sql" because there are no other dumps.') ->expectsConfirmation($this->shouldImportDump); } } diff --git a/Tests/ImportDumpTest.php b/tests/feature/ImportDumpTest.php similarity index 70% rename from Tests/ImportDumpTest.php rename to tests/feature/ImportDumpTest.php index d8db8585..43065ec9 100644 --- a/Tests/ImportDumpTest.php +++ b/tests/feature/ImportDumpTest.php @@ -1,50 +1,41 @@ protector = app('protector'); - $this->disk = Storage::disk('local'); - $this->baseDirectory = Config::get('protector.baseDirectory'); - $this->filePath = $this->protector->createTempFilePath( - sprintf('%s%sdump.sql', $this->baseDirectory, DIRECTORY_SEPARATOR) - ); - $this->emptyDumpPath = 'testDumps/dump.sql'; + Config::set('protector.baseDirectory', static::$baseDirectory); - $this->shouldDownloadDump = 'Do you want to download and import a fresh dump from the server or an existing local dump?'; - } - - protected function tearDown(): void - { - parent::tearDown(); + $this->disk = $this->getFakeDumpDisk(); - Config::set('protector.baseDirectory', 'testDumps'); - $this->disk->deleteDirectory(Config::get('protector.baseDirectory')); + $this->filePath = getcwd() . '/tests/dumps/dump.sql'; } - public function provideDumpMetadata(): array + public static function provideDumpMetadata(): array { return [ [ - "protector/dump.sql", + static::$baseDirectory . "/dump.sql", [ 'meta' => [ 'database' => 'protector-tests', @@ -69,7 +60,7 @@ public function provideDumpMetadata(): array ] ], [ - "protector/dumpWithGit.sql", + static::$baseDirectory . "/dumpWithGit.sql", [ 'meta' => [ 'database' => 'protector-tests', @@ -94,44 +85,40 @@ public function provideDumpMetadata(): array ] ], [ - "protector/dumpWithoutMetadata.sql", + static::$baseDirectory . "/dumpWithoutMetadata.sql", [] ], [ - "protector/dumpWithIncorrectMetadata.sql", + static::$baseDirectory . "/dumpWithIncorrectMetadata.sql", false ], ]; } - public function provideEmptyDumpsWhenReceivingTheLatestDumpName(): array + public static function provideEmptyDumpsWhenReceivingTheLatestDumpName(): array { return [ [ - ['dump.sql'], - 'testDumps/dump.sql', + static::$baseDirectory . '/dump.sql', false ], [ - ['dump.sql', 'secondDump.sql' => 'dump.sql', 'thirdDump' => 'dump.sql'], - 'testDumps/secondDump.sql', + static::$baseDirectory . '/secondDump.sql', true ] ]; } - public function provideEmptyDumpsForFlushingDumps(): array + public static function provideEmptyDumpsForFlushingDumps(): array { return [ [ - ['dump.sql'], [], null ], [ - ['dump.sql', 'secondDump.sql' => 'dump.sql'], - ['testDumps/secondDump.sql'], - 'testDumps/secondDump.sql' + [static::$baseDirectory . '/emptyDump.sql'], + static::$baseDirectory . '/emptyDump.sql' ] ]; } @@ -186,10 +173,8 @@ public function throwsExceptionOnMysqlFailedShellCommand() * @test * @dataProvider provideEmptyDumpsWhenReceivingTheLatestDumpName */ - public function canReturnLatestFileName(array $fileNames, string $expectedFileName, bool $shouldModify) + public function canReturnLatestFileName(string $expectedFileName, bool $shouldModify) { - $this->provideTestDumps($fileNames); - if ($shouldModify) { touch($this->disk->path($expectedFileName), time() + 60); } @@ -205,8 +190,7 @@ public function canReturnLatestFileName(array $fileNames, string $expectedFileNa */ public function throwsExceptionIfNoFileExists() { - $this->provideTestDumps([]); - + $this->clearDumpDirectory(); $this->expectException(FileNotFoundException::class); $this->protector->getLatestDumpName(); } @@ -225,22 +209,18 @@ public function verifyDumpDateMetaData($filePath, $expectedMetaData) */ public function failGetDumpMetaDataOnResponseHasNotEnoughLines() { - $this->provideTestDumps(['emptyDump.sql']); - - $this->assertEquals(false, $this->protector->getDumpMetaData('testDumps/emptyDump.sql')); + $this->assertEquals(false, $this->protector->getDumpMetaData(static::$baseDirectory . '/emptyDump.sql')); } /** * @test * @dataProvider provideEmptyDumpsForFlushingDumps */ - public function flushDumps($fileNames, $expected, $excludeDump) + public function flushDumps($expected, $excludeFromFlush) { - $this->provideTestDumps($fileNames); - - $this->protector->flush($excludeDump); + $this->protector->flush($excludeFromFlush); - $baseDirectory = Config::get('protector.baseDirectory'); + $baseDirectory = $this->protector->getBaseDirectory(); $dumpsAfterFlushing = $this->disk->files($baseDirectory); $this->assertEquals($expected, $dumpsAfterFlushing); diff --git a/Tests/RemoteDumpTest.php b/tests/feature/RemoteDumpTest.php similarity index 98% rename from Tests/RemoteDumpTest.php rename to tests/feature/RemoteDumpTest.php index 360d76ab..894e51bd 100644 --- a/Tests/RemoteDumpTest.php +++ b/tests/feature/RemoteDumpTest.php @@ -1,8 +1,10 @@ protector->createFilename(); $structure = '%s %d-%d-%d %d-%d %x.sql'; + config()->set('protector.fileName', $structure); + + $fileName = $this->protector->createFilename(); $this->assertIsString($fileName); $this->assertStringMatchesFormat($structure, $fileName);