diff --git a/app/Console/Commands/MashupCreateCommand.php b/app/Console/Commands/MashupCreateCommand.php index 4c1e0cc..1022a2a 100644 --- a/app/Console/Commands/MashupCreateCommand.php +++ b/app/Console/Commands/MashupCreateCommand.php @@ -128,8 +128,8 @@ class MashupCreateCommand extends Command required: true, default: 'Mashup', validate: fn (string $value) => match (true) { - strlen($value) < 1 => 'The name must be at least 2 characters.', - strlen($value) > 50 => 'The name must not exceed 50 characters.', + mb_strlen($value) < 1 => 'The name must be at least 2 characters.', + mb_strlen($value) > 50 => 'The name must not exceed 50 characters.', default => null, } ); @@ -149,7 +149,7 @@ class MashupCreateCommand extends Command $selectedPlugins = collect(); $availablePlugins = $plugins->mapWithKeys(fn ($plugin) => [$plugin->id => $plugin->name])->toArray(); - for ($i = 0; $i < $requiredCount; $i++) { + for ($i = 0; $i < $requiredCount; ++$i) { $position = match ($i) { 0 => 'first', 1 => 'second', diff --git a/app/Console/Commands/ScreenGeneratorCommand.php b/app/Console/Commands/ScreenGeneratorCommand.php index 722c5f2..ac74fba 100644 --- a/app/Console/Commands/ScreenGeneratorCommand.php +++ b/app/Console/Commands/ScreenGeneratorCommand.php @@ -4,6 +4,7 @@ namespace App\Console\Commands; use App\Jobs\GenerateScreenJob; use Illuminate\Console\Command; +use Throwable; class ScreenGeneratorCommand extends Command { @@ -31,7 +32,7 @@ class ScreenGeneratorCommand extends Command try { $markup = view($view)->render(); - } catch (\Throwable $e) { + } catch (Throwable $e) { $this->error('Failed to render view: '.$e->getMessage()); return 1; diff --git a/app/Jobs/FetchProxyCloudResponses.php b/app/Jobs/FetchProxyCloudResponses.php index 0f30f22..ece2808 100644 --- a/app/Jobs/FetchProxyCloudResponses.php +++ b/app/Jobs/FetchProxyCloudResponses.php @@ -3,6 +3,7 @@ namespace App\Jobs; use App\Models\Device; +use Exception; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -67,7 +68,7 @@ class FetchProxyCloudResponses implements ShouldQueue $device->update([ 'current_screen_image' => $filename, ]); - } catch (\Exception $e) { + } catch (Exception $e) { Log::error("Failed to download and save image for device: {$device->mac_address}", [ 'error' => $e->getMessage(), ]); @@ -95,7 +96,7 @@ class FetchProxyCloudResponses implements ShouldQueue ]); } - } catch (\Exception $e) { + } catch (Exception $e) { Log::error("Failed to fetch proxy cloud response for device: {$device->mac_address}", [ 'error' => $e->getMessage(), ]); diff --git a/app/Jobs/FirmwareDownloadJob.php b/app/Jobs/FirmwareDownloadJob.php index 9db7c82..6b4fc36 100644 --- a/app/Jobs/FirmwareDownloadJob.php +++ b/app/Jobs/FirmwareDownloadJob.php @@ -3,6 +3,7 @@ namespace App\Jobs; use App\Models\Firmware; +use Exception; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -40,7 +41,7 @@ class FirmwareDownloadJob implements ShouldQueue ]); } catch (ConnectionException $e) { Log::error('Firmware download failed: '.$e->getMessage()); - } catch (\Exception $e) { + } catch (Exception $e) { Log::error('An unexpected error occurred: '.$e->getMessage()); } } diff --git a/app/Jobs/FirmwarePollJob.php b/app/Jobs/FirmwarePollJob.php index 9d6f169..7110b9c 100644 --- a/app/Jobs/FirmwarePollJob.php +++ b/app/Jobs/FirmwarePollJob.php @@ -3,6 +3,7 @@ namespace App\Jobs; use App\Models\Firmware; +use Exception; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -10,6 +11,7 @@ use Illuminate\Http\Client\ConnectionException; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Http; +use Log; class FirmwarePollJob implements ShouldQueue { @@ -28,7 +30,7 @@ class FirmwarePollJob implements ShouldQueue $response = Http::get('https://usetrmnl.com/api/firmware/latest')->json(); if (! is_array($response) || ! isset($response['version']) || ! isset($response['url'])) { - \Log::error('Invalid firmware response format received'); + Log::error('Invalid firmware response format received'); return; } @@ -48,9 +50,9 @@ class FirmwarePollJob implements ShouldQueue } } catch (ConnectionException $e) { - \Log::error('Firmware download failed: '.$e->getMessage()); - } catch (\Exception $e) { - \Log::error('Unexpected error in firmware polling: '.$e->getMessage()); + Log::error('Firmware download failed: '.$e->getMessage()); + } catch (Exception $e) { + Log::error('Unexpected error in firmware polling: '.$e->getMessage()); } } } diff --git a/app/Models/Device.php b/app/Models/Device.php index 68b3301..52d6820 100644 --- a/app/Models/Device.php +++ b/app/Models/Device.php @@ -35,7 +35,8 @@ class Device extends Model // Ensure the voltage is within range if ($volts <= $min_volt) { return 0; - } elseif ($volts >= $max_volt) { + } + if ($volts >= $max_volt) { return 100; } @@ -60,7 +61,8 @@ class Device extends Model // Ensure the percentage is within range if ($percent <= 0) { return $min_volt; - } elseif ($percent >= 100) { + } + if ($percent >= 100) { return $max_volt; } @@ -75,13 +77,16 @@ class Device extends Model $rssi = $this->last_rssi_level; if ($rssi >= 0) { return 0; // No signal (0 bars) - } elseif ($rssi <= -80) { - return 1; // Weak signal (1 bar) - } elseif ($rssi <= -60) { - return 2; // Moderate signal (2 bars) - } else { - return 3; // Strong signal (3 bars) } + if ($rssi <= -80) { + return 1; // Weak signal (1 bar) + } + if ($rssi <= -60) { + return 2; // Moderate signal (2 bars) + } + + return 3; // Strong signal (3 bars) + } public function getUpdateFirmwareAttribute(): bool @@ -161,7 +166,7 @@ class Device extends Model public function mirrorDevice(): BelongsTo { - return $this->belongsTo(Device::class, 'mirror_device_id'); + return $this->belongsTo(self::class, 'mirror_device_id'); } public function updateFirmware(): BelongsTo diff --git a/app/Models/Plugin.php b/app/Models/Plugin.php index 30c5938..d476aea 100644 --- a/app/Models/Plugin.php +++ b/app/Models/Plugin.php @@ -90,12 +90,13 @@ class Plugin extends Model 'data' => $this->data_payload, ])->render(), ])->render(); - } else { - return view($this->render_markup_view, [ - 'size' => $size, - 'data' => $this->data_payload, - ])->render(); } + + return view($this->render_markup_view, [ + 'size' => $size, + 'data' => $this->data_payload, + ])->render(); + } return '

