110 lines
3.2 KiB
PHP
110 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\Event;
|
|
use App\Models\Tenant;
|
|
use App\Resources\EventResource;
|
|
use App\Tasks\CloseEvent;
|
|
use DateTime;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Anmeldeschluss und Early-Bird-Ende einer Veranstaltung.
|
|
*
|
|
* Beide sind ein Tag, keine Uhrzeit: Sie gelten einschließlich des ganzen Stichtags bis 23:59.
|
|
*/
|
|
class EventDeadlineTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
private Tenant $tenant;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->tenant = Tenant::create([
|
|
'slug' => 'tv',
|
|
'name' => 'Test',
|
|
'email' => 't@example.com',
|
|
'email_finance' => 'finance@example.com',
|
|
'url' => 'test.local',
|
|
'account_name' => 'Test e.V.',
|
|
'account_iban' => 'DE00',
|
|
'account_bic' => 'XY',
|
|
'city' => 'Stadt',
|
|
'postcode' => '00000',
|
|
'is_active_local_group' => true,
|
|
'has_active_instance' => true,
|
|
]);
|
|
|
|
app()->instance('tenant', $this->tenant);
|
|
|
|
DB::table('participation_fee_types')->insert(['slug' => 'fixed', 'name' => 'Fix']);
|
|
}
|
|
|
|
public function test_am_anmeldeschluss_um_2359_bleibt_die_anmeldung_offen(): void
|
|
{
|
|
$event = $this->makeEvent();
|
|
|
|
$this->travelTo(new DateTime('2026-09-11 23:59:00'));
|
|
new CloseEvent()->handle();
|
|
|
|
$this->assertTrue($event->fresh()->registration_allowed);
|
|
}
|
|
|
|
public function test_am_folgetag_schliesst_der_cron_die_anmeldung(): void
|
|
{
|
|
$event = $this->makeEvent();
|
|
|
|
$this->travelTo(new DateTime('2026-09-12 00:10:00'));
|
|
new CloseEvent()->handle();
|
|
|
|
$this->assertFalse($event->fresh()->registration_allowed);
|
|
}
|
|
|
|
public function test_am_early_bird_stichtag_um_2359_gilt_der_fruehbucherpreis(): void
|
|
{
|
|
$event = $this->makeEvent();
|
|
|
|
$this->travelTo(new DateTime('2026-09-11 23:59:00'));
|
|
|
|
$this->assertEqualsWithDelta(1.0, new EventResource($event)->getMultiplier(), 0.0001);
|
|
}
|
|
|
|
public function test_am_tag_nach_dem_early_bird_stichtag_gilt_der_aufschlag(): void
|
|
{
|
|
$event = $this->makeEvent();
|
|
|
|
$this->travelTo(new DateTime('2026-09-12 00:00:01'));
|
|
|
|
$this->assertEqualsWithDelta(1.2, new EventResource($event)->getMultiplier(), 0.0001);
|
|
}
|
|
|
|
private function makeEvent(): Event
|
|
{
|
|
return Event::create([
|
|
'tenant' => $this->tenant->slug,
|
|
'name' => 'Event',
|
|
'identifier' => 'evt-' . uniqid(),
|
|
'location' => 'Ort',
|
|
'postal_code' => '00000',
|
|
'email' => 'e@example.com',
|
|
'start_date' => '2026-09-20',
|
|
'end_date' => '2026-09-25',
|
|
'early_bird_end' => '2026-09-11',
|
|
'registration_final_end' => '2026-09-11',
|
|
'early_bird_end_amount_increase' => 20,
|
|
'registration_allowed' => true,
|
|
'account_owner' => 'Owner',
|
|
'account_iban' => 'DE00',
|
|
'participation_fee_type' => 'fixed',
|
|
'pay_per_day' => false,
|
|
'pay_direct' => false,
|
|
]);
|
|
}
|
|
}
|