refactor: apply rector
Some checks are pending
tests / ci (push) Waiting to run

This commit is contained in:
Benjamin Nussbaum 2025-09-24 20:31:32 +02:00
parent c67a182cf2
commit b4b6286172
89 changed files with 672 additions and 666 deletions

View file

@ -14,13 +14,13 @@ use Laravel\Sanctum\Sanctum;
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
beforeEach(function () {
beforeEach(function (): void {
TrmnlPipeline::fake();
Storage::fake('public');
Storage::disk('public')->makeDirectory('/images/generated');
});
test('device can fetch display data with valid credentials', function () {
test('device can fetch display data with valid credentials', function (): void {
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
'api_key' => 'test-api-key',
@ -52,7 +52,7 @@ test('device can fetch display data with valid credentials', function () {
->last_firmware_version->toBe('1.0.0');
});
test('display endpoint includes image_url_timeout when configured', function () {
test('display endpoint includes image_url_timeout when configured', function (): void {
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
'api_key' => 'test-api-key',
@ -74,7 +74,7 @@ test('display endpoint includes image_url_timeout when configured', function ()
]);
});
test('display endpoint omits image_url_timeout when not configured', function () {
test('display endpoint omits image_url_timeout when not configured', function (): void {
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
'api_key' => 'test-api-key',
@ -94,7 +94,7 @@ test('display endpoint omits image_url_timeout when not configured', function ()
->assertJsonMissing(['image_url_timeout']);
});
test('new device is auto-assigned to user with auto-assign enabled', function () {
test('new device is auto-assigned to user with auto-assign enabled', function (): void {
$user = User::factory()->create(['assign_new_devices' => true]);
$response = $this->withHeaders([
@ -114,7 +114,7 @@ test('new device is auto-assigned to user with auto-assign enabled', function ()
->api_key->toBe('new-device-key');
});
test('new device is auto-assigned and mirrors specified device', function () {
test('new device is auto-assigned and mirrors specified device', function (): void {
// Create a source device that will be mirrored
$sourceDevice = Device::factory()->create([
'mac_address' => 'AA:BB:CC:DD:EE:FF',
@ -153,7 +153,7 @@ test('new device is auto-assigned and mirrors specified device', function () {
]);
});
test('device setup endpoint returns correct data', function () {
test('device setup endpoint returns correct data', function (): void {
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
'api_key' => 'test-api-key',
@ -172,7 +172,7 @@ test('device setup endpoint returns correct data', function () {
]);
});
test('device can submit logs', function () {
test('device can submit logs', function (): void {
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
'api_key' => 'test-api-key',
@ -200,7 +200,7 @@ test('device can submit logs', function () {
expect($device->logs()->count())->toBe(1);
});
test('device can submit logs in revised format', function () {
test('device can submit logs in revised format', function (): void {
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
'api_key' => 'test-api-key',
@ -240,7 +240,7 @@ test('device can submit logs in revised format', function () {
// $response->assertOk();
// });
test('user cannot update display for devices they do not own', function () {
test('user cannot update display for devices they do not own', function (): void {
$user = User::factory()->create();
$otherUser = User::factory()->create();
$device = Device::factory()->create(['user_id' => $otherUser->id]);
@ -255,7 +255,7 @@ test('user cannot update display for devices they do not own', function () {
$response->assertForbidden();
});
test('invalid device credentials return error', function () {
test('invalid device credentials return error', function (): void {
$response = $this->withHeaders([
'id' => 'invalid-mac',
'access-token' => 'invalid-token',
@ -265,7 +265,7 @@ test('invalid device credentials return error', function () {
->assertJson(['message' => 'MAC Address not registered or invalid access token']);
});
test('log endpoint requires valid device credentials', function () {
test('log endpoint requires valid device credentials', function (): void {
$response = $this->withHeaders([
'id' => 'invalid-mac',
'access-token' => 'invalid-token',
@ -275,7 +275,7 @@ test('log endpoint requires valid device credentials', function () {
->assertJson(['message' => 'Device not found or invalid access token']);
});
test('update_firmware flag is only returned once', function () {
test('update_firmware flag is only returned once', function (): void {
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
'api_key' => 'test-api-key',
@ -320,7 +320,7 @@ test('update_firmware flag is only returned once', function () {
expect($device->proxy_cloud_response['update_firmware'])->toBeFalse();
});
test('authenticated user can fetch device status', function () {
test('authenticated user can fetch device status', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create([
'user_id' => $user->id,
@ -354,7 +354,7 @@ test('authenticated user can fetch device status', function () {
]);
});
test('user cannot fetch status for devices they do not own', function () {
test('user cannot fetch status for devices they do not own', function (): void {
$user = User::factory()->create();
$otherUser = User::factory()->create();
$device = Device::factory()->create(['user_id' => $otherUser->id]);
@ -366,7 +366,7 @@ test('user cannot fetch status for devices they do not own', function () {
$response->assertForbidden();
});
test('display status endpoint requires device_id parameter', function () {
test('display status endpoint requires device_id parameter', function (): void {
$user = User::factory()->create();
Sanctum::actingAs($user);
@ -376,7 +376,7 @@ test('display status endpoint requires device_id parameter', function () {
->assertJsonValidationErrors(['device_id']);
});
test('display status endpoint requires valid device_id', function () {
test('display status endpoint requires valid device_id', function (): void {
$user = User::factory()->create();
Sanctum::actingAs($user);
@ -386,7 +386,7 @@ test('display status endpoint requires valid device_id', function () {
->assertJsonValidationErrors(['device_id']);
});
test('device can mirror another device', function () {
test('device can mirror another device', function (): void {
// Create source device with a playlist and image
$sourceDevice = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
@ -428,7 +428,7 @@ test('device can mirror another device', function () {
->last_firmware_version->toBe('1.0.0');
});
test('device can fetch current screen data', function () {
test('device can fetch current screen data', function (): void {
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
'api_key' => 'test-api-key',
@ -451,7 +451,7 @@ test('device can fetch current screen data', function () {
]);
});
test('current_screen endpoint requires valid device credentials', function () {
test('current_screen endpoint requires valid device credentials', function (): void {
$response = $this->withHeaders([
'access-token' => 'invalid-token',
])->get('/api/current_screen');
@ -460,7 +460,7 @@ test('current_screen endpoint requires valid device credentials', function () {
->assertJson(['message' => 'Device not found or invalid access token']);
});
test('authenticated user can fetch their devices', function () {
test('authenticated user can fetch their devices', function (): void {
$user = User::factory()->create();
$devices = Device::factory()->count(2)->create([
'user_id' => $user->id,
@ -502,7 +502,7 @@ test('authenticated user can fetch their devices', function () {
]);
});
test('plugin caches image until data is stale', function () {
test('plugin caches image until data is stale', function (): void {
// Create source device with a playlist
$device = Device::factory()->create([
'mac_address' => '55:11:22:33:44:55',
@ -577,7 +577,7 @@ test('plugin caches image until data is stale', function () {
->not->toBe($firstResponse['filename']);
});
test('plugins in playlist are rendered in order', function () {
test('plugins in playlist are rendered in order', function (): void {
// Create source device with a playlist
$device = Device::factory()->create([
'mac_address' => '55:11:22:33:44:55',
@ -681,7 +681,7 @@ test('plugins in playlist are rendered in order', function () {
->not->toBe($secondResponse['filename']);
});
test('display endpoint updates last_refreshed_at timestamp', function () {
test('display endpoint updates last_refreshed_at timestamp', function (): void {
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
'api_key' => 'test-api-key',
@ -702,7 +702,7 @@ test('display endpoint updates last_refreshed_at timestamp', function () {
->and($device->last_refreshed_at->diffInSeconds(now()))->toBeLessThan(2);
});
test('display endpoint updates last_refreshed_at timestamp for mirrored devices', function () {
test('display endpoint updates last_refreshed_at timestamp for mirrored devices', function (): void {
// Create source device
$sourceDevice = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
@ -731,7 +731,7 @@ test('display endpoint updates last_refreshed_at timestamp for mirrored devices'
->and($mirrorDevice->last_refreshed_at->diffInSeconds(now()))->toBeLessThan(2);
});
test('display endpoint handles mashup playlist items correctly', function () {
test('display endpoint handles mashup playlist items correctly', function (): void {
// Create a device
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
@ -791,7 +791,7 @@ test('display endpoint handles mashup playlist items correctly', function () {
expect($playlistItem->last_displayed_at)->not->toBeNull();
});
test('device in sleep mode returns sleep image and correct refresh rate', function () {
test('device in sleep mode returns sleep image and correct refresh rate', function (): void {
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
'api_key' => 'test-api-key',
@ -821,7 +821,7 @@ test('device in sleep mode returns sleep image and correct refresh rate', functi
Carbon\Carbon::setTestNow(); // Clear test time
});
test('device not in sleep mode returns normal image', function () {
test('device not in sleep mode returns normal image', function (): void {
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
'api_key' => 'test-api-key',
@ -850,7 +850,7 @@ test('device not in sleep mode returns normal image', function () {
Carbon\Carbon::setTestNow(); // Clear test time
});
test('device returns sleep.png and correct refresh time when paused', function () {
test('device returns sleep.png and correct refresh time when paused', function (): void {
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
'api_key' => 'test-api-key',
@ -872,7 +872,7 @@ test('device returns sleep.png and correct refresh time when paused', function (
expect($json['refresh_rate'])->toBeLessThanOrEqual(3600); // ~60 min
});
test('screens endpoint accepts nullable file_name', function () {
test('screens endpoint accepts nullable file_name', function (): void {
Queue::fake();
$device = Device::factory()->create([
@ -894,7 +894,7 @@ test('screens endpoint accepts nullable file_name', function () {
Queue::assertPushed(GenerateScreenJob::class);
});
test('screens endpoint returns 404 for invalid device credentials', function () {
test('screens endpoint returns 404 for invalid device credentials', function (): void {
$response = $this->withHeaders([
'id' => 'invalid-mac',
'access-token' => 'invalid-key',
@ -911,7 +911,7 @@ test('screens endpoint returns 404 for invalid device credentials', function ()
]);
});
test('setup endpoint assigns device model when model-id header is provided', function () {
test('setup endpoint assigns device model when model-id header is provided', function (): void {
$user = User::factory()->create(['assign_new_devices' => true]);
$deviceModel = DeviceModel::factory()->create([
'name' => 'test-model',
@ -934,7 +934,7 @@ test('setup endpoint assigns device model when model-id header is provided', fun
->and($device->device_model_id)->toBe($deviceModel->id);
});
test('setup endpoint handles non-existent device model gracefully', function () {
test('setup endpoint handles non-existent device model gracefully', function (): void {
$user = User::factory()->create(['assign_new_devices' => true]);
$response = $this->withHeaders([

View file

@ -10,12 +10,12 @@ use Illuminate\Support\Facades\Storage;
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
beforeEach(function () {
beforeEach(function (): void {
Storage::fake('public');
Storage::disk('public')->makeDirectory('/images/generated');
});
test('device with firmware version 1.5.1 gets bmp format', function () {
test('device with firmware version 1.5.1 gets bmp format', function (): void {
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
'api_key' => 'test-api-key',
@ -52,7 +52,7 @@ test('device with firmware version 1.5.1 gets bmp format', function () {
]);
});
test('device with firmware version 1.5.2 gets png format', function () {
test('device with firmware version 1.5.2 gets png format', function (): void {
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
'api_key' => 'test-api-key',
@ -88,7 +88,7 @@ test('device with firmware version 1.5.2 gets png format', function () {
]);
});
test('device falls back to bmp when png does not exist', function () {
test('device falls back to bmp when png does not exist', function (): void {
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:55',
'api_key' => 'test-api-key',
@ -124,7 +124,7 @@ test('device falls back to bmp when png does not exist', function () {
]);
});
test('device without device_model_id and image_format bmp3_1bit_srgb returns bmp when plugin is rendered', function () {
test('device without device_model_id and image_format bmp3_1bit_srgb returns bmp when plugin is rendered', function (): void {
// Create a user with auto-assign enabled
$user = User::factory()->create([
'assign_new_devices' => true,

View file

@ -8,7 +8,7 @@ use Illuminate\Http\UploadedFile;
use Illuminate\Support\Str;
use Laravel\Sanctum\Sanctum;
it('accepts a plugin settings archive and updates the plugin', function () {
it('accepts a plugin settings archive and updates the plugin', function (): void {
$user = User::factory()->create();
$plugin = Plugin::factory()->create([
'user_id' => $user->id,

View file

@ -5,13 +5,13 @@ use Livewire\Volt\Volt as LivewireVolt;
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
test('login screen can be rendered', function () {
test('login screen can be rendered', function (): void {
$response = $this->get('/login');
$response->assertStatus(200);
});
test('users can authenticate using the login screen', function () {
test('users can authenticate using the login screen', function (): void {
$user = User::factory()->create();
$response = LivewireVolt::test('auth.login')
@ -26,7 +26,7 @@ test('users can authenticate using the login screen', function () {
$this->assertAuthenticated();
});
test('users can not authenticate with invalid password', function () {
test('users can not authenticate with invalid password', function (): void {
$user = User::factory()->create();
$this->post('/login', [
@ -37,7 +37,7 @@ test('users can not authenticate with invalid password', function () {
$this->assertGuest();
});
test('users can logout', function () {
test('users can logout', function (): void {
$user = User::factory()->create();
$response = $this->actingAs($user)->post('/logout');

View file

@ -7,7 +7,7 @@ use Illuminate\Support\Facades\URL;
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
test('email verification screen can be rendered', function () {
test('email verification screen can be rendered', function (): void {
$user = User::factory()->unverified()->create();
$response = $this->actingAs($user)->get('/verify-email');
@ -15,7 +15,7 @@ test('email verification screen can be rendered', function () {
$response->assertStatus(200);
});
test('email can be verified', function () {
test('email can be verified', function (): void {
$user = User::factory()->unverified()->create();
Event::fake();
@ -23,7 +23,7 @@ test('email can be verified', function () {
$verificationUrl = URL::temporarySignedRoute(
'verification.verify',
now()->addMinutes(60),
['id' => $user->id, 'hash' => sha1($user->email)]
['id' => $user->id, 'hash' => sha1((string) $user->email)]
);
$response = $this->actingAs($user)->get($verificationUrl);
@ -34,7 +34,7 @@ test('email can be verified', function () {
$response->assertRedirect(route('dashboard', absolute: false).'?verified=1');
});
test('email is not verified with invalid hash', function () {
test('email is not verified with invalid hash', function (): void {
$user = User::factory()->unverified()->create();
$verificationUrl = URL::temporarySignedRoute(

View file

@ -5,7 +5,7 @@ use Livewire\Volt\Volt;
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
test('confirm password screen can be rendered', function () {
test('confirm password screen can be rendered', function (): void {
$user = User::factory()->create();
$response = $this->actingAs($user)->get('/confirm-password');
@ -13,7 +13,7 @@ test('confirm password screen can be rendered', function () {
$response->assertStatus(200);
});
test('password can be confirmed', function () {
test('password can be confirmed', function (): void {
$user = User::factory()->create();
$this->actingAs($user);
@ -27,7 +27,7 @@ test('password can be confirmed', function () {
->assertRedirect(route('dashboard', absolute: false));
});
test('password is not confirmed with invalid password', function () {
test('password is not confirmed with invalid password', function (): void {
$user = User::factory()->create();
$this->actingAs($user);

View file

@ -7,13 +7,13 @@ use Livewire\Volt\Volt;
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
test('reset password link screen can be rendered', function () {
test('reset password link screen can be rendered', function (): void {
$response = $this->get('/forgot-password');
$response->assertStatus(200);
});
test('reset password link can be requested', function () {
test('reset password link can be requested', function (): void {
Notification::fake();
$user = User::factory()->create();
@ -25,7 +25,7 @@ test('reset password link can be requested', function () {
Notification::assertSentTo($user, ResetPassword::class);
});
test('reset password screen can be rendered', function () {
test('reset password screen can be rendered', function (): void {
Notification::fake();
$user = User::factory()->create();
@ -34,7 +34,7 @@ test('reset password screen can be rendered', function () {
->set('email', $user->email)
->call('sendPasswordResetLink');
Notification::assertSentTo($user, ResetPassword::class, function ($notification) {
Notification::assertSentTo($user, ResetPassword::class, function ($notification): true {
$response = $this->get('/reset-password/'.$notification->token);
$response->assertStatus(200);
@ -43,7 +43,7 @@ test('reset password screen can be rendered', function () {
});
});
test('password can be reset with valid token', function () {
test('password can be reset with valid token', function (): void {
Notification::fake();
$user = User::factory()->create();
@ -52,7 +52,7 @@ test('password can be reset with valid token', function () {
->set('email', $user->email)
->call('sendPasswordResetLink');
Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) {
Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user): true {
$response = Volt::test('auth.reset-password', ['token' => $notification->token])
->set('email', $user->email)
->set('password', 'password')

View file

@ -4,13 +4,13 @@ use Livewire\Volt\Volt;
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
test('registration screen can be rendered', function () {
test('registration screen can be rendered', function (): void {
$response = $this->get('/register');
$response->assertStatus(200);
});
test('new users can register', function () {
test('new users can register', function (): void {
$response = Volt::test('auth.register')
->set('name', 'Test User')
->set('email', 'test@example.com')

View file

@ -7,7 +7,7 @@ use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('example recipes seeder command calls seeder with correct user id', function () {
test('example recipes seeder command calls seeder with correct user id', function (): void {
$seeder = Mockery::mock(ExampleRecipesSeeder::class);
$seeder->shouldReceive('run')
->once()
@ -19,14 +19,14 @@ test('example recipes seeder command calls seeder with correct user id', functio
->assertExitCode(0);
});
test('example recipes seeder command has correct signature', function () {
test('example recipes seeder command has correct signature', function (): void {
$command = $this->app->make(App\Console\Commands\ExampleRecipesSeederCommand::class);
expect($command->getName())->toBe('recipes:seed');
expect($command->getDescription())->toBe('Seed example recipes');
});
test('example recipes seeder command prompts for missing input', function () {
test('example recipes seeder command prompts for missing input', function (): void {
$seeder = Mockery::mock(ExampleRecipesSeeder::class);
$seeder->shouldReceive('run')
->once()

View file

@ -3,7 +3,7 @@
use App\Jobs\FetchProxyCloudResponses;
use Illuminate\Support\Facades\Bus;
test('it dispatches fetch proxy cloud responses job', function () {
test('it dispatches fetch proxy cloud responses job', function (): void {
// Prevent the job from actually running
Bus::fake();

View file

@ -6,24 +6,24 @@ use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('firmware check command has correct signature', function () {
test('firmware check command has correct signature', function (): void {
$command = $this->app->make(App\Console\Commands\FirmwareCheckCommand::class);
expect($command->getName())->toBe('trmnl:firmware:check');
expect($command->getDescription())->toBe('Checks for the latest firmware and downloads it if flag --download is passed.');
});
test('firmware check command runs without errors', function () {
test('firmware check command runs without errors', function (): void {
$this->artisan('trmnl:firmware:check')
->assertExitCode(0);
});
test('firmware check command runs with download flag', function () {
test('firmware check command runs with download flag', function (): void {
$this->artisan('trmnl:firmware:check', ['--download' => true])
->assertExitCode(0);
});
test('firmware check command can run successfully', function () {
test('firmware check command can run successfully', function (): void {
$this->artisan('trmnl:firmware:check')
->assertExitCode(0);
});

View file

@ -6,12 +6,12 @@ use App\Models\Device;
use App\Models\Firmware;
use App\Models\User;
test('firmware update command has correct signature', function () {
test('firmware update command has correct signature', function (): void {
$this->artisan('trmnl:firmware:update --help')
->assertExitCode(0);
});
test('firmware update command can be called', function () {
test('firmware update command can be called', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create(['user_id' => $user->id]);
$firmware = Firmware::factory()->create(['version_tag' => '1.0.0']);
@ -26,7 +26,7 @@ test('firmware update command can be called', function () {
expect($device->update_firmware_id)->toBe($firmware->id);
});
test('firmware update command updates all devices when all is selected', function () {
test('firmware update command updates all devices when all is selected', function (): void {
$user = User::factory()->create();
$device1 = Device::factory()->create(['user_id' => $user->id]);
$device2 = Device::factory()->create(['user_id' => $user->id]);
@ -44,7 +44,7 @@ test('firmware update command updates all devices when all is selected', functio
expect($device2->update_firmware_id)->toBe($firmware->id);
});
test('firmware update command aborts when no devices selected', function () {
test('firmware update command aborts when no devices selected', function (): void {
$firmware = Firmware::factory()->create(['version_tag' => '1.0.0']);
$this->artisan('trmnl:firmware:update')
@ -55,7 +55,7 @@ test('firmware update command aborts when no devices selected', function () {
->assertExitCode(0);
});
test('firmware update command calls firmware check when check is selected', function () {
test('firmware update command calls firmware check when check is selected', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create(['user_id' => $user->id]);
$firmware = Firmware::factory()->create(['version_tag' => '1.0.0']);
@ -70,7 +70,7 @@ test('firmware update command calls firmware check when check is selected', func
expect($device->update_firmware_id)->toBe($firmware->id);
});
test('firmware update command calls firmware check with download when download is selected', function () {
test('firmware update command calls firmware check with download when download is selected', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create(['user_id' => $user->id]);
$firmware = Firmware::factory()->create(['version_tag' => '1.0.0']);

View file

@ -8,12 +8,12 @@ use App\Models\PlaylistItem;
use App\Models\Plugin;
use App\Models\User;
test('mashup create command has correct signature', function () {
test('mashup create command has correct signature', function (): void {
$this->artisan('mashup:create --help')
->assertExitCode(0);
});
test('mashup create command creates mashup successfully', function () {
test('mashup create command creates mashup successfully', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create(['user_id' => $user->id]);
$playlist = Playlist::factory()->create(['device_id' => $device->id]);
@ -40,13 +40,13 @@ test('mashup create command creates mashup successfully', function () {
expect($playlistItem->getMashupPluginIds())->toContain($plugin1->id, $plugin2->id);
});
test('mashup create command exits when no devices found', function () {
test('mashup create command exits when no devices found', function (): void {
$this->artisan('mashup:create')
->expectsOutput('No devices found. Please create a device first.')
->assertExitCode(1);
});
test('mashup create command exits when no playlists found for device', function () {
test('mashup create command exits when no playlists found for device', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create(['user_id' => $user->id]);
@ -56,7 +56,7 @@ test('mashup create command exits when no playlists found for device', function
->assertExitCode(1);
});
test('mashup create command exits when no plugins found', function () {
test('mashup create command exits when no plugins found', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create(['user_id' => $user->id]);
$playlist = Playlist::factory()->create(['device_id' => $device->id]);
@ -70,7 +70,7 @@ test('mashup create command exits when no plugins found', function () {
->assertExitCode(1);
});
test('mashup create command validates mashup name length', function () {
test('mashup create command validates mashup name length', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create(['user_id' => $user->id]);
$playlist = Playlist::factory()->create(['device_id' => $device->id]);
@ -86,7 +86,7 @@ test('mashup create command validates mashup name length', function () {
->assertExitCode(1);
});
test('mashup create command validates mashup name maximum length', function () {
test('mashup create command validates mashup name maximum length', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create(['user_id' => $user->id]);
$playlist = Playlist::factory()->create(['device_id' => $device->id]);
@ -104,7 +104,7 @@ test('mashup create command validates mashup name maximum length', function () {
->assertExitCode(1);
});
test('mashup create command uses default name when provided', function () {
test('mashup create command uses default name when provided', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create(['user_id' => $user->id]);
$playlist = Playlist::factory()->create(['device_id' => $device->id]);
@ -128,7 +128,7 @@ test('mashup create command uses default name when provided', function () {
expect($playlistItem)->not->toBeNull();
});
test('mashup create command handles 1x1 layout with single plugin', function () {
test('mashup create command handles 1x1 layout with single plugin', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create(['user_id' => $user->id]);
$playlist = Playlist::factory()->create(['device_id' => $device->id]);

View file

@ -4,12 +4,12 @@ declare(strict_types=1);
use function Pest\Laravel\mock;
test('oidc test command has correct signature', function () {
test('oidc test command has correct signature', function (): void {
$this->artisan('oidc:test --help')
->assertExitCode(0);
});
test('oidc test command runs successfully with disabled oidc', function () {
test('oidc test command runs successfully with disabled oidc', function (): void {
config([
'app.url' => 'http://localhost',
'services.oidc.enabled' => false,
@ -40,7 +40,7 @@ test('oidc test command runs successfully with disabled oidc', function () {
->assertExitCode(0);
});
test('oidc test command runs successfully with enabled oidc but missing config', function () {
test('oidc test command runs successfully with enabled oidc but missing config', function (): void {
config([
'app.url' => 'http://localhost',
'services.oidc.enabled' => true,
@ -70,7 +70,7 @@ test('oidc test command runs successfully with enabled oidc but missing config',
->assertExitCode(0);
});
test('oidc test command runs successfully with partial config', function () {
test('oidc test command runs successfully with partial config', function (): void {
config([
'services.oidc.enabled' => true,
'services.oidc.endpoint' => 'https://example.com',
@ -95,9 +95,9 @@ test('oidc test command runs successfully with partial config', function () {
->assertExitCode(0);
});
test('oidc test command runs successfully with full config but disabled', function () {
test('oidc test command runs successfully with full config but disabled', function (): void {
// Mock the HTTP client to return fake OIDC configuration
mock(GuzzleHttp\Client::class, function ($mock) {
mock(GuzzleHttp\Client::class, function ($mock): void {
$mock->shouldReceive('get')
->with('https://example.com/.well-known/openid-configuration')
->andReturn(new GuzzleHttp\Psr7\Response(200, [], json_encode([
@ -129,9 +129,9 @@ test('oidc test command runs successfully with full config but disabled', functi
->assertExitCode(0);
});
test('oidc test command runs successfully with full config and enabled', function () {
test('oidc test command runs successfully with full config and enabled', function (): void {
// Mock the HTTP client to return fake OIDC configuration
mock(GuzzleHttp\Client::class, function ($mock) {
mock(GuzzleHttp\Client::class, function ($mock): void {
$mock->shouldReceive('get')
->with('https://example.com/.well-known/openid-configuration')
->andReturn(new GuzzleHttp\Psr7\Response(200, [], json_encode([
@ -164,9 +164,9 @@ test('oidc test command runs successfully with full config and enabled', functio
->assertExitCode(0);
});
test('oidc test command handles empty scopes', function () {
test('oidc test command handles empty scopes', function (): void {
// Mock the HTTP client to return fake OIDC configuration
mock(GuzzleHttp\Client::class, function ($mock) {
mock(GuzzleHttp\Client::class, function ($mock): void {
$mock->shouldReceive('get')
->with('https://example.com/.well-known/openid-configuration')
->andReturn(new GuzzleHttp\Psr7\Response(200, [], json_encode([

View file

@ -3,7 +3,7 @@
use App\Jobs\GenerateScreenJob;
use Illuminate\Support\Facades\Bus;
test('it generates screen with default parameters', function () {
test('it generates screen with default parameters', function (): void {
Bus::fake();
$this->artisan('trmnl:screen:generate')

View file

@ -4,12 +4,12 @@ use App\Models\User;
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
test('guests are redirected to the login page', function () {
test('guests are redirected to the login page', function (): void {
$response = $this->get('/dashboard');
$response->assertRedirect('/login');
});
test('authenticated users can visit the dashboard', function () {
test('authenticated users can visit the dashboard', function (): void {
$user = User::factory()->create();
$this->actingAs($user);

View file

@ -10,7 +10,7 @@ use function Pest\Laravel\actingAs;
uses(RefreshDatabase::class);
test('configure view displays last_refreshed_at timestamp', function () {
test('configure view displays last_refreshed_at timestamp', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create([
'user_id' => $user->id,

View file

@ -8,7 +8,7 @@ use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('dashboard shows device image with correct rotation', function () {
test('dashboard shows device image with correct rotation', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create([
'user_id' => $user->id,
@ -28,7 +28,7 @@ test('dashboard shows device image with correct rotation', function () {
$response->assertSee('origin-center');
});
test('device configure page shows device image with correct rotation', function () {
test('device configure page shows device image with correct rotation', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create([
'user_id' => $user->id,
@ -48,7 +48,7 @@ test('device configure page shows device image with correct rotation', function
$response->assertSee('origin-center');
});
test('device with no rotation shows no transform style', function () {
test('device with no rotation shows no transform style', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create([
'user_id' => $user->id,
@ -67,7 +67,7 @@ test('device with no rotation shows no transform style', function () {
$response->assertSee('-rotate-[0deg]');
});
test('device with null rotation defaults to 0', function () {
test('device with null rotation defaults to 0', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create([
'user_id' => $user->id,

View file

@ -5,7 +5,7 @@ use Illuminate\Support\Carbon;
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
test('device can be created with basic attributes', function () {
test('device can be created with basic attributes', function (): void {
$device = Device::factory()->create([
'name' => 'Test Device',
]);
@ -14,7 +14,7 @@ test('device can be created with basic attributes', function () {
->and($device->name)->toBe('Test Device');
});
test('battery percentage is calculated correctly', function () {
test('battery percentage is calculated correctly', function (): void {
$cases = [
['voltage' => 3.0, 'expected' => 0], // Min voltage
['voltage' => 4.2, 'expected' => 100], // Max voltage
@ -34,7 +34,7 @@ test('battery percentage is calculated correctly', function () {
}
});
test('wifi strength is determined correctly', function () {
test('wifi strength is determined correctly', function (): void {
$cases = [
['rssi' => 0, 'expected' => 0], // No signal
['rssi' => -90, 'expected' => 1], // Weak signal
@ -52,7 +52,7 @@ test('wifi strength is determined correctly', function () {
}
});
test('proxy cloud attribute is properly cast to boolean', function () {
test('proxy cloud attribute is properly cast to boolean', function (): void {
$device = Device::factory()->create([
'proxy_cloud' => true,
]);
@ -63,7 +63,7 @@ test('proxy cloud attribute is properly cast to boolean', function () {
expect($device->proxy_cloud)->toBeFalse();
});
test('last log request is properly cast to json', function () {
test('last log request is properly cast to json', function (): void {
$logData = ['status' => 'success', 'timestamp' => '2024-03-04 12:00:00'];
$device = Device::factory()->create([
@ -76,7 +76,7 @@ test('last log request is properly cast to json', function () {
->toHaveKey('timestamp');
});
test('getSleepModeEndsInSeconds returns correct value for overnight sleep window', function () {
test('getSleepModeEndsInSeconds returns correct value for overnight sleep window', function (): void {
// Set the current time to 12:13
Carbon::setTestNow(Carbon::create(2024, 1, 1, 12, 13, 0));

View file

@ -6,7 +6,7 @@ use Livewire\Volt\Volt;
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
test('device management page can be rendered', function () {
test('device management page can be rendered', function (): void {
$user = User::factory()->create();
$response = $this->actingAs($user)
@ -15,7 +15,7 @@ test('device management page can be rendered', function () {
$response->assertOk();
});
test('user can create a new device', function () {
test('user can create a new device', function (): void {
$user = User::factory()->create();
$this->actingAs($user);
@ -48,7 +48,7 @@ test('user can create a new device', function () {
expect($device->user_id)->toBe($user->id);
});
test('device creation requires required fields', function () {
test('device creation requires required fields', function (): void {
$user = User::factory()->create();
$this->actingAs($user);
@ -67,7 +67,7 @@ test('device creation requires required fields', function () {
]);
});
test('user can toggle proxy cloud for their device', function () {
test('user can toggle proxy cloud for their device', function (): void {
$user = User::factory()->create();
$this->actingAs($user);
$device = Device::factory()->create([
@ -88,7 +88,7 @@ test('user can toggle proxy cloud for their device', function () {
expect($device->fresh()->proxy_cloud)->toBeFalse();
});
test('user cannot toggle proxy cloud for other users devices', function () {
test('user cannot toggle proxy cloud for other users devices', function (): void {
$user = User::factory()->create();
$this->actingAs($user);

View file

@ -1,6 +1,6 @@
<?php
it('returns a successful response', function () {
it('returns a successful response', function (): void {
$response = $this->get('/');
$response->assertStatus(200);

View file

@ -8,7 +8,7 @@ use Illuminate\Support\Facades\Queue;
uses(RefreshDatabase::class);
test('command dispatches fetch device models job', function () {
test('command dispatches fetch device models job', function (): void {
Queue::fake();
$this->artisan('device-models:fetch')

View file

@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Storage;
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
beforeEach(function () {
beforeEach(function (): void {
Storage::fake('public');
Storage::disk('public')->makeDirectory('/images/generated');
Http::preventStrayRequests();
@ -18,7 +18,7 @@ beforeEach(function () {
]);
});
test('it fetches and processes proxy cloud responses for devices', function () {
test('it fetches and processes proxy cloud responses for devices', function (): void {
config(['services.trmnl.proxy_base_url' => 'https://example.com']);
// Create a test device with proxy cloud enabled
@ -59,16 +59,14 @@ test('it fetches and processes proxy cloud responses for devices', function () {
$job->handle();
// Assert HTTP requests were made with correct headers
Http::assertSent(function ($request) use ($device) {
return $request->hasHeader('id', $device->mac_address) &&
$request->hasHeader('access-token', $device->api_key) &&
$request->hasHeader('width', 800) &&
$request->hasHeader('height', 480) &&
$request->hasHeader('rssi', $device->last_rssi_level) &&
$request->hasHeader('battery_voltage', $device->last_battery_voltage) &&
$request->hasHeader('refresh-rate', $device->default_refresh_interval) &&
$request->hasHeader('fw-version', $device->last_firmware_version);
});
Http::assertSent(fn ($request): bool => $request->hasHeader('id', $device->mac_address) &&
$request->hasHeader('access-token', $device->api_key) &&
$request->hasHeader('width', 800) &&
$request->hasHeader('height', 480) &&
$request->hasHeader('rssi', $device->last_rssi_level) &&
$request->hasHeader('battery_voltage', $device->last_battery_voltage) &&
$request->hasHeader('refresh-rate', $device->default_refresh_interval) &&
$request->hasHeader('fw-version', $device->last_firmware_version));
// Assert the device was updated
$device->refresh();
@ -82,7 +80,7 @@ test('it fetches and processes proxy cloud responses for devices', function () {
Storage::disk('public')->assertExists('images/generated/test-image.bmp');
});
test('it handles log requests when present', function () {
test('it handles log requests when present', function (): void {
$device = Device::factory()->create([
'proxy_cloud' => true,
'mac_address' => '00:11:22:33:44:55',
@ -103,18 +101,16 @@ test('it handles log requests when present', function () {
$job->handle();
// Assert log request was sent
Http::assertSent(function ($request) use ($device) {
return $request->url() === config('services.trmnl.proxy_base_url').'/api/log' &&
$request->hasHeader('id', $device->mac_address) &&
$request->body() === json_encode(['message' => 'test log']);
});
Http::assertSent(fn ($request): bool => $request->url() === config('services.trmnl.proxy_base_url').'/api/log' &&
$request->hasHeader('id', $device->mac_address) &&
$request->body() === json_encode(['message' => 'test log']));
// Assert log request was cleared
$device->refresh();
expect($device->last_log_request)->toBeNull();
});
test('it handles API errors gracefully', function () {
test('it handles API errors gracefully', function (): void {
$device = Device::factory()->create([
'proxy_cloud' => true,
'mac_address' => '00:11:22:33:44:55',
@ -130,7 +126,7 @@ test('it handles API errors gracefully', function () {
expect(fn () => $job->handle())->not->toThrow(Exception::class);
});
test('it only processes proxy cloud enabled devices', function () {
test('it only processes proxy cloud enabled devices', function (): void {
Http::fake();
$enabledDevice = Device::factory()->create(['proxy_cloud' => true]);
$disabledDevice = Device::factory()->create(['proxy_cloud' => false]);
@ -139,16 +135,12 @@ test('it only processes proxy cloud enabled devices', function () {
$job->handle();
// Assert request was only made for enabled device
Http::assertSent(function ($request) use ($enabledDevice) {
return $request->hasHeader('id', $enabledDevice->mac_address);
});
Http::assertSent(fn ($request) => $request->hasHeader('id', $enabledDevice->mac_address));
Http::assertNotSent(function ($request) use ($disabledDevice) {
return $request->hasHeader('id', $disabledDevice->mac_address);
});
Http::assertNotSent(fn ($request) => $request->hasHeader('id', $disabledDevice->mac_address));
});
test('it fetches and processes proxy cloud responses for devices with BMP images', function () {
test('it fetches and processes proxy cloud responses for devices with BMP images', function (): void {
config(['services.trmnl.proxy_base_url' => 'https://example.com']);
// Create a test device with proxy cloud enabled
@ -176,16 +168,14 @@ test('it fetches and processes proxy cloud responses for devices with BMP images
$job->handle();
// Assert HTTP requests were made with correct headers
Http::assertSent(function ($request) use ($device) {
return $request->hasHeader('id', $device->mac_address) &&
$request->hasHeader('access-token', $device->api_key) &&
$request->hasHeader('width', 800) &&
$request->hasHeader('height', 480) &&
$request->hasHeader('rssi', $device->last_rssi_level) &&
$request->hasHeader('battery_voltage', $device->last_battery_voltage) &&
$request->hasHeader('refresh-rate', $device->default_refresh_interval) &&
$request->hasHeader('fw-version', $device->last_firmware_version);
});
Http::assertSent(fn ($request): bool => $request->hasHeader('id', $device->mac_address) &&
$request->hasHeader('access-token', $device->api_key) &&
$request->hasHeader('width', 800) &&
$request->hasHeader('height', 480) &&
$request->hasHeader('rssi', $device->last_rssi_level) &&
$request->hasHeader('battery_voltage', $device->last_battery_voltage) &&
$request->hasHeader('refresh-rate', $device->default_refresh_interval) &&
$request->hasHeader('fw-version', $device->last_firmware_version));
// Assert the device was updated
$device->refresh();
@ -201,7 +191,7 @@ test('it fetches and processes proxy cloud responses for devices with BMP images
expect(Storage::disk('public')->exists('images/generated/test-image.png'))->toBeFalse();
});
test('it fetches and processes proxy cloud responses for devices with PNG images', function () {
test('it fetches and processes proxy cloud responses for devices with PNG images', function (): void {
config(['services.trmnl.proxy_base_url' => 'https://example.com']);
// Create a test device with proxy cloud enabled
@ -229,16 +219,14 @@ test('it fetches and processes proxy cloud responses for devices with PNG images
$job->handle();
// Assert HTTP requests were made with correct headers
Http::assertSent(function ($request) use ($device) {
return $request->hasHeader('id', $device->mac_address) &&
$request->hasHeader('access-token', $device->api_key) &&
$request->hasHeader('width', 800) &&
$request->hasHeader('height', 480) &&
$request->hasHeader('rssi', $device->last_rssi_level) &&
$request->hasHeader('battery_voltage', $device->last_battery_voltage) &&
$request->hasHeader('refresh-rate', $device->default_refresh_interval) &&
$request->hasHeader('fw-version', $device->last_firmware_version);
});
Http::assertSent(fn ($request): bool => $request->hasHeader('id', $device->mac_address) &&
$request->hasHeader('access-token', $device->api_key) &&
$request->hasHeader('width', 800) &&
$request->hasHeader('height', 480) &&
$request->hasHeader('rssi', $device->last_rssi_level) &&
$request->hasHeader('battery_voltage', $device->last_battery_voltage) &&
$request->hasHeader('refresh-rate', $device->default_refresh_interval) &&
$request->hasHeader('fw-version', $device->last_firmware_version));
// Assert the device was updated
$device->refresh();
@ -254,7 +242,7 @@ test('it fetches and processes proxy cloud responses for devices with PNG images
expect(Storage::disk('public')->exists('images/generated/test-image.bmp'))->toBeFalse();
});
test('it handles missing content type in image URL gracefully', function () {
test('it handles missing content type in image URL gracefully', function (): void {
config(['services.trmnl.proxy_base_url' => 'https://example.com']);
// Create a test device with proxy cloud enabled

View file

@ -7,13 +7,13 @@ use Illuminate\Support\Facades\Storage;
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
beforeEach(function () {
beforeEach(function (): void {
TrmnlPipeline::fake();
Storage::fake('public');
Storage::disk('public')->makeDirectory('/images/generated');
});
test('it generates screen images and updates device', function () {
test('it generates screen images and updates device', function (): void {
$device = Device::factory()->create();
$job = new GenerateScreenJob($device->id, null, view('trmnl')->render());
$job->handle();
@ -27,7 +27,7 @@ test('it generates screen images and updates device', function () {
Storage::disk('public')->assertExists("/images/generated/{$uuid}.png");
});
test('it cleans up unused images', function () {
test('it cleans up unused images', function (): void {
// Create some test devices with images
$activeDevice = Device::factory()->create([
'current_screen_image' => 'uuid-to-be-replaced',
@ -49,7 +49,7 @@ test('it cleans up unused images', function () {
Storage::disk('public')->assertMissing('/images/generated/inactive-uuid.bmp');
});
test('it preserves gitignore file during cleanup', function () {
test('it preserves gitignore file during cleanup', function (): void {
Storage::disk('public')->put('/images/generated/.gitignore', '*');
$device = Device::factory()->create();

View file

@ -7,7 +7,7 @@ use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('it keeps only the 50 most recent logs per device', function () {
test('it keeps only the 50 most recent logs per device', function (): void {
// Create two devices
$device1 = Device::factory()->create();
$device2 = Device::factory()->create();

View file

@ -14,12 +14,12 @@ beforeEach(function (): void {
DeviceModel::truncate();
});
test('fetch device models job can be dispatched', function () {
test('fetch device models job can be dispatched', function (): void {
$job = new FetchDeviceModelsJob();
expect($job)->toBeInstanceOf(FetchDeviceModelsJob::class);
});
test('fetch device models job handles successful api response', function () {
test('fetch device models job handles successful api response', function (): void {
Http::fake([
'usetrmnl.com/api/models' => Http::response([
'data' => [
@ -65,7 +65,7 @@ test('fetch device models job handles successful api response', function () {
expect($deviceModel->source)->toBe('api');
});
test('fetch device models job handles multiple device models', function () {
test('fetch device models job handles multiple device models', function (): void {
Http::fake([
'usetrmnl.com/api/models' => Http::response([
'data' => [
@ -114,7 +114,7 @@ test('fetch device models job handles multiple device models', function () {
expect(DeviceModel::where('name', 'model-2')->exists())->toBeTrue();
});
test('fetch device models job handles empty data array', function () {
test('fetch device models job handles empty data array', function (): void {
Http::fake([
'usetrmnl.com/api/models' => Http::response([
'data' => [],
@ -131,7 +131,7 @@ test('fetch device models job handles empty data array', function () {
expect(DeviceModel::count())->toBe(0);
});
test('fetch device models job handles missing data field', function () {
test('fetch device models job handles missing data field', function (): void {
Http::fake([
'usetrmnl.com/api/models' => Http::response([
'message' => 'No data available',
@ -148,7 +148,7 @@ test('fetch device models job handles missing data field', function () {
expect(DeviceModel::count())->toBe(0);
});
test('fetch device models job handles non-array data', function () {
test('fetch device models job handles non-array data', function (): void {
Http::fake([
'usetrmnl.com/api/models' => Http::response([
'data' => 'invalid-data',
@ -165,7 +165,7 @@ test('fetch device models job handles non-array data', function () {
expect(DeviceModel::count())->toBe(0);
});
test('fetch device models job handles api failure', function () {
test('fetch device models job handles api failure', function (): void {
Http::fake([
'usetrmnl.com/api/models' => Http::response([
'error' => 'Internal Server Error',
@ -185,9 +185,9 @@ test('fetch device models job handles api failure', function () {
expect(DeviceModel::count())->toBe(0);
});
test('fetch device models job handles network exception', function () {
test('fetch device models job handles network exception', function (): void {
Http::fake([
'usetrmnl.com/api/models' => function () {
'usetrmnl.com/api/models' => function (): void {
throw new Exception('Network connection failed');
},
]);
@ -202,7 +202,7 @@ test('fetch device models job handles network exception', function () {
expect(DeviceModel::count())->toBe(0);
});
test('fetch device models job handles device model with missing name', function () {
test('fetch device models job handles device model with missing name', function (): void {
Http::fake([
'usetrmnl.com/api/models' => Http::response([
'data' => [
@ -228,7 +228,7 @@ test('fetch device models job handles device model with missing name', function
expect(DeviceModel::count())->toBe(0);
});
test('fetch device models job handles device model with partial data', function () {
test('fetch device models job handles device model with partial data', function (): void {
Http::fake([
'usetrmnl.com/api/models' => Http::response([
'data' => [
@ -263,7 +263,7 @@ test('fetch device models job handles device model with partial data', function
expect($deviceModel->source)->toBe('api');
});
test('fetch device models job updates existing device model', function () {
test('fetch device models job updates existing device model', function (): void {
// Create an existing device model
$existingModel = DeviceModel::factory()->create([
'name' => 'existing-model',
@ -309,7 +309,7 @@ test('fetch device models job updates existing device model', function () {
expect($existingModel->source)->toBe('api');
});
test('fetch device models job handles processing exception for individual model', function () {
test('fetch device models job handles processing exception for individual model', function (): void {
Http::fake([
'usetrmnl.com/api/models' => Http::response([
'data' => [

View file

@ -5,12 +5,12 @@ use App\Models\Firmware;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;
beforeEach(function () {
beforeEach(function (): void {
Storage::fake('public');
Storage::disk('public')->makeDirectory('/firmwares');
});
test('it creates firmwares directory if it does not exist', function () {
test('it creates firmwares directory if it does not exist', function (): void {
$firmware = Firmware::factory()->create([
'url' => 'https://example.com/firmware.bin',
'version_tag' => '1.0.0',
@ -26,7 +26,7 @@ test('it creates firmwares directory if it does not exist', function () {
expect(Storage::disk('public')->exists('firmwares'))->toBeTrue();
});
test('it downloads firmware and updates storage location', function () {
test('it downloads firmware and updates storage location', function (): void {
Http::fake([
'https://example.com/firmware.bin' => Http::response('fake firmware content', 200),
]);
@ -42,7 +42,7 @@ test('it downloads firmware and updates storage location', function () {
expect($firmware->fresh()->storage_location)->toBe('firmwares/FW1.0.0.bin');
});
test('it handles connection exception gracefully', function () {
test('it handles connection exception gracefully', function (): void {
$firmware = Firmware::factory()->create([
'url' => 'https://example.com/firmware.bin',
'version_tag' => '1.0.0',
@ -50,7 +50,7 @@ test('it handles connection exception gracefully', function () {
]);
Http::fake([
'https://example.com/firmware.bin' => function () {
'https://example.com/firmware.bin' => function (): void {
throw new Illuminate\Http\Client\ConnectionException('Connection failed');
},
]);
@ -65,7 +65,7 @@ test('it handles connection exception gracefully', function () {
expect($firmware->fresh()->storage_location)->toBeNull();
});
test('it handles general exception gracefully', function () {
test('it handles general exception gracefully', function (): void {
$firmware = Firmware::factory()->create([
'url' => 'https://example.com/firmware.bin',
'version_tag' => '1.0.0',
@ -73,7 +73,7 @@ test('it handles general exception gracefully', function () {
]);
Http::fake([
'https://example.com/firmware.bin' => function () {
'https://example.com/firmware.bin' => function (): void {
throw new Exception('Unexpected error');
},
]);
@ -88,7 +88,7 @@ test('it handles general exception gracefully', function () {
expect($firmware->fresh()->storage_location)->toBeNull();
});
test('it handles firmware with special characters in version tag', function () {
test('it handles firmware with special characters in version tag', function (): void {
Http::fake([
'https://example.com/firmware.bin' => Http::response('fake firmware content', 200),
]);
@ -103,7 +103,7 @@ test('it handles firmware with special characters in version tag', function () {
expect($firmware->fresh()->storage_location)->toBe('firmwares/FW1.0.0-beta.bin');
});
test('it handles firmware with long version tag', function () {
test('it handles firmware with long version tag', function (): void {
Http::fake([
'https://example.com/firmware.bin' => Http::response('fake firmware content', 200),
]);
@ -118,7 +118,7 @@ test('it handles firmware with long version tag', function () {
expect($firmware->fresh()->storage_location)->toBe('firmwares/FW1.0.0.1234.5678.90.bin');
});
test('it creates firmwares directory even when it already exists', function () {
test('it creates firmwares directory even when it already exists', function (): void {
$firmware = Firmware::factory()->create([
'url' => 'https://example.com/firmware.bin',
'version_tag' => '1.0.0',
@ -138,7 +138,7 @@ test('it creates firmwares directory even when it already exists', function () {
expect($firmware->fresh()->storage_location)->toBe('firmwares/FW1.0.0.bin');
});
test('it handles http error response', function () {
test('it handles http error response', function (): void {
$firmware = Firmware::factory()->create([
'url' => 'https://example.com/firmware.bin',
'version_tag' => '1.0.0',

View file

@ -5,11 +5,11 @@ use App\Models\Firmware;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
beforeEach(function () {
beforeEach(function (): void {
Http::preventStrayRequests();
});
test('it creates new firmware record when polling', function () {
test('it creates new firmware record when polling', function (): void {
Http::fake([
'https://usetrmnl.com/api/firmware/latest' => Http::response([
'version' => '1.0.0',
@ -25,7 +25,7 @@ test('it creates new firmware record when polling', function () {
->latest->toBeTrue();
});
test('it updates existing firmware record when polling', function () {
test('it updates existing firmware record when polling', function (): void {
$existingFirmware = Firmware::factory()->create([
'version_tag' => '1.0.0',
'url' => 'https://old-url.com/firmware.bin',
@ -46,7 +46,7 @@ test('it updates existing firmware record when polling', function () {
->latest->toBeTrue();
});
test('it marks previous firmware as not latest when new version is found', function () {
test('it marks previous firmware as not latest when new version is found', function (): void {
$oldFirmware = Firmware::factory()->create([
'version_tag' => '1.0.0',
'latest' => true,
@ -65,9 +65,9 @@ test('it marks previous firmware as not latest when new version is found', funct
->and(Firmware::where('version_tag', '1.1.0')->first()->latest)->toBeTrue();
});
test('it handles connection exception gracefully', function () {
test('it handles connection exception gracefully', function (): void {
Http::fake([
'https://usetrmnl.com/api/firmware/latest' => function () {
'https://usetrmnl.com/api/firmware/latest' => function (): void {
throw new ConnectionException('Connection failed');
},
]);
@ -78,7 +78,7 @@ test('it handles connection exception gracefully', function () {
expect(Firmware::count())->toBe(0);
});
test('it handles invalid response gracefully', function () {
test('it handles invalid response gracefully', function (): void {
Http::fake([
'https://usetrmnl.com/api/firmware/latest' => Http::response(null, 200),
]);
@ -89,7 +89,7 @@ test('it handles invalid response gracefully', function () {
expect(Firmware::count())->toBe(0);
});
test('it handles missing version in response gracefully', function () {
test('it handles missing version in response gracefully', function (): void {
Http::fake([
'https://usetrmnl.com/api/firmware/latest' => Http::response([
'url' => 'https://example.com/firmware.bin',
@ -102,7 +102,7 @@ test('it handles missing version in response gracefully', function () {
expect(Firmware::count())->toBe(0);
});
test('it handles missing url in response gracefully', function () {
test('it handles missing url in response gracefully', function (): void {
Http::fake([
'https://usetrmnl.com/api/firmware/latest' => Http::response([
'version' => '1.0.0',

View file

@ -8,7 +8,7 @@ use App\Models\User;
use App\Notifications\BatteryLow;
use Illuminate\Support\Facades\Notification;
test('it sends battery low notification when battery is below threshold', function () {
test('it sends battery low notification when battery is below threshold', function (): void {
Notification::fake();
config(['app.notifications.battery_low.warn_at_percent' => 20]);
@ -29,7 +29,7 @@ test('it sends battery low notification when battery is below threshold', functi
expect($device->battery_notification_sent)->toBeTrue();
});
test('it does not send notification when battery is above threshold', function () {
test('it does not send notification when battery is above threshold', function (): void {
Notification::fake();
config(['app.notifications.battery_low.warn_at_percent' => 20]);
@ -50,7 +50,7 @@ test('it does not send notification when battery is above threshold', function (
expect($device->battery_notification_sent)->toBeFalse();
});
test('it does not send notification when already sent', function () {
test('it does not send notification when already sent', function (): void {
Notification::fake();
config(['app.notifications.battery_low.warn_at_percent' => 20]);
@ -68,7 +68,7 @@ test('it does not send notification when already sent', function () {
Notification::assertNotSentTo($user, BatteryLow::class);
});
test('it resets notification flag when battery is above threshold', function () {
test('it resets notification flag when battery is above threshold', function (): void {
Notification::fake();
config(['app.notifications.battery_low.warn_at_percent' => 20]);
@ -89,7 +89,7 @@ test('it resets notification flag when battery is above threshold', function ()
expect($device->battery_notification_sent)->toBeFalse();
});
test('it skips devices without associated user', function () {
test('it skips devices without associated user', function (): void {
Notification::fake();
config(['app.notifications.battery_low.warn_at_percent' => 20]);
@ -106,7 +106,7 @@ test('it skips devices without associated user', function () {
Notification::assertNothingSent();
});
test('it processes multiple devices correctly', function () {
test('it processes multiple devices correctly', function (): void {
Notification::fake();
config(['app.notifications.battery_low.warn_at_percent' => 20]);

View file

@ -9,7 +9,7 @@ use Livewire\Livewire;
uses(RefreshDatabase::class);
test('device auto join component can be rendered', function () {
test('device auto join component can be rendered', function (): void {
$user = User::factory()->create(['assign_new_devices' => false]);
Livewire::actingAs($user)
@ -19,7 +19,7 @@ test('device auto join component can be rendered', function () {
->assertSet('isFirstUser', true);
});
test('device auto join component initializes with user settings', function () {
test('device auto join component initializes with user settings', function (): void {
$user = User::factory()->create(['assign_new_devices' => true]);
Livewire::actingAs($user)
@ -28,7 +28,7 @@ test('device auto join component initializes with user settings', function () {
->assertSet('isFirstUser', true);
});
test('device auto join component identifies first user correctly', function () {
test('device auto join component identifies first user correctly', function (): void {
$firstUser = User::factory()->create(['id' => 1, 'assign_new_devices' => false]);
$otherUser = User::factory()->create(['id' => 2, 'assign_new_devices' => false]);
@ -41,7 +41,7 @@ test('device auto join component identifies first user correctly', function () {
->assertSet('isFirstUser', false);
});
test('device auto join component updates user setting when toggled', function () {
test('device auto join component updates user setting when toggled', function (): void {
$user = User::factory()->create(['assign_new_devices' => false]);
Livewire::actingAs($user)
@ -55,7 +55,7 @@ test('device auto join component updates user setting when toggled', function ()
// Validation test removed - Livewire automatically handles boolean conversion
test('device auto join component handles false value correctly', function () {
test('device auto join component handles false value correctly', function (): void {
$user = User::factory()->create(['assign_new_devices' => true]);
Livewire::actingAs($user)
@ -67,7 +67,7 @@ test('device auto join component handles false value correctly', function () {
expect($user->assign_new_devices)->toBeFalse();
});
test('device auto join component only updates when deviceAutojoin property changes', function () {
test('device auto join component only updates when deviceAutojoin property changes', function (): void {
$user = User::factory()->create(['assign_new_devices' => false]);
$component = Livewire::actingAs($user)
@ -80,7 +80,7 @@ test('device auto join component only updates when deviceAutojoin property chang
expect($user->assign_new_devices)->toBeFalse();
});
test('device auto join component renders correct view', function () {
test('device auto join component renders correct view', function (): void {
$user = User::factory()->create();
Livewire::actingAs($user)
@ -88,7 +88,7 @@ test('device auto join component renders correct view', function () {
->assertViewIs('livewire.actions.device-auto-join');
});
test('device auto join component works with authenticated user', function () {
test('device auto join component works with authenticated user', function (): void {
$user = User::factory()->create(['assign_new_devices' => true]);
$component = Livewire::actingAs($user)
@ -98,7 +98,7 @@ test('device auto join component works with authenticated user', function () {
expect($component->instance()->isFirstUser)->toBe($user->id === 1);
});
test('device auto join component handles multiple updates correctly', function () {
test('device auto join component handles multiple updates correctly', function (): void {
$user = User::factory()->create(['assign_new_devices' => false]);
$component = Livewire::actingAs($user)

View file

@ -6,11 +6,11 @@ use Illuminate\Support\Facades\Http;
use Livewire\Volt\Volt;
use Symfony\Component\Yaml\Yaml;
beforeEach(function () {
beforeEach(function (): void {
Cache::flush();
});
it('can render catalog component', function () {
it('can render catalog component', function (): void {
// Mock empty catalog response
Http::fake([
config('app.catalog_url') => Http::response('', 200),
@ -21,7 +21,7 @@ it('can render catalog component', function () {
$component->assertSee('No plugins available');
});
it('loads plugins from catalog URL', function () {
it('loads plugins from catalog URL', function (): void {
// Clear cache first to ensure fresh data
Cache::forget('catalog_plugins');
@ -62,7 +62,7 @@ it('loads plugins from catalog URL', function () {
$component->assertSee('MIT');
});
it('shows error when plugin not found', function () {
it('shows error when plugin not found', function (): void {
$user = User::factory()->create();
$this->actingAs($user);
@ -75,7 +75,7 @@ it('shows error when plugin not found', function () {
$component->assertHasErrors();
});
it('shows error when zip_url is missing', function () {
it('shows error when zip_url is missing', function (): void {
$user = User::factory()->create();
// Mock the HTTP response for the catalog URL without zip_url

View file

@ -10,7 +10,7 @@ use Illuminate\Support\Carbon;
uses(RefreshDatabase::class);
test('playlist scheduling works correctly for time ranges spanning midnight', function () {
test('playlist scheduling works correctly for time ranges spanning midnight', function (): void {
// Create a user and device
$user = User::factory()->create();
$device = Device::factory()->create(['user_id' => $user->id]);
@ -85,7 +85,7 @@ test('playlist scheduling works correctly for time ranges spanning midnight', fu
expect($nextItem->playlist->name)->toBe('Day until Deep Night Playlist');
});
test('playlist isActiveNow handles midnight spanning correctly', function () {
test('playlist isActiveNow handles midnight spanning correctly', function (): void {
$playlist = Playlist::factory()->create([
'is_active' => true,
'active_from' => '09:01',
@ -110,7 +110,7 @@ test('playlist isActiveNow handles midnight spanning correctly', function () {
expect($playlist->isActiveNow())->toBeFalse();
});
test('playlist isActiveNow handles normal time ranges correctly', function () {
test('playlist isActiveNow handles normal time ranges correctly', function (): void {
$playlist = Playlist::factory()->create([
'is_active' => true,
'active_from' => '09:00',

View file

@ -9,11 +9,11 @@ use App\Services\PluginImportService;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
beforeEach(function () {
beforeEach(function (): void {
Storage::fake('local');
});
it('exports plugin to zip file in correct format', function () {
it('exports plugin to zip file in correct format', function (): void {
$user = User::factory()->create();
$plugin = Plugin::factory()->create([
'user_id' => $user->id,
@ -42,7 +42,7 @@ it('exports plugin to zip file in correct format', function () {
expect($response->getFile()->getFilename())->toContain('test-plugin-123.zip');
});
it('exports plugin with polling configuration', function () {
it('exports plugin with polling configuration', function (): void {
$user = User::factory()->create();
$plugin = Plugin::factory()->create([
'user_id' => $user->id,
@ -63,7 +63,7 @@ it('exports plugin with polling configuration', function () {
expect($response)->toBeInstanceOf(Symfony\Component\HttpFoundation\BinaryFileResponse::class);
});
it('exports and imports plugin maintaining all data', function () {
it('exports and imports plugin maintaining all data', function (): void {
$user = User::factory()->create();
$originalPlugin = Plugin::factory()->create([
'user_id' => $user->id,
@ -122,7 +122,7 @@ it('exports and imports plugin maintaining all data', function () {
expect($importedPlugin->data_payload)->toBe(['items' => [1, 2, 3]]);
});
it('handles blade templates correctly', function () {
it('handles blade templates correctly', function (): void {
$user = User::factory()->create();
$plugin = Plugin::factory()->create([
'user_id' => $user->id,
@ -138,7 +138,7 @@ it('handles blade templates correctly', function () {
expect($response)->toBeInstanceOf(Symfony\Component\HttpFoundation\BinaryFileResponse::class);
});
it('removes wrapper div from exported markup', function () {
it('removes wrapper div from exported markup', function (): void {
$user = User::factory()->create();
$plugin = Plugin::factory()->create([
'user_id' => $user->id,
@ -154,7 +154,7 @@ it('removes wrapper div from exported markup', function () {
expect($response)->toBeInstanceOf(Symfony\Component\HttpFoundation\BinaryFileResponse::class);
});
it('converts polling headers correctly', function () {
it('converts polling headers correctly', function (): void {
$user = User::factory()->create();
$plugin = Plugin::factory()->create([
'user_id' => $user->id,
@ -170,7 +170,7 @@ it('converts polling headers correctly', function () {
expect($response)->toBeInstanceOf(Symfony\Component\HttpFoundation\BinaryFileResponse::class);
});
it('api route returns zip file for authenticated user', function () {
it('api route returns zip file for authenticated user', function (): void {
$user = User::factory()->create();
$plugin = Plugin::factory()->create([
'user_id' => $user->id,
@ -188,7 +188,7 @@ it('api route returns zip file for authenticated user', function () {
$response->assertHeader('Content-Disposition', 'attachment; filename=plugin_api-test-404.zip');
});
it('api route returns 404 for non-existent plugin', function () {
it('api route returns 404 for non-existent plugin', function (): void {
$user = User::factory()->create();
$response = $this->actingAs($user)
@ -197,13 +197,13 @@ it('api route returns 404 for non-existent plugin', function () {
$response->assertStatus(404);
});
it('api route returns 401 for unauthenticated user', function () {
it('api route returns 401 for unauthenticated user', function (): void {
$response = $this->getJson('/api/plugin_settings/test-id/archive');
$response->assertStatus(401);
});
it('api route returns 404 for plugin belonging to different user', function () {
it('api route returns 404 for plugin belonging to different user', function (): void {
$user1 = User::factory()->create();
$user2 = User::factory()->create();
$plugin = Plugin::factory()->create([
@ -217,7 +217,7 @@ it('api route returns 404 for plugin belonging to different user', function () {
$response->assertStatus(404);
});
it('exports zip with files in root directory', function () {
it('exports zip with files in root directory', function (): void {
$user = User::factory()->create();
$plugin = Plugin::factory()->create([
'user_id' => $user->id,
@ -243,7 +243,7 @@ it('exports zip with files in root directory', function () {
$zip->close();
});
it('maintains correct yaml field order', function () {
it('maintains correct yaml field order', function (): void {
$user = User::factory()->create();
$plugin = Plugin::factory()->create([
'user_id' => $user->id,

View file

@ -6,7 +6,7 @@ use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('plugin import extracts default values from custom_fields and stores in configuration', function () {
test('plugin import extracts default values from custom_fields and stores in configuration', function (): void {
// Create a user
$user = User::factory()->create();
@ -74,7 +74,7 @@ test('plugin import extracts default values from custom_fields and stores in con
expect($plugin->configuration_template['custom_fields'])->toHaveCount(3);
});
test('plugin import handles custom_fields without default values', function () {
test('plugin import handles custom_fields without default values', function (): void {
// Create a user
$user = User::factory()->create();

View file

@ -9,11 +9,11 @@ use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;
beforeEach(function () {
beforeEach(function (): void {
Storage::fake('local');
});
it('imports plugin from valid zip file', function () {
it('imports plugin from valid zip file', function (): void {
$user = User::factory()->create();
// Create a mock ZIP file with the required structure
@ -38,7 +38,7 @@ it('imports plugin from valid zip file', function () {
->and($plugin->configuration['api_key'])->toBe('default-api-key');
});
it('imports plugin with shared.liquid file', function () {
it('imports plugin with shared.liquid file', function (): void {
$user = User::factory()->create();
$zipContent = createMockZipFile([
@ -56,7 +56,7 @@ it('imports plugin with shared.liquid file', function () {
->and($plugin->render_markup)->toContain('<div class="view view--{{ size }}">');
});
it('imports plugin with files in root directory', function () {
it('imports plugin with files in root directory', function (): void {
$user = User::factory()->create();
$zipContent = createMockZipFile([
@ -73,17 +73,17 @@ it('imports plugin with files in root directory', function () {
->and($plugin->name)->toBe('Test Plugin');
});
it('throws exception for invalid zip file', function () {
it('throws exception for invalid zip file', function (): void {
$user = User::factory()->create();
$zipFile = UploadedFile::fake()->createWithContent('invalid.zip', 'not a zip file');
$pluginImportService = new PluginImportService();
expect(fn () => $pluginImportService->importFromZip($zipFile, $user))
expect(fn (): Plugin => $pluginImportService->importFromZip($zipFile, $user))
->toThrow(Exception::class, 'Could not open the ZIP file.');
});
it('throws exception for missing required files', function () {
it('throws exception for missing required files', function (): void {
$user = User::factory()->create();
$zipContent = createMockZipFile([
@ -94,11 +94,11 @@ it('throws exception for missing required files', function () {
$zipFile = UploadedFile::fake()->createWithContent('test-plugin.zip', $zipContent);
$pluginImportService = new PluginImportService();
expect(fn () => $pluginImportService->importFromZip($zipFile, $user))
expect(fn (): Plugin => $pluginImportService->importFromZip($zipFile, $user))
->toThrow(Exception::class, 'Invalid ZIP structure. Required files settings.yml and full.liquid are missing.');
});
it('sets default values when settings are missing', function () {
it('sets default values when settings are missing', function (): void {
$user = User::factory()->create();
$zipContent = createMockZipFile([
@ -117,7 +117,7 @@ it('sets default values when settings are missing', function () {
->and($plugin->polling_verb)->toBe('get'); // default value
});
it('handles blade markup language correctly', function () {
it('handles blade markup language correctly', function (): void {
$user = User::factory()->create();
$zipContent = createMockZipFile([
@ -133,7 +133,7 @@ it('handles blade markup language correctly', function () {
expect($plugin->markup_language)->toBe('blade');
});
it('imports plugin from monorepo with zip_entry_path parameter', function () {
it('imports plugin from monorepo with zip_entry_path parameter', function (): void {
$user = User::factory()->create();
// Create a mock ZIP file with plugin in a subdirectory
@ -152,7 +152,7 @@ it('imports plugin from monorepo with zip_entry_path parameter', function () {
->and($plugin->name)->toBe('Test Plugin');
});
it('imports plugin from monorepo with src subdirectory', function () {
it('imports plugin from monorepo with src subdirectory', function (): void {
$user = User::factory()->create();
// Create a mock ZIP file with plugin in a subdirectory with src folder
@ -171,7 +171,7 @@ it('imports plugin from monorepo with src subdirectory', function () {
->and($plugin->name)->toBe('Test Plugin');
});
it('imports plugin from monorepo with shared.liquid in subdirectory', function () {
it('imports plugin from monorepo with shared.liquid in subdirectory', function (): void {
$user = User::factory()->create();
$zipContent = createMockZipFile([
@ -189,7 +189,7 @@ it('imports plugin from monorepo with shared.liquid in subdirectory', function (
->and($plugin->render_markup)->toContain('<div class="view view--{{ size }}">');
});
it('imports plugin from URL with zip_entry_path parameter', function () {
it('imports plugin from URL with zip_entry_path parameter', function (): void {
$user = User::factory()->create();
// Create a mock ZIP file with plugin in a subdirectory
@ -214,12 +214,10 @@ it('imports plugin from URL with zip_entry_path parameter', function () {
->and($plugin->user_id)->toBe($user->id)
->and($plugin->name)->toBe('Test Plugin');
Http::assertSent(function ($request) {
return $request->url() === 'https://github.com/example/repo/archive/refs/heads/main.zip';
});
Http::assertSent(fn ($request): bool => $request->url() === 'https://github.com/example/repo/archive/refs/heads/main.zip');
});
it('imports plugin from URL with zip_entry_path and src subdirectory', function () {
it('imports plugin from URL with zip_entry_path and src subdirectory', function (): void {
$user = User::factory()->create();
// Create a mock ZIP file with plugin in a subdirectory with src folder
@ -245,7 +243,7 @@ it('imports plugin from URL with zip_entry_path and src subdirectory', function
->and($plugin->name)->toBe('Test Plugin');
});
it('imports plugin from GitHub monorepo with repository-named directory', function () {
it('imports plugin from GitHub monorepo with repository-named directory', function (): void {
$user = User::factory()->create();
// Create a mock ZIP file that simulates GitHub's ZIP structure with repository-named directory
@ -273,7 +271,7 @@ it('imports plugin from GitHub monorepo with repository-named directory', functi
->and($plugin->name)->toBe('Test Plugin'); // Should be from example-plugin, not other-plugin
});
it('finds required files in simple ZIP structure', function () {
it('finds required files in simple ZIP structure', function (): void {
$user = User::factory()->create();
// Create a simple ZIP file with just one plugin
@ -292,7 +290,7 @@ it('finds required files in simple ZIP structure', function () {
->and($plugin->name)->toBe('Test Plugin');
});
it('finds required files in GitHub monorepo structure with zip_entry_path', function () {
it('finds required files in GitHub monorepo structure with zip_entry_path', function (): void {
$user = User::factory()->create();
// Create a mock ZIP file that simulates GitHub's ZIP structure
@ -313,7 +311,7 @@ it('finds required files in GitHub monorepo structure with zip_entry_path', func
->and($plugin->name)->toBe('Test Plugin'); // Should be from example-plugin, not other-plugin
});
it('imports specific plugin from monorepo zip with zip_entry_path parameter', function () {
it('imports specific plugin from monorepo zip with zip_entry_path parameter', function (): void {
$user = User::factory()->create();
// Create a mock ZIP file with 2 plugins in a monorepo structure

View file

@ -5,7 +5,7 @@ use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('renders plugin with inline templates', function () {
test('renders plugin with inline templates', function (): void {
$plugin = Plugin::factory()->create([
'name' => 'Test Plugin',
'markup_language' => 'liquid',
@ -61,16 +61,16 @@ LIQUID
// Should render both templates
// Check for any of the facts (since random number generation is non-deterministic)
$this->assertTrue(
str_contains($result, 'Fact 1') ||
str_contains($result, 'Fact 2') ||
str_contains($result, 'Fact 3')
str_contains((string) $result, 'Fact 1') ||
str_contains((string) $result, 'Fact 2') ||
str_contains((string) $result, 'Fact 3')
);
$this->assertStringContainsString('Test Plugin', $result);
$this->assertStringContainsString('Please try to enjoy each fact equally', $result);
$this->assertStringContainsString('class="view view--full"', $result);
});
test('renders plugin with inline templates using with syntax', function () {
test('renders plugin with inline templates using with syntax', function (): void {
$plugin = Plugin::factory()->create([
'name' => 'Test Plugin',
'markup_language' => 'liquid',
@ -127,16 +127,16 @@ LIQUID
// Should render both templates
// Check for any of the facts (since random number generation is non-deterministic)
$this->assertTrue(
str_contains($result, 'Fact 1') ||
str_contains($result, 'Fact 2') ||
str_contains($result, 'Fact 3')
str_contains((string) $result, 'Fact 1') ||
str_contains((string) $result, 'Fact 2') ||
str_contains((string) $result, 'Fact 3')
);
$this->assertStringContainsString('Test Plugin', $result);
$this->assertStringContainsString('Please try to enjoy each fact equally', $result);
$this->assertStringContainsString('class="view view--full"', $result);
});
test('renders plugin with simple inline template', function () {
test('renders plugin with simple inline template', function (): void {
$plugin = Plugin::factory()->create([
'markup_language' => 'liquid',
'render_markup' => <<<'LIQUID'
@ -162,7 +162,7 @@ LIQUID
$this->assertStringContainsString('class="simple"', $result);
});
test('renders plugin with liquid filter find_by', function () {
test('renders plugin with liquid filter find_by', function (): void {
$plugin = Plugin::factory()->create([
'markup_language' => 'liquid',
'render_markup' => <<<'LIQUID'
@ -194,7 +194,7 @@ LIQUID
$this->assertStringContainsString('class="user"', $result);
});
test('renders plugin with liquid filter find_by and fallback', function () {
test('renders plugin with liquid filter find_by and fallback', function (): void {
$plugin = Plugin::factory()->create([
'markup_language' => 'liquid',
'render_markup' => <<<'LIQUID'
@ -216,7 +216,7 @@ LIQUID
$this->assertStringContainsString('Not Found', $result);
});
test('renders plugin with liquid filter group_by', function () {
test('renders plugin with liquid filter group_by', function (): void {
$plugin = Plugin::factory()->create([
'markup_language' => 'liquid',
'render_markup' => <<<'LIQUID'

View file

@ -14,7 +14,7 @@ use Keepsuit\Liquid\Environment;
* to:
* {% assign _temp_xxx = collection | filter: "key", "value" %}{% for item in _temp_xxx %}
*/
test('where filter works when assigned to variable first', function () {
test('where filter works when assigned to variable first', function (): void {
$plugin = Plugin::factory()->create([
'markup_language' => 'liquid',
'render_markup' => <<<'LIQUID'
@ -42,7 +42,7 @@ LIQUID
$this->assertStringNotContainsString('"type":"L"', $result);
});
test('where filter works directly in for loop with preprocessing', function () {
test('where filter works directly in for loop with preprocessing', function (): void {
$plugin = Plugin::factory()->create([
'markup_language' => 'liquid',
'render_markup' => <<<'LIQUID'
@ -68,7 +68,7 @@ LIQUID
$this->assertStringNotContainsString('"type":"L"', $result);
});
test('where filter works directly in for loop with multiple matches', function () {
test('where filter works directly in for loop with multiple matches', function (): void {
$plugin = Plugin::factory()->create([
'markup_language' => 'liquid',
'render_markup' => <<<'LIQUID'
@ -95,7 +95,7 @@ LIQUID
$this->assertStringNotContainsString('"type":"L"', $result);
});
it('encodes arrays for url_encode as JSON with spaces after commas and then percent-encodes', function () {
it('encodes arrays for url_encode as JSON with spaces after commas and then percent-encodes', function (): void {
/** @var Environment $env */
$env = app('liquid.environment');
$env->filterRegistry->register(StandardFilters::class);
@ -109,7 +109,7 @@ it('encodes arrays for url_encode as JSON with spaces after commas and then perc
expect($output)->toBe('%5B%22common%22%2C%22obscure%22%5D');
});
it('keeps scalar url_encode behavior intact', function () {
it('keeps scalar url_encode behavior intact', function (): void {
/** @var Environment $env */
$env = app('liquid.environment');
$env->filterRegistry->register(StandardFilters::class);

View file

@ -6,7 +6,7 @@ use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('hasMissingRequiredConfigurationFields returns true when required field is null', function () {
test('hasMissingRequiredConfigurationFields returns true when required field is null', function (): void {
$user = User::factory()->create();
$configurationTemplate = [
@ -39,7 +39,7 @@ test('hasMissingRequiredConfigurationFields returns true when required field is
expect($plugin->hasMissingRequiredConfigurationFields())->toBeTrue();
});
test('hasMissingRequiredConfigurationFields returns false when all required fields are set', function () {
test('hasMissingRequiredConfigurationFields returns false when all required fields are set', function (): void {
$user = User::factory()->create();
$configurationTemplate = [
@ -73,7 +73,7 @@ test('hasMissingRequiredConfigurationFields returns false when all required fiel
expect($plugin->hasMissingRequiredConfigurationFields())->toBeFalse();
});
test('hasMissingRequiredConfigurationFields returns false when no custom fields exist', function () {
test('hasMissingRequiredConfigurationFields returns false when no custom fields exist', function (): void {
$user = User::factory()->create();
$plugin = Plugin::factory()->create([
@ -85,7 +85,7 @@ test('hasMissingRequiredConfigurationFields returns false when no custom fields
expect($plugin->hasMissingRequiredConfigurationFields())->toBeFalse();
});
test('hasMissingRequiredConfigurationFields returns true when explicitly required field is null', function () {
test('hasMissingRequiredConfigurationFields returns true when explicitly required field is null', function (): void {
$user = User::factory()->create();
$configurationTemplate = [
@ -111,7 +111,7 @@ test('hasMissingRequiredConfigurationFields returns true when explicitly require
expect($plugin->hasMissingRequiredConfigurationFields())->toBeTrue();
});
test('hasMissingRequiredConfigurationFields returns true when required field is empty string', function () {
test('hasMissingRequiredConfigurationFields returns true when required field is empty string', function (): void {
$user = User::factory()->create();
$configurationTemplate = [
@ -137,7 +137,7 @@ test('hasMissingRequiredConfigurationFields returns true when required field is
expect($plugin->hasMissingRequiredConfigurationFields())->toBeTrue();
});
test('hasMissingRequiredConfigurationFields returns true when required array field is empty', function () {
test('hasMissingRequiredConfigurationFields returns true when required array field is empty', function (): void {
$user = User::factory()->create();
$configurationTemplate = [
@ -164,7 +164,7 @@ test('hasMissingRequiredConfigurationFields returns true when required array fie
expect($plugin->hasMissingRequiredConfigurationFields())->toBeTrue();
});
test('hasMissingRequiredConfigurationFields returns false when author_bio field is present but other required field is set', function () {
test('hasMissingRequiredConfigurationFields returns false when author_bio field is present but other required field is set', function (): void {
$user = User::factory()->create();
$configurationTemplate = [
@ -193,7 +193,7 @@ test('hasMissingRequiredConfigurationFields returns false when author_bio field
expect($plugin->hasMissingRequiredConfigurationFields())->toBeFalse();
});
test('hasMissingRequiredConfigurationFields returns false when field has default value', function () {
test('hasMissingRequiredConfigurationFields returns false when field has default value', function (): void {
$user = User::factory()->create();
$configurationTemplate = [
@ -217,7 +217,7 @@ test('hasMissingRequiredConfigurationFields returns false when field has default
expect($plugin->hasMissingRequiredConfigurationFields())->toBeFalse();
});
test('hasMissingRequiredConfigurationFields returns true when required xhrSelect field is missing', function () {
test('hasMissingRequiredConfigurationFields returns true when required xhrSelect field is missing', function (): void {
$user = User::factory()->create();
$configurationTemplate = [
@ -242,7 +242,7 @@ test('hasMissingRequiredConfigurationFields returns true when required xhrSelect
expect($plugin->hasMissingRequiredConfigurationFields())->toBeTrue();
});
test('hasMissingRequiredConfigurationFields returns false when required xhrSelect field is set', function () {
test('hasMissingRequiredConfigurationFields returns false when required xhrSelect field is set', function (): void {
$user = User::factory()->create();
$configurationTemplate = [

View file

@ -3,7 +3,7 @@
use App\Models\Plugin;
use Illuminate\Support\Str;
test('webhook updates plugin data for webhook strategy', function () {
test('webhook updates plugin data for webhook strategy', function (): void {
// Create a plugin with webhook strategy
$plugin = Plugin::factory()->create([
'data_strategy' => 'webhook',
@ -26,7 +26,7 @@ test('webhook updates plugin data for webhook strategy', function () {
]);
});
test('webhook returns 400 for non-webhook strategy plugins', function () {
test('webhook returns 400 for non-webhook strategy plugins', function (): void {
// Create a plugin with non-webhook strategy
$plugin = Plugin::factory()->create([
'data_strategy' => 'polling',
@ -43,7 +43,7 @@ test('webhook returns 400 for non-webhook strategy plugins', function () {
->assertJson(['error' => 'Plugin does not use webhook strategy']);
});
test('webhook returns 400 when merge_variables is missing', function () {
test('webhook returns 400 when merge_variables is missing', function (): void {
// Create a plugin with webhook strategy
$plugin = Plugin::factory()->create([
'data_strategy' => 'webhook',
@ -58,7 +58,7 @@ test('webhook returns 400 when merge_variables is missing', function () {
->assertJson(['error' => 'Request must contain merge_variables key']);
});
test('webhook returns 404 for non-existent plugin', function () {
test('webhook returns 404 for non-existent plugin', function (): void {
// Make request with non-existent plugin UUID
$response = $this->postJson('/api/custom_plugins/'.Str::uuid(), [
'merge_variables' => ['new' => 'data'],

View file

@ -6,7 +6,7 @@ use Livewire\Volt\Volt;
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
test('password can be updated', function () {
test('password can be updated', function (): void {
$user = User::factory()->create([
'password' => Hash::make('password'),
]);
@ -24,7 +24,7 @@ test('password can be updated', function () {
expect(Hash::check('new-password', $user->refresh()->password))->toBeTrue();
});
test('correct password must be provided to update password', function () {
test('correct password must be provided to update password', function (): void {
$user = User::factory()->create([
'password' => Hash::make('password'),
]);

View file

@ -5,13 +5,13 @@ use Livewire\Volt\Volt;
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
test('profile page is displayed', function () {
test('profile page is displayed', function (): void {
$this->actingAs($user = User::factory()->create());
$this->get('/settings/profile')->assertOk();
});
test('profile information can be updated', function () {
test('profile information can be updated', function (): void {
$user = User::factory()->create();
$this->actingAs($user);
@ -30,7 +30,7 @@ test('profile information can be updated', function () {
expect($user->email_verified_at)->toBeNull();
});
test('email verification status is unchanged when email address is unchanged', function () {
test('email verification status is unchanged when email address is unchanged', function (): void {
$user = User::factory()->create();
$this->actingAs($user);
@ -45,7 +45,7 @@ test('email verification status is unchanged when email address is unchanged', f
expect($user->refresh()->email_verified_at)->not->toBeNull();
});
test('user can delete their account', function () {
test('user can delete their account', function (): void {
$user = User::factory()->create();
$this->actingAs($user);
@ -62,7 +62,7 @@ test('user can delete their account', function () {
expect(auth()->check())->toBeFalse();
});
test('correct password must be provided to delete account', function () {
test('correct password must be provided to delete account', function (): void {
$user = User::factory()->create();
$this->actingAs($user);