Skip to content

Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️

1.1 KB
Raw Blame
<?php

namespace Tests\Feature\Http\TeamAccess;

use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use Tests\Concerns\ActsAsAccountUsers;
use Tests\TestCase;

class PublicPreviewScopeTest extends TestCase
{
    use ActsAsAccountUsers;
    use DatabaseTransactions;

    public function test_a_restricted_member_can_preview_only_the_draft_events_they_were_given(): void
    {
        [, $accountId] = $this->createAccountOwner();
        $organizerId = $this->createOrganizer($accountId);
        $grantedEvent = $this->createEvent($accountId, $organizerId, 'Granted');
        $otherEvent = $this->createEvent($accountId, $organizerId, 'Other');
        DB::table('events')->whereIn('id', [$grantedEvent, $otherEvent])->update(['status' => 'DRAFT']);

        $member = $this->addRestrictedAccountUser($accountId, eventIds: [$grantedEvent]);
        $headers = $this->headersFor($member, $accountId);

        $this->getJson("/public/events/{$grantedEvent}", $headers)->assertOk();
        $this->getJson("/public/events/{$otherEvent}", $headers)->assertNotFound();
    }
}