No render markup yet defined for this plugin.

'; diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 6609fa8..9e5761f 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -3,6 +3,7 @@ namespace App\Providers; use Illuminate\Support\ServiceProvider; +use URL; class AppServiceProvider extends ServiceProvider { @@ -20,7 +21,7 @@ class AppServiceProvider extends ServiceProvider public function boot(): void { if (app()->isProduction() && config('app.force_https')) { - \URL::forceScheme('https'); + URL::forceScheme('https'); } } } diff --git a/app/Services/ImageGenerationService.php b/app/Services/ImageGenerationService.php index addadae..0c1b5a9 100644 --- a/app/Services/ImageGenerationService.php +++ b/app/Services/ImageGenerationService.php @@ -5,9 +5,14 @@ namespace App\Services; use App\Enums\ImageFormat; use App\Models\Device; use App\Models\Plugin; +use Exception; use Illuminate\Support\Facades\Storage; +use Imagick; +use ImagickException; use ImagickPixel; +use Log; use Ramsey\Uuid\Uuid; +use RuntimeException; use Spatie\Browsershot\Browsershot; use Wnx\SidecarBrowsershot\BrowsershotLambda; @@ -26,9 +31,9 @@ class ImageGenerationService BrowsershotLambda::html($markup) ->windowSize(800, 480) ->save($pngPath); - } catch (\Exception $e) { - \Log::error('Failed to generate PNG: '.$e->getMessage()); - throw new \RuntimeException('Failed to generate PNG: '.$e->getMessage(), 0, $e); + } catch (Exception $e) { + Log::error('Failed to generate PNG: '.$e->getMessage()); + throw new RuntimeException('Failed to generate PNG: '.$e->getMessage(), 0, $e); } } else { try { @@ -36,25 +41,25 @@ class ImageGenerationService ->setOption('args', config('app.puppeteer_docker') ? ['--no-sandbox', '--disable-setuid-sandbox', '--disable-gpu'] : []) ->windowSize(800, 480) ->save($pngPath); - } catch (\Exception $e) { - \Log::error('Failed to generate PNG: '.$e->getMessage()); - throw new \RuntimeException('Failed to generate PNG: '.$e->getMessage(), 0, $e); + } catch (Exception $e) { + Log::error('Failed to generate PNG: '.$e->getMessage()); + throw new RuntimeException('Failed to generate PNG: '.$e->getMessage(), 0, $e); } } switch ($device->image_format) { case ImageFormat::BMP3_1BIT_SRGB->value: try { - ImageGenerationService::convertToBmpImageMagick($pngPath, $bmpPath); - } catch (\ImagickException $e) { - throw new \RuntimeException('Failed to convert image to BMP: '.$e->getMessage(), 0, $e); + self::convertToBmpImageMagick($pngPath, $bmpPath); + } catch (ImagickException $e) { + throw new RuntimeException('Failed to convert image to BMP: '.$e->getMessage(), 0, $e); } break; case ImageFormat::PNG_8BIT_GRAYSCALE->value: case ImageFormat::PNG_8BIT_256C->value: try { - ImageGenerationService::convertToPngImageMagick($pngPath, $device->width, $device->height, $device->rotate, quantize: $device->image_format === ImageFormat::PNG_8BIT_GRAYSCALE); - } catch (\ImagickException $e) { - throw new \RuntimeException('Failed to convert image to PNG: '.$e->getMessage(), 0, $e); + self::convertToPngImageMagick($pngPath, $device->width, $device->height, $device->rotate, quantize: $device->image_format === ImageFormat::PNG_8BIT_GRAYSCALE); + } catch (ImagickException $e) { + throw new RuntimeException('Failed to convert image to PNG: '.$e->getMessage(), 0, $e); } break; case ImageFormat::AUTO->value: @@ -62,33 +67,33 @@ class ImageGenerationService if (isset($device->last_firmware_version) && version_compare($device->last_firmware_version, '1.5.2', '<')) { try { - ImageGenerationService::convertToBmpImageMagick($pngPath, $bmpPath); - } catch (\ImagickException $e) { - throw new \RuntimeException('Failed to convert image to BMP: '.$e->getMessage(), 0, $e); + self::convertToBmpImageMagick($pngPath, $bmpPath); + } catch (ImagickException $e) { + throw new RuntimeException('Failed to convert image to BMP: '.$e->getMessage(), 0, $e); } } else { try { - ImageGenerationService::convertToPngImageMagick($pngPath, $device->width, $device->height, $device->rotate); - } catch (\ImagickException $e) { - throw new \RuntimeException('Failed to convert image to PNG: '.$e->getMessage(), 0, $e); + self::convertToPngImageMagick($pngPath, $device->width, $device->height, $device->rotate); + } catch (ImagickException $e) { + throw new RuntimeException('Failed to convert image to PNG: '.$e->getMessage(), 0, $e); } } } $device->update(['current_screen_image' => $uuid]); - \Log::info("Device $device->id: updated with new image: $uuid"); + Log::info("Device $device->id: updated with new image: $uuid"); return $uuid; } /** - * @throws \ImagickException + * @throws ImagickException */ private static function convertToBmpImageMagick(string $pngPath, string $bmpPath): void { - $imagick = new \Imagick($pngPath); - $imagick->setImageType(\Imagick::IMGTYPE_GRAYSCALE); - $imagick->quantizeImage(2, \Imagick::COLORSPACE_GRAY, 0, true, false); + $imagick = new Imagick($pngPath); + $imagick->setImageType(Imagick::IMGTYPE_GRAYSCALE); + $imagick->quantizeImage(2, Imagick::COLORSPACE_GRAY, 0, true, false); $imagick->setImageDepth(1); $imagick->stripImage(); $imagick->setFormat('BMP3'); @@ -97,20 +102,20 @@ class ImageGenerationService } /** - * @throws \ImagickException + * @throws ImagickException */ private static function convertToPngImageMagick(string $pngPath, ?int $width, ?int $height, ?int $rotate, $quantize = true): void { - $imagick = new \Imagick($pngPath); + $imagick = new Imagick($pngPath); if ($width !== 800 || $height !== 480) { - $imagick->resizeImage($width, $height, \Imagick::FILTER_LANCZOS, 1, true); + $imagick->resizeImage($width, $height, Imagick::FILTER_LANCZOS, 1, true); } if ($rotate !== null && $rotate !== 0) { $imagick->rotateImage(new ImagickPixel('black'), $rotate); } - $imagick->setImageType(\Imagick::IMGTYPE_GRAYSCALE); + $imagick->setImageType(Imagick::IMGTYPE_GRAYSCALE); if ($quantize) { - $imagick->quantizeImage(2, \Imagick::COLORSPACE_GRAY, 0, true, false); + $imagick->quantizeImage(2, Imagick::COLORSPACE_GRAY, 0, true, false); } $imagick->setImageDepth(8); $imagick->stripImage(); @@ -152,7 +157,7 @@ class ImageGenerationService ) { // TODO cache image per device $plugin->update(['current_image' => null]); - \Log::debug('Skip cache as devices with other dimensions exist'); + Log::debug('Skip cache as devices with other dimensions exist'); } } } diff --git a/config/sidecar.php b/config/sidecar.php index cb83e0e..b825e9d 100644 --- a/config/sidecar.php +++ b/config/sidecar.php @@ -5,6 +5,6 @@ return [ * All of your function classes that you'd like to deploy go here. */ 'functions' => [ - \Wnx\SidecarBrowsershot\Functions\BrowsershotFunction::class, + Wnx\SidecarBrowsershot\Functions\BrowsershotFunction::class, ], ]; diff --git a/pint.json b/pint.json new file mode 100644 index 0000000..6b39126 --- /dev/null +++ b/pint.json @@ -0,0 +1,34 @@ +{ + "preset": "laravel", + "rules": { + "array_push": true, + "backtick_to_shell_exec": true, + "date_time_immutable": true, + "lowercase_keywords": true, + "lowercase_static_reference": true, + "final_internal_class": true, + "final_public_method_for_abstract_class": true, + "fully_qualified_strict_types": true, + "global_namespace_import": { + "import_classes": true, + "import_constants": true, + "import_functions": true + }, + "mb_str_functions": true, + "modernize_types_casting": true, + "new_with_parentheses": false, + "no_superfluous_elseif": true, + "no_useless_else": true, + "no_multiple_statements_per_line": true, + "ordered_interfaces": true, + "ordered_traits": true, + "protected_to_private": true, + "self_accessor": true, + "self_static_accessor": true, + "strict_comparison": true, + "visibility_required": true, + "increment_style": { + "style": "pre" + } + } +} diff --git a/routes/api.php b/routes/api.php index f91df50..a346783 100644 --- a/routes/api.php +++ b/routes/api.php @@ -71,7 +71,7 @@ Route::get('/display', function (Request $request) { ImageGenerationService::resetIfNotCacheable($plugin); // Check and update stale data if needed - if ($plugin->isDataStale() || $plugin->current_image == null) { + if ($plugin->isDataStale() || $plugin->current_image === null) { $plugin->updateDataPayload(); $markup = $plugin->render(); @@ -80,7 +80,7 @@ Route::get('/display', function (Request $request) { $plugin->refresh(); - if ($plugin->current_image != null) { + if ($plugin->current_image !== null) { $playlistItem->update(['last_displayed_at' => now()]); $device->update(['current_screen_image' => $plugin->current_image]); } @@ -93,7 +93,7 @@ Route::get('/display', function (Request $request) { foreach ($plugins as $plugin) { // Reset cache if Devices with different dimensions exist ImageGenerationService::resetIfNotCacheable($plugin); - if ($plugin->isDataStale() || $plugin->current_image == null) { + if ($plugin->isDataStale() || $plugin->current_image === null) { $plugin->updateDataPayload(); } } @@ -103,7 +103,7 @@ Route::get('/display', function (Request $request) { $device->refresh(); - if ($device->current_screen_image != null) { + if ($device->current_screen_image !== null) { $playlistItem->update(['last_displayed_at' => now()]); } } @@ -214,7 +214,7 @@ Route::post('/log', function (Request $request) { $logs = $request->json('log.logs_array', []); foreach ($logs as $log) { - \Log::info('Device Log', $log); + Log::info('Device Log', $log); DeviceLog::create([ 'device_id' => $device->id, 'device_timestamp' => $log['creation_timestamp'] ?? now(), @@ -342,7 +342,7 @@ Route::get('/current_screen', function (Request $request) { }); Route::post('custom_plugins/{plugin_uuid}', function (string $plugin_uuid) { - $plugin = \App\Models\Plugin::where('uuid', $plugin_uuid)->firstOrFail(); + $plugin = Plugin::where('uuid', $plugin_uuid)->firstOrFail(); // Check if plugin uses webhook strategy if ($plugin->data_strategy !== 'webhook') { diff --git a/routes/console.php b/routes/console.php index b0c43f3..9aecc63 100644 --- a/routes/console.php +++ b/routes/console.php @@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Schedule; Schedule::job(FetchProxyCloudResponses::class, [])->cron( config('services.trmnl.proxy_refresh_cron') ? config('services.trmnl.proxy_refresh_cron') : - sprintf('*/%s * * * *', intval(config('services.trmnl.proxy_refresh_minutes', 15))) + sprintf('*/%s * * * *', (int) (config('services.trmnl.proxy_refresh_minutes', 15))) ); Schedule::job(FirmwarePollJob::class)->daily(); diff --git a/tests/Feature/Api/DeviceEndpointsTest.php b/tests/Feature/Api/DeviceEndpointsTest.php index 46ea18a..654fedd 100644 --- a/tests/Feature/Api/DeviceEndpointsTest.php +++ b/tests/Feature/Api/DeviceEndpointsTest.php @@ -8,7 +8,7 @@ use App\Models\User; use Illuminate\Support\Facades\Storage; use Laravel\Sanctum\Sanctum; -uses(\Illuminate\Foundation\Testing\RefreshDatabase::class); +uses(Illuminate\Foundation\Testing\RefreshDatabase::class); beforeEach(function () { Storage::fake('public'); diff --git a/tests/Feature/Api/DeviceImageFormatTest.php b/tests/Feature/Api/DeviceImageFormatTest.php index 2997853..ff24744 100644 --- a/tests/Feature/Api/DeviceImageFormatTest.php +++ b/tests/Feature/Api/DeviceImageFormatTest.php @@ -3,7 +3,7 @@ use App\Models\Device; use Illuminate\Support\Facades\Storage; -uses(\Illuminate\Foundation\Testing\RefreshDatabase::class); +uses(Illuminate\Foundation\Testing\RefreshDatabase::class); beforeEach(function () { Storage::fake('public'); diff --git a/tests/Feature/Auth/AuthenticationTest.php b/tests/Feature/Auth/AuthenticationTest.php index 61d04f1..96edffc 100644 --- a/tests/Feature/Auth/AuthenticationTest.php +++ b/tests/Feature/Auth/AuthenticationTest.php @@ -3,7 +3,7 @@ use App\Models\User; use Livewire\Volt\Volt as LivewireVolt; -uses(\Illuminate\Foundation\Testing\RefreshDatabase::class); +uses(Illuminate\Foundation\Testing\RefreshDatabase::class); test('login screen can be rendered', function () { $response = $this->get('/login'); diff --git a/tests/Feature/Auth/EmailVerificationTest.php b/tests/Feature/Auth/EmailVerificationTest.php index 37a205f..52a663d 100644 --- a/tests/Feature/Auth/EmailVerificationTest.php +++ b/tests/Feature/Auth/EmailVerificationTest.php @@ -5,7 +5,7 @@ use Illuminate\Auth\Events\Verified; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\URL; -uses(\Illuminate\Foundation\Testing\RefreshDatabase::class); +uses(Illuminate\Foundation\Testing\RefreshDatabase::class); test('email verification screen can be rendered', function () { $user = User::factory()->unverified()->create(); diff --git a/tests/Feature/Auth/PasswordConfirmationTest.php b/tests/Feature/Auth/PasswordConfirmationTest.php index 3f9b423..efb11ce 100644 --- a/tests/Feature/Auth/PasswordConfirmationTest.php +++ b/tests/Feature/Auth/PasswordConfirmationTest.php @@ -3,7 +3,7 @@ use App\Models\User; use Livewire\Volt\Volt; -uses(\Illuminate\Foundation\Testing\RefreshDatabase::class); +uses(Illuminate\Foundation\Testing\RefreshDatabase::class); test('confirm password screen can be rendered', function () { $user = User::factory()->create(); diff --git a/tests/Feature/Auth/PasswordResetTest.php b/tests/Feature/Auth/PasswordResetTest.php index b678d73..86fda9d 100644 --- a/tests/Feature/Auth/PasswordResetTest.php +++ b/tests/Feature/Auth/PasswordResetTest.php @@ -5,7 +5,7 @@ use Illuminate\Auth\Notifications\ResetPassword; use Illuminate\Support\Facades\Notification; use Livewire\Volt\Volt; -uses(\Illuminate\Foundation\Testing\RefreshDatabase::class); +uses(Illuminate\Foundation\Testing\RefreshDatabase::class); test('reset password link screen can be rendered', function () { $response = $this->get('/forgot-password'); diff --git a/tests/Feature/Auth/RegistrationTest.php b/tests/Feature/Auth/RegistrationTest.php index 1ef6256..a1c4c07 100644 --- a/tests/Feature/Auth/RegistrationTest.php +++ b/tests/Feature/Auth/RegistrationTest.php @@ -2,7 +2,7 @@ use Livewire\Volt\Volt; -uses(\Illuminate\Foundation\Testing\RefreshDatabase::class); +uses(Illuminate\Foundation\Testing\RefreshDatabase::class); test('registration screen can be rendered', function () { $response = $this->get('/register'); diff --git a/tests/Feature/DashboardTest.php b/tests/Feature/DashboardTest.php index e11099a..4ed5100 100644 --- a/tests/Feature/DashboardTest.php +++ b/tests/Feature/DashboardTest.php @@ -2,7 +2,7 @@ use App\Models\User; -uses(\Illuminate\Foundation\Testing\RefreshDatabase::class); +uses(Illuminate\Foundation\Testing\RefreshDatabase::class); test('guests are redirected to the login page', function () { $response = $this->get('/dashboard'); diff --git a/tests/Feature/Devices/DeviceTest.php b/tests/Feature/Devices/DeviceTest.php index 517be40..6848bdd 100644 --- a/tests/Feature/Devices/DeviceTest.php +++ b/tests/Feature/Devices/DeviceTest.php @@ -2,7 +2,7 @@ use App\Models\Device; -uses(\Illuminate\Foundation\Testing\RefreshDatabase::class); +uses(Illuminate\Foundation\Testing\RefreshDatabase::class); test('device can be created with basic attributes', function () { $device = Device::factory()->create([ diff --git a/tests/Feature/Devices/ManageTest.php b/tests/Feature/Devices/ManageTest.php index b54d6a8..a629cfe 100644 --- a/tests/Feature/Devices/ManageTest.php +++ b/tests/Feature/Devices/ManageTest.php @@ -4,7 +4,7 @@ use App\Models\Device; use App\Models\User; use Livewire\Volt\Volt; -uses(\Illuminate\Foundation\Testing\RefreshDatabase::class); +uses(Illuminate\Foundation\Testing\RefreshDatabase::class); test('device management page can be rendered', function () { $user = User::factory()->create(); diff --git a/tests/Feature/FetchProxyCloudResponsesTest.php b/tests/Feature/FetchProxyCloudResponsesTest.php index 1e2af3d..5f5dc65 100644 --- a/tests/Feature/FetchProxyCloudResponsesTest.php +++ b/tests/Feature/FetchProxyCloudResponsesTest.php @@ -5,7 +5,7 @@ use App\Models\Device; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Storage; -uses(\Illuminate\Foundation\Testing\RefreshDatabase::class); +uses(Illuminate\Foundation\Testing\RefreshDatabase::class); beforeEach(function () { Storage::fake('public'); diff --git a/tests/Feature/GenerateScreenJobTest.php b/tests/Feature/GenerateScreenJobTest.php index feb1f40..c245897 100644 --- a/tests/Feature/GenerateScreenJobTest.php +++ b/tests/Feature/GenerateScreenJobTest.php @@ -4,7 +4,7 @@ use App\Jobs\GenerateScreenJob; use App\Models\Device; use Illuminate\Support\Facades\Storage; -uses(\Illuminate\Foundation\Testing\RefreshDatabase::class); +uses(Illuminate\Foundation\Testing\RefreshDatabase::class); beforeEach(function () { Storage::fake('public'); diff --git a/tests/Feature/Jobs/CleanupDeviceLogsJobTest.php b/tests/Feature/Jobs/CleanupDeviceLogsJobTest.php index 5d675f5..15888c0 100644 --- a/tests/Feature/Jobs/CleanupDeviceLogsJobTest.php +++ b/tests/Feature/Jobs/CleanupDeviceLogsJobTest.php @@ -13,7 +13,7 @@ test('it keeps only the 50 most recent logs per device', function () { $device2 = Device::factory()->create(); // Create 60 logs for each device with different timestamps - for ($i = 0; $i < 60; $i++) { + for ($i = 0; $i < 60; ++$i) { DeviceLog::factory()->create([ 'device_id' => $device1->id, 'device_timestamp' => now()->subMinutes($i), @@ -37,7 +37,7 @@ test('it keeps only the 50 most recent logs per device', function () { $device2Logs = $device2->logs()->orderByDesc('device_timestamp')->get(); // Check that the timestamps are in descending order - for ($i = 0; $i < 49; $i++) { + for ($i = 0; $i < 49; ++$i) { expect($device1Logs[$i]->device_timestamp->gt($device1Logs[$i + 1]->device_timestamp))->toBeTrue() ->and($device2Logs[$i]->device_timestamp->gt($device2Logs[$i + 1]->device_timestamp))->toBeTrue(); } diff --git a/tests/Feature/Settings/PasswordUpdateTest.php b/tests/Feature/Settings/PasswordUpdateTest.php index d0c32c5..3252860 100644 --- a/tests/Feature/Settings/PasswordUpdateTest.php +++ b/tests/Feature/Settings/PasswordUpdateTest.php @@ -4,7 +4,7 @@ use App\Models\User; use Illuminate\Support\Facades\Hash; use Livewire\Volt\Volt; -uses(\Illuminate\Foundation\Testing\RefreshDatabase::class); +uses(Illuminate\Foundation\Testing\RefreshDatabase::class); test('password can be updated', function () { $user = User::factory()->create([ diff --git a/tests/Feature/Settings/ProfileUpdateTest.php b/tests/Feature/Settings/ProfileUpdateTest.php index 6628ccc..48ea114 100644 --- a/tests/Feature/Settings/ProfileUpdateTest.php +++ b/tests/Feature/Settings/ProfileUpdateTest.php @@ -3,7 +3,7 @@ use App\Models\User; use Livewire\Volt\Volt; -uses(\Illuminate\Foundation\Testing\RefreshDatabase::class); +uses(Illuminate\Foundation\Testing\RefreshDatabase::class); test('profile page is displayed', function () { $this->actingAs($user = User::factory()->create()); diff --git a/tests/Unit/Models/DeviceLogTest.php b/tests/Unit/Models/DeviceLogTest.php index d34e8d7..37e128f 100644 --- a/tests/Unit/Models/DeviceLogTest.php +++ b/tests/Unit/Models/DeviceLogTest.php @@ -36,7 +36,7 @@ test('device log casts device_timestamp to datetime', function () { 'device_timestamp' => $timestamp, ]); - expect($log->device_timestamp)->toBeInstanceOf(\Carbon\Carbon::class) + expect($log->device_timestamp)->toBeInstanceOf(Carbon\Carbon::class) ->and($log->device_timestamp->timestamp)->toBe($timestamp->timestamp); }); @@ -45,7 +45,7 @@ test('device log factory creates valid data', function () { $log = DeviceLog::factory()->create(); expect($log->device_id)->toBeInt() - ->and($log->device_timestamp)->toBeInstanceOf(\Carbon\Carbon::class) + ->and($log->device_timestamp)->toBeInstanceOf(Carbon\Carbon::class) ->and($log->log_entry)->toBeArray() ->and($log->log_entry)->toHaveKeys(['creation_timestamp', 'device_status_stamp', 'log_id', 'log_message', 'log_codeline', 'log_sourcefile', 'additional_info']); }); diff --git a/tests/Unit/Models/PluginTest.php b/tests/Unit/Models/PluginTest.php index f5cd2b3..19b09a0 100644 --- a/tests/Unit/Models/PluginTest.php +++ b/tests/Unit/Models/PluginTest.php @@ -2,7 +2,7 @@ use App\Models\Plugin; -uses(\Illuminate\Foundation\Testing\RefreshDatabase::class); +uses(Illuminate\Foundation\Testing\RefreshDatabase::class); test('plugin has required attributes', function () { $plugin = Plugin::factory()->create([ @@ -26,7 +26,7 @@ test('plugin automatically generates uuid on creation', function () { }); test('plugin can have custom uuid', function () { - $uuid = \Illuminate\Support\Str::uuid(); + $uuid = Illuminate\Support\Str::uuid(); $plugin = Plugin::factory()->create(['uuid' => $uuid]); expect($plugin->uuid)->toBe($uuid);