-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Migrate config renovate.json (#46) * Add PHP 8.4 support and improve test coverage * Fix content-type of geostackip-script * Add Guzzle to require-dev for HTTP client testing * Update orchestra/testbench to version constraint to ^9.1 * Refactor PHP extensions for streamlined setup * Remove unused ext-pcntl dependency * Add SQLite extension for testing environment * Remove unused curl extension from dependencies --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
- Loading branch information
1 parent
ab76b2e
commit a440b86
Showing
13 changed files
with
363 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ phpstan.neon.dist | |
testbench.yaml | ||
vendor | ||
node_modules | ||
.php-cs-fixer.cache |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
tests/Feature/Http/Controllers/Api/IncidentControllerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Tests\Feature\Http\Controllers\Api; | ||
|
||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Illuminate\Support\Facades\Http; | ||
use function Pest\testDirectory; | ||
use Tvup\LaravelFejlvarp\Incident; | ||
|
||
uses(RefreshDatabase::class); | ||
|
||
it('will include a javascript to lookup data about the ip-address', function () { | ||
// Arrange | ||
$incidentData = file_get_contents(testDirectory('Fixtures/incident_data_exception.json')); | ||
$incident = Incident::factory()->create(['resolved_at' => null, 'data' => json_decode($incidentData, true)]); | ||
|
||
// Act | ||
$response = $this->get(route('incident.show', $incident->hash)); | ||
|
||
// Assert | ||
$response->assertOk(); | ||
$response->assertViewHas('incident', fn ($i) => $i->hash === $incident->hash); | ||
$response->assertSee('/api/geoip?ip=89.150.133.237&callback=geoipCallback', false); | ||
}); | ||
|
||
it('can fetch info about an IP-address and return as a javascript-function', function () { | ||
// Arrange | ||
// Set the IPStack access key to a mock key - needed for controller to enter the if-statement that fetches the IP info | ||
config()->set('fejlvarp.ipstack.access_key', 'mock_key'); | ||
|
||
// Mock the IPStack API response | ||
$ipStackResultOfIp = file_get_contents(testDirectory('Fixtures/ipstack_89-150-133-237.json')); | ||
Http::fake([ | ||
'api.ipstack.com/89.150.133.237?access_key=mock_key' => Http::response(json_decode($ipStackResultOfIp, true)), | ||
]); | ||
|
||
// Act | ||
$response = $this->get('/api/geoip?ip=89.150.133.237&callback=geoipCallback'); | ||
|
||
// Assert | ||
$response->assertHeader('Content-Type', 'application/javascript'); | ||
$response->assertOk(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Tests\Feature\Http\Controllers; | ||
|
||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Tvup\LaravelFejlvarp\Incident; | ||
|
||
uses(RefreshDatabase::class); | ||
|
||
it('can retrieve all unresolved incidents', function () { | ||
Incident::factory()->count(2)->create(['resolved_at' => null]); | ||
Incident::factory()->create(['resolved_at' => now()]); | ||
|
||
$response = $this->get(route('incidents.index')); | ||
|
||
$response->assertOk(); | ||
$response->assertViewHas('incidents', fn ($incidents) => $incidents->count() === 2); | ||
}); | ||
|
||
it('can show a single incident', function () { | ||
$incident = Incident::factory()->create(); | ||
|
||
$response = $this->get(route('incident.show', $incident->hash)); | ||
|
||
$response->assertOk(); | ||
$response->assertViewHas('incident', fn ($i) => $i->hash === $incident->hash); | ||
}); | ||
|
||
it('can mark an incident as resolved', function () { | ||
$incident = Incident::factory()->create(['resolved_at' => null]); | ||
|
||
$this->post(route('incident.delete', $incident->hash)); | ||
|
||
expect($incident->fresh()->resolved_at)->not->toBeNull(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
{ | ||
"application": "Laravel", | ||
"error": { | ||
"type": "Symfony\\Component\\Console\\Exception\\CommandNotFoundException", | ||
"message": "Command \"FEJL\" is not defined.", | ||
"code": 0, | ||
"file": "/var/www/html/vendor/symfony/console/Application.php", | ||
"line": 726, | ||
"trace": "#0 /var/www/html/vendor/symfony/console/Application.php(284): Symfony\\Component\\Console\\Application->find()\n#1 /var/www/html/vendor/symfony/console/Application.php(193): Symfony\\Component\\Console\\Application->doRun()\n#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(198): Symfony\\Component\\Console\\Application->run()\n#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1231): Illuminate\\Foundation\\Console\\Kernel->handle()\n#4 /var/www/html/artisan(13): Illuminate\\Foundation\\Application->handleCommand()\n#5 {main}" | ||
}, | ||
"environment": { | ||
"GET": null, | ||
"POST": null, | ||
"SERVER": { | ||
"PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", | ||
"HOSTNAME": "f5408bf6ad54", | ||
"TERM": "xterm", | ||
"WWWUSER": "1000", | ||
"LARAVEL_SAIL": "1", | ||
"XDEBUG_MODE": "off", | ||
"XDEBUG_CONFIG": "client_host=host.docker.internal", | ||
"IGNITION_LOCAL_SITES_PATH": "/home/user/Projects/LaravelFejlVarp-parent", | ||
"DEBIAN_FRONTEND": "noninteractive", | ||
"TZ": "UTC", | ||
"SUPERVISOR_PHP_COMMAND": "/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80", | ||
"SUPERVISOR_PHP_USER": "sail", | ||
"HOME": "/home/sail", | ||
"PHP_SELF": "artisan", | ||
"SCRIPT_NAME": "artisan", | ||
"SCRIPT_FILENAME": "artisan", | ||
"PATH_TRANSLATED": "artisan", | ||
"DOCUMENT_ROOT": "", | ||
"REQUEST_TIME_FLOAT": 1738366035.610871, | ||
"REQUEST_TIME": 1738366035, | ||
"argv": [ | ||
"artisan", | ||
"FEJL" | ||
], | ||
"argc": 2, | ||
"APP_NAME": "Laravel", | ||
"APP_ENV": "local", | ||
"APP_KEY": "base64:1234", | ||
"APP_DEBUG": "true", | ||
"APP_TIMEZONE": "UTC", | ||
"APP_URL": "http://localhost", | ||
"APP_PORT": "8080", | ||
"VITE_PORT": "5173", | ||
"APP_LOCALE": "en", | ||
"APP_FALLBACK_LOCALE": "en", | ||
"APP_FAKER_LOCALE": "en_US", | ||
"APP_MAINTENANCE_DRIVER": "file", | ||
"PHP_CLI_SERVER_WORKERS": "4", | ||
"BCRYPT_ROUNDS": "12", | ||
"LOG_CHANNEL": "stack", | ||
"LOG_STACK": "single", | ||
"LOG_DEPRECATIONS_CHANNEL": "null", | ||
"LOG_LEVEL": "debug", | ||
"DB_CONNECTION": "mysql", | ||
"DB_HOST": "mysql", | ||
"DB_PORT": "3306", | ||
"DB_DATABASE": "laravel", | ||
"DB_USERNAME": "sail", | ||
"DB_PASSWORD": "password", | ||
"FORWARD_DB_PORT": "3307", | ||
"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": "redis", | ||
"REDIS_PASSWORD": "null", | ||
"REDIS_PORT": "6379", | ||
"FORWARD_REDIS_PORT": "6379", | ||
"MAIL_MAILER": "smtp", | ||
"MAIL_SCHEME": "null", | ||
"MAIL_HOST": "mailpit", | ||
"MAIL_PORT": "1025", | ||
"MAIL_USERNAME": "null", | ||
"MAIL_PASSWORD": "null", | ||
"MAIL_FROM_ADDRESS": "[email protected]", | ||
"MAIL_FROM_NAME": "Laravel", | ||
"FORWARD_MAILPIT_PORT": "1026", | ||
"FORWARD_MAILPIT_DASHBOARD_PORT": "8025", | ||
"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": "Laravel", | ||
"SCOUT_DRIVER": "meilisearch", | ||
"MEILISEARCH_HOST": "http://meilisearch:7700", | ||
"MEILISEARCH_NO_ANALYTICS": "false", | ||
"FORWARD_MEILISEARCH_PORT": "7700", | ||
"INCIDENT_MANAGER_IPSTACK_ACCESS_KEY": "access_key", | ||
"SHELL_VERBOSITY": 0 | ||
}, | ||
"SESSION": null | ||
}, | ||
"application_data": null, | ||
"queries": [] | ||
} |
Oops, something went wrong.