Update guest v2 home and tasks experience
This commit is contained in:
47
tests/Feature/Api/Event/EventStatsTest.php
Normal file
47
tests/Feature/Api/Event/EventStatsTest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Api\Event;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\Photo;
|
||||
use App\Services\EventJoinTokenService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class EventStatsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_it_returns_guest_and_like_counts(): void
|
||||
{
|
||||
$event = Event::factory()->create([
|
||||
'status' => 'published',
|
||||
]);
|
||||
|
||||
Photo::factory()->create([
|
||||
'event_id' => $event->id,
|
||||
'guest_name' => 'Alex',
|
||||
'likes_count' => 3,
|
||||
]);
|
||||
|
||||
Photo::factory()->create([
|
||||
'event_id' => $event->id,
|
||||
'guest_name' => 'Sam',
|
||||
'likes_count' => 5,
|
||||
]);
|
||||
|
||||
Photo::factory()->create([
|
||||
'event_id' => $event->id,
|
||||
'guest_name' => 'Alex',
|
||||
'likes_count' => 2,
|
||||
]);
|
||||
|
||||
$token = app(EventJoinTokenService::class)->createToken($event, ['label' => 'stats']);
|
||||
|
||||
$response = $this->getJson('/api/v1/events/'.$token->plain_token.'/stats');
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertJsonPath('guest_count', 2);
|
||||
$response->assertJsonPath('likes_count', 10);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user