byos_laravel/tests/Feature/Devices/DeviceRotationTest.php
Benjamin Nussbaum b4b6286172
Some checks are pending
tests / ci (push) Waiting to run
refactor: apply rector
2025-09-24 20:35:48 +02:00

87 lines
2.8 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\Device;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('dashboard shows device image with correct rotation', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create([
'user_id' => $user->id,
'rotate' => 90,
'current_screen_image' => 'test-image-uuid',
]);
// 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');
$response = $this->actingAs($user)
->get(route('dashboard'));
$response->assertSuccessful();
$response->assertSee('-rotate-[90deg]');
$response->assertSee('origin-center');
});
test('device configure page shows device image with correct rotation', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create([
'user_id' => $user->id,
'rotate' => 90,
'current_screen_image' => 'test-image-uuid',
]);
// 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');
$response = $this->actingAs($user)
->get(route('devices.configure', $device));
$response->assertSuccessful();
$response->assertSee('-rotate-[90deg]');
$response->assertSee('origin-center');
});
test('device with no rotation shows no transform style', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create([
'user_id' => $user->id,
'rotate' => 0,
'current_screen_image' => 'test-image-uuid',
]);
// 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');
$response = $this->actingAs($user)
->get(route('dashboard'));
$response->assertSuccessful();
$response->assertSee('-rotate-[0deg]');
});
test('device with null rotation defaults to 0', function (): void {
$user = User::factory()->create();
$device = Device::factory()->create([
'user_id' => $user->id,
'rotate' => null,
'current_screen_image' => 'test-image-uuid',
]);
// 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');
$response = $this->actingAs($user)
->get(route('dashboard'));
$response->assertSuccessful();
$response->assertSee('-rotate-[0deg]');
});