chore: pint

This commit is contained in:
Benjamin Nussbaum 2025-08-26 11:17:09 +02:00
parent 25f36eaf54
commit 4c66761baa
12 changed files with 142 additions and 121 deletions

View file

@ -2,7 +2,8 @@
declare(strict_types=1);
use App\Models\{Device, User};
use App\Models\Device;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
@ -16,8 +17,8 @@ test('dashboard shows device image with correct rotation', function () {
]);
// Mock the file existence check
\Illuminate\Support\Facades\Storage::fake('public');
\Illuminate\Support\Facades\Storage::disk('public')->put('images/generated/test-image-uuid.png', 'fake-image-content');
Illuminate\Support\Facades\Storage::fake('public');
Illuminate\Support\Facades\Storage::disk('public')->put('images/generated/test-image-uuid.png', 'fake-image-content');
$response = $this->actingAs($user)
->get(route('dashboard'));
@ -36,8 +37,8 @@ test('device configure page shows device image with correct rotation', function
]);
// Mock the file existence check
\Illuminate\Support\Facades\Storage::fake('public');
\Illuminate\Support\Facades\Storage::disk('public')->put('images/generated/test-image-uuid.png', 'fake-image-content');
Illuminate\Support\Facades\Storage::fake('public');
Illuminate\Support\Facades\Storage::disk('public')->put('images/generated/test-image-uuid.png', 'fake-image-content');
$response = $this->actingAs($user)
->get(route('devices.configure', $device));
@ -56,8 +57,8 @@ test('device with no rotation shows no transform style', function () {
]);
// Mock the file existence check
\Illuminate\Support\Facades\Storage::fake('public');
\Illuminate\Support\Facades\Storage::disk('public')->put('images/generated/test-image-uuid.png', 'fake-image-content');
Illuminate\Support\Facades\Storage::fake('public');
Illuminate\Support\Facades\Storage::disk('public')->put('images/generated/test-image-uuid.png', 'fake-image-content');
$response = $this->actingAs($user)
->get(route('dashboard'));
@ -75,8 +76,8 @@ test('device with null rotation defaults to 0', function () {
]);
// Mock the file existence check
\Illuminate\Support\Facades\Storage::fake('public');
\Illuminate\Support\Facades\Storage::disk('public')->put('images/generated/test-image-uuid.png', 'fake-image-content');
Illuminate\Support\Facades\Storage::fake('public');
Illuminate\Support\Facades\Storage::disk('public')->put('images/generated/test-image-uuid.png', 'fake-image-content');
$response = $this->actingAs($user)
->get(route('dashboard'));

View file

@ -266,7 +266,7 @@ it('maintains correct yaml field order', function () {
// Extract and read the settings.yml file
$zip->extractTo(sys_get_temp_dir(), 'settings.yml');
$yamlContent = file_get_contents(sys_get_temp_dir() . '/settings.yml');
$yamlContent = file_get_contents(sys_get_temp_dir().'/settings.yml');
$zip->close();
// Check that the YAML content has the expected field order
@ -285,11 +285,11 @@ it('maintains correct yaml field order', function () {
$lines = explode("\n", $yamlContent);
$fieldLines = [];
foreach ($lines as $line) {
$line = trim($line);
if (preg_match('/^([a-zA-Z_]+):/', $line, $matches)) {
$fieldLines[] = $matches[1] . ':';
$fieldLines[] = $matches[1].':';
}
}
@ -304,5 +304,5 @@ it('maintains correct yaml field order', function () {
}
// Clean up
unlink(sys_get_temp_dir() . '/settings.yml');
unlink(sys_get_temp_dir().'/settings.yml');
});

View file

@ -3,10 +3,6 @@
use App\Models\Plugin;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Livewire\Volt\Volt;
use Symfony\Component\Yaml\Yaml;
uses(RefreshDatabase::class);
@ -22,23 +18,23 @@ test('plugin import extracts default values from custom_fields and stores in con
'field_type' => 'string',
'name' => 'Reading Days',
'description' => 'Select days of the week to read',
'default' => 'Monday,Friday,Saturday,Sunday'
'default' => 'Monday,Friday,Saturday,Sunday',
],
[
'keyname' => 'refresh_interval',
'field_type' => 'number',
'name' => 'Refresh Interval',
'description' => 'How often to refresh data',
'default' => 15
'default' => 15,
],
[
'keyname' => 'timezone',
'field_type' => 'time_zone',
'name' => 'Timezone',
'description' => 'Select your timezone'
'description' => 'Select your timezone',
// No default value
]
]
],
],
];
// Extract default values from custom_fields and populate configuration
@ -53,7 +49,7 @@ test('plugin import extracts default values from custom_fields and stores in con
// Create the plugin directly
$plugin = Plugin::create([
'uuid' => \Illuminate\Support\Str::uuid(),
'uuid' => Illuminate\Support\Str::uuid(),
'user_id' => $user->id,
'name' => 'Test Plugin with Defaults',
'data_stale_minutes' => 30,
@ -68,11 +64,11 @@ test('plugin import extracts default values from custom_fields and stores in con
expect($plugin->configuration)->toHaveKey('reading_days');
expect($plugin->configuration)->toHaveKey('refresh_interval');
expect($plugin->configuration)->not->toHaveKey('timezone');
expect($plugin->getConfiguration('reading_days'))->toBe('Monday,Friday,Saturday,Sunday');
expect($plugin->getConfiguration('refresh_interval'))->toBe(15);
expect($plugin->getConfiguration('timezone'))->toBeNull();
// Verify configuration template was stored correctly
expect($plugin->configuration_template)->toBeArray();
expect($plugin->configuration_template['custom_fields'])->toHaveCount(3);
@ -89,9 +85,9 @@ test('plugin import handles custom_fields without default values', function () {
'keyname' => 'timezone',
'field_type' => 'time_zone',
'name' => 'Timezone',
'description' => 'Select your timezone'
]
]
'description' => 'Select your timezone',
],
],
];
// Extract default values from custom_fields and populate configuration
@ -106,7 +102,7 @@ test('plugin import handles custom_fields without default values', function () {
// Create the plugin directly
$plugin = Plugin::create([
'uuid' => \Illuminate\Support\Str::uuid(),
'uuid' => Illuminate\Support\Str::uuid(),
'user_id' => $user->id,
'name' => 'Test Plugin No Defaults',
'data_stale_minutes' => 30,
@ -119,8 +115,8 @@ test('plugin import handles custom_fields without default values', function () {
expect($plugin)->not->toBeNull();
expect($plugin->configuration)->toBeArray();
expect($plugin->configuration)->toBeEmpty();
// Verify configuration template was stored correctly
expect($plugin->configuration_template)->toBeArray();
expect($plugin->configuration_template['custom_fields'])->toHaveCount(1);
});
});