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