adrema/tests/EndToEnd/MemberIndexTest.php

79 lines
2.6 KiB
PHP
Raw Normal View History

<?php
namespace Tests\EndToEnd;
use App\Group;
2023-12-19 02:00:42 +01:00
use App\Invoice\Models\Invoice;
use App\Invoice\Models\InvoicePosition;
use App\Member\Member;
use Illuminate\Foundation\Testing\DatabaseMigrations;
2024-01-26 00:35:00 +01:00
use Illuminate\Support\Facades\Artisan;
use Laravel\Scout\Console\SyncIndexSettingsCommand;
use Tests\TestCase;
class MemberIndexTest extends TestCase
{
use DatabaseMigrations;
2024-01-26 00:35:00 +01:00
public function setUp(): void
{
parent::setUp();
config()->set('scout.driver', 'meilisearch');
Artisan::call(SyncIndexSettingsCommand::class);
}
public function testItHandlesFullTextSearch(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
2024-01-26 14:52:33 +01:00
Member::factory()->defaults()->create(['firstname' => 'Alexander']);
Member::factory()->defaults()->create(['firstname' => 'Heinrich']);
2024-01-26 14:52:51 +01:00
sleep(5);
2024-01-26 10:28:05 +01:00
$response = $this->callFilter('member.index', ['search' => 'Alexander']);
$this->assertCount(1, $this->inertia($response, 'data.data'));
}
2023-07-24 16:55:07 +02:00
public function testItHandlesAddress(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
2024-01-26 14:52:33 +01:00
Member::factory()->defaults()->create(['address' => '']);
Member::factory()->defaults()->create(['zip' => '']);
Member::factory()->defaults()->create(['location' => '']);
2023-07-24 16:55:07 +02:00
2024-01-26 14:52:51 +01:00
sleep(5);
2023-07-24 16:55:07 +02:00
$response = $this->callFilter('member.index', ['has_full_address' => true]);
$noResponse = $this->callFilter('member.index', ['has_full_address' => false]);
$this->assertCount(0, $this->inertia($response, 'data.data'));
$this->assertCount(3, $this->inertia($noResponse, 'data.data'));
}
public function testItHandlesBirthday(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
2024-01-26 14:52:33 +01:00
$member = Member::factory()->defaults()->create(['birthday' => null]);
2023-07-24 16:55:07 +02:00
2024-01-26 14:52:51 +01:00
sleep(5);
2023-07-24 16:55:07 +02:00
$response = $this->callFilter('member.index', ['has_birthday' => true]);
$this->assertCount(0, $this->inertia($response, 'data.data'));
$member->delete();
}
public function testItFiltersForSearchButNotForPayments(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
2024-01-26 14:52:33 +01:00
Member::factory()->defaults()
2023-12-19 02:00:42 +01:00
->has(InvoicePosition::factory()->for(Invoice::factory()))
->create(['firstname' => '::firstname::']);
2024-01-26 14:52:33 +01:00
Member::factory()->defaults()->create(['firstname' => '::firstname::']);
2024-01-26 14:52:51 +01:00
sleep(5);
$response = $this->callFilter('member.index', ['search' => '::firstname::', 'ausstand' => true]);
$this->assertCount(1, $this->inertia($response, 'data.data'));
}
}