2023-02-14 14:27:11 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Activity;
|
|
|
|
|
|
|
|
use App\Activity;
|
2023-02-23 22:43:13 +01:00
|
|
|
use App\Subactivity;
|
2023-02-14 14:27:11 +01:00
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class IndexTest extends TestCase
|
|
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
public function testItDisplaysLocalActivities(): void
|
|
|
|
{
|
2023-02-14 14:32:34 +01:00
|
|
|
$this->login()->loginNami()->withoutExceptionHandling();
|
2023-02-23 22:43:13 +01:00
|
|
|
Activity::factory()->name('Local')->create();
|
|
|
|
Activity::factory()->name('Remote')->inNami(123)->create();
|
2023-02-14 14:27:11 +01:00
|
|
|
|
|
|
|
$response = $this->get('/activity');
|
|
|
|
|
|
|
|
$this->assertInertiaHas('Local', $response, 'data.data.0.name');
|
|
|
|
$this->assertCount(1, $this->inertia($response, 'data.data'));
|
|
|
|
}
|
2023-02-23 22:43:13 +01:00
|
|
|
|
|
|
|
public function testItDisplaysDefaultFilter(): void
|
|
|
|
{
|
|
|
|
$this->login()->loginNami()->withoutExceptionHandling();
|
|
|
|
|
|
|
|
$response = $this->callFilter('activity.index', []);
|
|
|
|
|
|
|
|
$this->assertInertiaHas(null, $response, 'data.meta.filter.subactivity');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItFiltersActivityBySubactivity(): void
|
|
|
|
{
|
|
|
|
$this->login()->loginNami()->withoutExceptionHandling();
|
|
|
|
$subactivity = Subactivity::factory()->name('jjon')->create();
|
|
|
|
Activity::factory()->name('Local')->hasAttached($subactivity)->create();
|
|
|
|
Activity::factory()->count(2)->name('Local')->create();
|
|
|
|
|
|
|
|
$response = $this->callFilter('activity.index', ['subactivity_id' => $subactivity->id]);
|
|
|
|
|
|
|
|
$this->assertInertiaHas($subactivity->id, $response, 'data.meta.filter.subactivity_id');
|
|
|
|
$this->assertCount(1, $this->inertia($response, 'data.data'));
|
|
|
|
}
|
2023-02-14 14:27:11 +01:00
|
|
|
}
|