Skip to content

Commit

Permalink
✅ Tests for generation Signature Key
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahNxT committed May 13, 2024
1 parent 1284ce3 commit a0d8650
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ composer.lock
docs
vendor
.php-cs-fixer.cache

.phpunit.cache/
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
],
"require": {
"php": "^8.1",
"illuminate/support": "^9.0|^10.0|^11.0",
"illuminate/support": "^10.0|^11.0",
"illuminate/console": "^10.10.0|^11.0",
"spatie/laravel-package-tools": "^1.13.6",
"spatie/url-signer": "^2.0"
},
"require-dev": {
"orchestra/testbench": "^7.12.1|^8.0|^9.0",
"orchestra/testbench": "^8.0|^9.0",
"pestphp/pest": "^1.22.2|^1.22|^2.34"
},
"autoload": {
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<testsuites>
<testsuite name="Package Test Suite">
<directory>./tests/</directory>
<directory suffix=".php">./tests/Commands/</directory>
</testsuite>
</testsuites>
<php>
Expand Down
27 changes: 27 additions & 0 deletions tests/Commands/GenerateUrlSignerSignatureKey.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use Illuminate\Support\Env;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\File;

beforeEach(function () {
File::copy(__DIR__.'/../Stubs/.env', base_path('.env'));
});

test('it can generate a URL signer signature key', function () {
Artisan::call('generate:url-signer-signature-key');

$env = trim(File::get(base_path('.env')));

expect($env)->toContain('URL_SIGNER_SIGNATURE_KEY=');
});

test('it can display a URL signer signature key', function () {
Artisan::call('generate:url-signer-signature-key --show');

$output = trim(Artisan::output());

expect($output)
->toBeString()
->toHaveLength(64);
});
65 changes: 65 additions & 0 deletions tests/Stubs/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# .env.example from Laravel/Laravel repository (commit: 27907e0)
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_TIMEZONE=UTC
APP_URL=http://localhost

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file
APP_MAINTENANCE_STORE=database

BCRYPT_ROUNDS=12

LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=

SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null

BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database

CACHE_STORE=database
CACHE_PREFIX=

MEMCACHED_HOST=127.0.0.1

REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=log
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

VITE_APP_NAME="${APP_NAME}"

0 comments on commit a0d8650

Please sign in to comment.