81 lines
3.1 KiB
PHP
81 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Membership;
|
|
|
|
use App\Efz\EfzPendingBlock;
|
|
use App\Group;
|
|
use App\Member\Member;
|
|
use App\Member\Membership;
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
use Livewire\Livewire;
|
|
use Modules\Prevention\EfzPendingBlock as PreventionEfzPendingBlock;
|
|
use Tests\TestCase;
|
|
|
|
class EfzPendingBlockTest extends TestCase
|
|
{
|
|
use DatabaseTransactions;
|
|
|
|
public function testItDisplaysEfzPending(): void
|
|
{
|
|
$this->withoutExceptionHandling()->withNamiSettings(12345, 'password', 101);
|
|
$group = Group::factory()->inNami(101)->create();
|
|
|
|
Member::factory()
|
|
->has(Membership::factory()->in('€ LeiterIn', 1, 'Biber', 2))
|
|
->defaults()
|
|
->for($group)
|
|
->create(['firstname' => 'Max', 'lastname' => 'Muster', 'efz' => now()->subYear()]);
|
|
Member::factory()
|
|
->has(Membership::factory()->in('€ Mitglied', 1, 'Biber', 2))
|
|
->defaults()
|
|
->for($group)
|
|
->create(['firstname' => 'Jane', 'lastname' => 'Muster', 'efz' => now()->subYear()]);
|
|
Member::factory()
|
|
->has(Membership::factory()->in('€ LeiterIn', 1, 'Biber', 2))
|
|
->defaults()
|
|
->for($group)
|
|
->create(['firstname' => 'Mae', 'lastname' => 'Muster', 'efz' => now()->subYears(5)->startOfYear()]);
|
|
Member::factory()
|
|
->has(Membership::factory()->in('€ LeiterIn', 1, 'Biber', 2))
|
|
->defaults()
|
|
->for($group)
|
|
->create(['firstname' => 'Joe', 'lastname' => 'Muster', 'efz' => now()->subYears(5)->endOfYear()]);
|
|
Member::factory()
|
|
->has(Membership::factory()->in('€ LeiterIn', 1, 'Biber', 2)->ended())
|
|
->defaults()
|
|
->for($group)
|
|
->create(['firstname' => 'Joe', 'lastname' => 'Muster', 'efz' => now()->subYears(5)->endOfYear()]);
|
|
Member::factory()
|
|
->has(Membership::factory()->in('€ LeiterIn', 1, 'Biber', 2))
|
|
->defaults()
|
|
->for($group)
|
|
->create(['firstname' => 'Moa', 'lastname' => 'Muster', 'efz' => null]);
|
|
Member::factory()
|
|
->has(Membership::factory()->in('€ Mitglied', 1, 'Biber', 2))
|
|
->defaults()
|
|
->for($group)
|
|
->create(['firstname' => 'Doe', 'lastname' => 'Muster', 'efz' => now()->subYears(5)]);
|
|
|
|
Livewire::test(PreventionEfzPendingBlock::class)
|
|
->assertSee('Joe Muster')
|
|
->assertSee('Mae Muster')
|
|
->assertSee('Moa Muster');
|
|
}
|
|
|
|
public function testItExcludesForeignGroups(): void
|
|
{
|
|
$this->withoutExceptionHandling()->withNamiSettings(12345, 'password', 101);
|
|
Group::factory()->inNami(101)->create();
|
|
$otherGroup = Group::factory()->inNami(55)->create();
|
|
|
|
Member::factory()
|
|
->has(Membership::factory()->in('€ LeiterIn', 1, 'Biber', 2))
|
|
->defaults()
|
|
->for($otherGroup)
|
|
->create(['firstname' => 'Joe', 'lastname' => 'Muster', 'efz' => now()->subYears(5)->endOfYear()]);
|
|
|
|
Livewire::test(PreventionEfzPendingBlock::class)
|
|
->assertDontSee('Joe');
|
|
}
|
|
}
|