added a help system, replaced the words "tenant" and "Pwa" with better alternatives. corrected and implemented cron jobs. prepared going live on a coolify-powered system.
This commit is contained in:
110
tests/Feature/Photobooth/PhotoboothControllerTest.php
Normal file
110
tests/Feature/Photobooth/PhotoboothControllerTest.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Photobooth;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\PhotoboothSetting;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\Feature\Tenant\TenantTestCase;
|
||||
|
||||
class PhotoboothControllerTest extends TenantTestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
config([
|
||||
'photobooth.control_service.base_url' => 'https://control.test',
|
||||
'photobooth.control_service.token' => 'secret-token',
|
||||
]);
|
||||
|
||||
PhotoboothSetting::current()->update([
|
||||
'control_service_base_url' => 'https://control.test',
|
||||
]);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_returns_photobooth_status_for_an_event(): void
|
||||
{
|
||||
$event = Event::factory()->for($this->tenant)->create([
|
||||
'slug' => 'photobooth-demo',
|
||||
]);
|
||||
|
||||
$response = $this->authenticatedRequest('GET', "/api/v1/tenant/events/{$event->slug}/photobooth");
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonPath('data.enabled', false)
|
||||
->assertJsonPath('data.username', null)
|
||||
->assertJsonPath('data.ftp.port', 2121);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_can_enable_and_rotate_photobooth_access(): void
|
||||
{
|
||||
$event = Event::factory()->for($this->tenant)->create([
|
||||
'slug' => 'photobooth-event',
|
||||
'date' => now()->addDay(),
|
||||
]);
|
||||
|
||||
Http::fake([
|
||||
'https://control.test/*' => Http::response(['ok' => true], 200),
|
||||
]);
|
||||
|
||||
$enable = $this->authenticatedRequest('POST', "/api/v1/tenant/events/{$event->slug}/photobooth/enable");
|
||||
|
||||
$enable->assertOk()
|
||||
->assertJsonPath('data.enabled', true)
|
||||
->assertJsonPath('data.username', fn ($value) => is_string($value) && strlen($value) <= 10);
|
||||
|
||||
$event->refresh();
|
||||
$this->assertTrue($event->photobooth_enabled);
|
||||
$this->assertNotNull($event->photobooth_username);
|
||||
$this->assertNotNull($event->photobooth_password);
|
||||
$username = $event->photobooth_username;
|
||||
$firstPassword = $event->photobooth_password;
|
||||
|
||||
Http::assertSent(fn ($request) => $request->url() === 'https://control.test/users' && $request['username'] === $username);
|
||||
|
||||
$rotate = $this->authenticatedRequest('POST', "/api/v1/tenant/events/{$event->slug}/photobooth/rotate");
|
||||
|
||||
$rotate->assertOk()
|
||||
->assertJsonPath('data.enabled', true);
|
||||
|
||||
$event->refresh();
|
||||
$this->assertNotSame($firstPassword, $event->photobooth_password);
|
||||
|
||||
Http::assertSent(fn ($request) => $request->url() === "https://control.test/users/{$username}/rotate");
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_can_disable_photobooth_access(): void
|
||||
{
|
||||
$event = Event::factory()->for($this->tenant)->create([
|
||||
'slug' => 'photobooth-disable',
|
||||
'photobooth_enabled' => true,
|
||||
'photobooth_username' => 'pb123456',
|
||||
'photobooth_path' => '/photobooth/demo',
|
||||
'photobooth_status' => 'active',
|
||||
'photobooth_expires_at' => now()->subDay(),
|
||||
]);
|
||||
$event->photobooth_password = 'SECRET12';
|
||||
$event->save();
|
||||
|
||||
Http::fake([
|
||||
'https://control.test/*' => Http::response(['ok' => true], 200),
|
||||
]);
|
||||
|
||||
$response = $this->authenticatedRequest('POST', "/api/v1/tenant/events/{$event->slug}/photobooth/disable");
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonPath('data.enabled', false)
|
||||
->assertJsonPath('data.username', null);
|
||||
|
||||
$event->refresh();
|
||||
$this->assertFalse($event->photobooth_enabled);
|
||||
$this->assertNull($event->photobooth_username);
|
||||
|
||||
Http::assertSent(fn ($request) => $request->url() === 'https://control.test/users/pb123456');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user