2022-11-17 02:15:29 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Membership;
|
|
|
|
|
|
|
|
use App\Efz\EfzPendingBlock;
|
2023-02-26 18:48:34 +01:00
|
|
|
use App\Group;
|
2022-11-17 02:15:29 +01:00
|
|
|
use App\Member\Member;
|
|
|
|
use App\Member\Membership;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class EfzPendingBlockTest extends TestCase
|
|
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
public function testItDisplaysEfzPending(): void
|
|
|
|
{
|
2023-02-26 18:48:34 +01:00
|
|
|
$this->withoutExceptionHandling()->withNamiSettings(12345, 'password', 101);
|
|
|
|
$group = Group::factory()->inNami(101)->create();
|
|
|
|
|
2022-11-17 02:15:29 +01:00
|
|
|
Member::factory()
|
|
|
|
->has(Membership::factory()->in('€ LeiterIn', 1, 'Biber', 2))
|
|
|
|
->defaults()
|
2023-02-26 18:48:34 +01:00
|
|
|
->for($group)
|
2022-11-17 02:15:29 +01:00
|
|
|
->create(['firstname' => 'Max', 'lastname' => 'Muster', 'efz' => now()->subYear()]);
|
|
|
|
Member::factory()
|
|
|
|
->has(Membership::factory()->in('€ Mitglied', 1, 'Biber', 2))
|
|
|
|
->defaults()
|
2023-02-26 18:48:34 +01:00
|
|
|
->for($group)
|
2022-11-17 02:15:29 +01:00
|
|
|
->create(['firstname' => 'Jane', 'lastname' => 'Muster', 'efz' => now()->subYear()]);
|
|
|
|
Member::factory()
|
|
|
|
->has(Membership::factory()->in('€ LeiterIn', 1, 'Biber', 2))
|
|
|
|
->defaults()
|
2023-02-26 18:48:34 +01:00
|
|
|
->for($group)
|
2022-11-17 02:15:29 +01:00
|
|
|
->create(['firstname' => 'Mae', 'lastname' => 'Muster', 'efz' => now()->subYears(5)->startOfYear()]);
|
|
|
|
Member::factory()
|
|
|
|
->has(Membership::factory()->in('€ LeiterIn', 1, 'Biber', 2))
|
|
|
|
->defaults()
|
2023-02-26 18:48:34 +01:00
|
|
|
->for($group)
|
2022-11-17 02:15:29 +01:00
|
|
|
->create(['firstname' => 'Joe', 'lastname' => 'Muster', 'efz' => now()->subYears(5)->endOfYear()]);
|
|
|
|
Member::factory()
|
|
|
|
->has(Membership::factory()->in('€ LeiterIn', 1, 'Biber', 2))
|
|
|
|
->defaults()
|
2023-02-26 18:48:34 +01:00
|
|
|
->for($group)
|
2022-11-17 02:15:29 +01:00
|
|
|
->create(['firstname' => 'Moa', 'lastname' => 'Muster', 'efz' => null]);
|
|
|
|
Member::factory()
|
|
|
|
->has(Membership::factory()->in('€ Mitglied', 1, 'Biber', 2))
|
|
|
|
->defaults()
|
2023-02-26 18:48:34 +01:00
|
|
|
->for($group)
|
2022-11-17 02:15:29 +01:00
|
|
|
->create(['firstname' => 'Doe', 'lastname' => 'Muster', 'efz' => now()->subYears(5)]);
|
|
|
|
|
|
|
|
$data = app(EfzPendingBlock::class)->render()['data'];
|
|
|
|
|
|
|
|
$this->assertEquals([
|
|
|
|
'members' => ['Joe Muster', 'Mae Muster', 'Moa Muster'],
|
|
|
|
], $data);
|
|
|
|
}
|
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()
|
|
|
|
->has(Membership::factory()->in('€ LeiterIn', 1, 'Biber', 2))
|
|
|
|
->defaults()
|
|
|
|
->for($otherGroup)
|
|
|
|
->create(['firstname' => 'Joe', 'lastname' => 'Muster', 'efz' => now()->subYears(5)->endOfYear()]);
|
|
|
|
|
|
|
|
$data = app(EfzPendingBlock::class)->render()['data'];
|
|
|
|
|
|
|
|
$this->assertCount(0, $data['members']);
|
|
|
|
}
|
2022-11-17 02:15:29 +01:00
|
|
|
}
|