2022-11-17 20:43:51 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Member;
|
|
|
|
|
2023-02-26 18:48:34 +01:00
|
|
|
use App\Group;
|
2022-11-17 20:43:51 +01:00
|
|
|
use App\Member\Member;
|
|
|
|
use App\Member\Membership;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
2024-10-13 21:00:47 +02:00
|
|
|
use Livewire\Livewire;
|
|
|
|
use Modules\Prevention\PsPendingBlock;
|
2022-11-17 20:43:51 +01:00
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class PsPendingBlockTest extends TestCase
|
|
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
public function testItRendersContent(): void
|
|
|
|
{
|
2023-02-26 18:48:34 +01:00
|
|
|
$this->withoutExceptionHandling()->withNamiSettings(12345, 'password', 101);
|
|
|
|
$group = Group::factory()->inNami(101)->create();
|
|
|
|
|
2022-11-17 20:43:51 +01:00
|
|
|
$noPsAtAll = Member::factory()
|
|
|
|
->defaults()
|
2023-02-26 18:48:34 +01:00
|
|
|
->for($group)
|
2022-11-17 20:43:51 +01:00
|
|
|
->has(Membership::factory()->in('€ LeiterIn', 5, 'Wölfling', 8))
|
|
|
|
->create(['firstname' => 'Jane', 'lastname' => 'Doe']);
|
|
|
|
$validPs = Member::factory()
|
|
|
|
->defaults()
|
2023-02-26 18:48:34 +01:00
|
|
|
->for($group)
|
2022-11-17 20:43:51 +01:00
|
|
|
->has(Membership::factory()->in('€ LeiterIn', 5, 'Wölfling', 8))
|
|
|
|
->create(['firstname' => 'Max', 'lastname' => 'Doe', 'ps_at' => now()->subYears(4)]);
|
|
|
|
$validMorePs = Member::factory()
|
|
|
|
->defaults()
|
2023-02-26 18:48:34 +01:00
|
|
|
->for($group)
|
2022-11-17 20:43:51 +01:00
|
|
|
->has(Membership::factory()->in('€ LeiterIn', 5, 'Wölfling', 8))
|
|
|
|
->create(['firstname' => 'Joe', 'lastname' => 'Doe', 'more_ps_at' => now()->subYears(4)]);
|
|
|
|
$invalidPs = Member::factory()
|
|
|
|
->defaults()
|
2023-02-26 18:48:34 +01:00
|
|
|
->for($group)
|
2022-11-17 20:43:51 +01:00
|
|
|
->has(Membership::factory()->in('€ LeiterIn', 5, 'Wölfling', 8))
|
|
|
|
->create(['firstname' => 'Mike', 'lastname' => 'Doe', 'ps_at' => now()->subYears(5)]);
|
|
|
|
$invalidMorePs = Member::factory()
|
|
|
|
->defaults()
|
2023-02-26 18:48:34 +01:00
|
|
|
->for($group)
|
2022-11-17 20:43:51 +01:00
|
|
|
->has(Membership::factory()->in('€ LeiterIn', 5, 'Wölfling', 8))
|
2024-08-30 19:04:18 +02:00
|
|
|
->create(['firstname' => 'Nora', 'lastname' => 'Doe', 'more_ps_at' => now()->subYears(5)]);
|
|
|
|
$inactiveMembership = Member::factory()
|
|
|
|
->defaults()
|
|
|
|
->for($group)
|
|
|
|
->has(Membership::factory()->in('€ LeiterIn', 5, 'Wölfling', 8)->ended())
|
2024-10-13 21:00:47 +02:00
|
|
|
->create(['firstname' => 'Lisa', 'lastname' => 'Doe', 'more_ps_at' => now()->subYears(5)]);
|
2022-11-17 20:43:51 +01:00
|
|
|
$invalidPsButValidMorePs = Member::factory()
|
|
|
|
->defaults()
|
2023-02-26 18:48:34 +01:00
|
|
|
->for($group)
|
2022-11-17 20:43:51 +01:00
|
|
|
->has(Membership::factory()->in('€ LeiterIn', 5, 'Wölfling', 8))
|
|
|
|
->create(['firstname' => 'Hey', 'lastname' => 'Doe', 'ps_at' => now()->subYears(10), 'more_ps_at' => now()->subYears(3)]);
|
|
|
|
$notALeader = Member::factory()
|
|
|
|
->defaults()
|
2023-02-26 18:48:34 +01:00
|
|
|
->for($group)
|
2022-11-17 20:43:51 +01:00
|
|
|
->has(Membership::factory()->in('€ Mitglied', 5, 'Wölfling', 8))
|
|
|
|
->create(['firstname' => 'Mae', 'lastname' => 'Doe']);
|
|
|
|
|
2024-10-13 21:00:47 +02:00
|
|
|
Livewire::test(PsPendingBlock::class)
|
|
|
|
->assertSee('Jane Doe')
|
|
|
|
->assertDontSee('Max Doe')
|
|
|
|
->assertDontSee('Joe Doe')
|
|
|
|
->assertSee('Mike Doe')
|
|
|
|
->assertSee('Nora Doe')
|
|
|
|
->assertDontSee('Lisa Doe')
|
|
|
|
->assertDontSee('Hey Doe')
|
|
|
|
->assertDontSee('Mae Doe');
|
2022-11-17 20:43:51 +01:00
|
|
|
}
|
2023-02-26 18:48:34 +01:00
|
|
|
|
|
|
|
public function testItExcludesForeignGroups(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->withNamiSettings(12345, 'password', 101);
|
|
|
|
Group::factory()->inNami(101)->create();
|
|
|
|
$otherGroup = Group::factory()->inNami(55)->create();
|
|
|
|
|
|
|
|
Member::factory()
|
|
|
|
->defaults()
|
|
|
|
->for($otherGroup)
|
|
|
|
->has(Membership::factory()->in('€ LeiterIn', 5, 'Wölfling', 8))
|
2024-10-13 21:00:47 +02:00
|
|
|
->create(['lastname' => 'Doe']);
|
2023-02-26 18:48:34 +01:00
|
|
|
|
2024-10-13 21:00:47 +02:00
|
|
|
Livewire::test(PsPendingBlock::class)
|
|
|
|
->assertDontSee('Doe');
|
2023-02-26 18:48:34 +01:00
|
|
|
}
|
2022-11-17 20:43:51 +01:00
|
|
|
}
|