Compare commits

...

2 Commits

Author SHA1 Message Date
philipp lang ef4cf07647 Lint Member ShowTest
continuous-integration/drone/push Build is failing Details
2025-06-12 01:48:21 +02:00
philipp lang 7b54d29345 Fix ShowTest 2025-06-12 00:17:04 +02:00
1 changed files with 142 additions and 155 deletions

View File

@ -9,29 +9,23 @@ use App\Gender;
use App\Group; use App\Group;
use App\Invoice\Models\Invoice; use App\Invoice\Models\Invoice;
use App\Invoice\Models\InvoicePosition; use App\Invoice\Models\InvoicePosition;
use App\Member\Data\MembershipData;
use App\Member\Member; use App\Member\Member;
use App\Member\Membership; use App\Member\Membership;
use App\Nationality; use App\Nationality;
use App\Payment\Subscription; use App\Payment\Subscription;
use App\Region; use App\Region;
use Carbon\Carbon; use Carbon\Carbon;
use Generator;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
class ShowTest extends TestCase uses(DatabaseTransactions::class);
{ covers(MembershipData::class);
use DatabaseTransactions;
public function setUp(): void beforeEach(function () {
{
parent::setUp();
Country::factory()->create(['name' => 'Deutschland']); Country::factory()->create(['name' => 'Deutschland']);
} });
public function testItShowsSingleMember(): void it('testItShowsSingleMember', function () {
{
Carbon::setTestNow(Carbon::parse('2006-01-01 15:00:00')); Carbon::setTestNow(Carbon::parse('2006-01-01 15:00:00'));
$this->withoutExceptionHandling()->login()->loginNami(); $this->withoutExceptionHandling()->login()->loginNami();
@ -119,8 +113,8 @@ class ShowTest extends TestCase
], $response, 'data'); ], $response, 'data');
$this->assertInertiaHas([ $this->assertInertiaHas([
'id' => $member->memberships->first()->id, 'id' => $member->memberships->first()->id,
'human_date' => '19.11.2022', 'from' => ['human' => '19.11.2022', 'raw' => '2022-11-19'],
'promised_at' => now()->format('Y-m-d'), 'promised_at' => ['human' => now()->format('d.m.Y'), 'raw' => now()->format('Y-m-d')],
'activity' => [ 'activity' => [
'name' => '€ LeiterIn', 'name' => '€ LeiterIn',
'id' => $member->memberships->first()->activity->id, 'id' => $member->memberships->first()->activity->id,
@ -147,10 +141,9 @@ class ShowTest extends TestCase
'status' => 'Neu', 'status' => 'Neu',
] ]
], $response, 'data.invoicePositions.0'); ], $response, 'data.invoicePositions.0');
} });
public function testItShowsMinimalSingleMember(): void it('testItShowsMinimalSingleMember', function () {
{
$this->withoutExceptionHandling()->login()->loginNami(); $this->withoutExceptionHandling()->login()->loginNami();
$member = Member::factory() $member = Member::factory()
->for(Group::factory()) ->for(Group::factory())
@ -176,18 +169,9 @@ class ShowTest extends TestCase
'multiply_pv' => false, 'multiply_pv' => false,
'multiply_more_pv' => false, 'multiply_more_pv' => false,
], $response, 'data'); ], $response, 'data');
} });
public static function membershipDataProvider(): Generator it('testItShowsIfMembershipIsActive', function (Carbon $from, ?Carbon $to, bool $isActive) {
{
yield [now()->subMonths(2), null, true];
yield [now()->subMonths(2), now()->subDay(), false];
yield [now()->addDays(2), null, false];
}
#[DataProvider('membershipDataProvider')]
public function testItShowsIfMembershipIsActive(Carbon $from, ?Carbon $to, bool $isActive): void
{
$this->withoutExceptionHandling()->login()->loginNami(); $this->withoutExceptionHandling()->login()->loginNami();
$member = Member::factory() $member = Member::factory()
->defaults() ->defaults()
@ -197,5 +181,8 @@ class ShowTest extends TestCase
$response = $this->get("/member/{$member->id}"); $response = $this->get("/member/{$member->id}");
$this->assertInertiaHas($isActive, $response, 'data.memberships.0.is_active'); $this->assertInertiaHas($isActive, $response, 'data.memberships.0.is_active');
} })->with([
} [now()->subMonths(2), null, true],
[now()->subMonths(2), now()->subDay(), false],
[now()->addDays(2), null, false],
]);