Compare commits

..

No commits in common. "ef4cf07647245402e06cb77dca3b1bb0d0615217" and "fd8c0f1085ec03a26d84ac45d840f7b6a39ad673" have entirely different histories.

1 changed files with 155 additions and 142 deletions

View File

@ -9,23 +9,29 @@ 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;
uses(DatabaseTransactions::class);
covers(MembershipData::class);
class ShowTest extends TestCase
{
use DatabaseTransactions;
beforeEach(function () {
public function setUp(): void
{
parent::setUp();
Country::factory()->create(['name' => 'Deutschland']);
});
}
it('testItShowsSingleMember', function () {
public function testItShowsSingleMember(): void
{
Carbon::setTestNow(Carbon::parse('2006-01-01 15:00:00'));
$this->withoutExceptionHandling()->login()->loginNami();
@ -113,8 +119,8 @@ it('testItShowsSingleMember', function () {
], $response, 'data');
$this->assertInertiaHas([
'id' => $member->memberships->first()->id,
'from' => ['human' => '19.11.2022', 'raw' => '2022-11-19'],
'promised_at' => ['human' => now()->format('d.m.Y'), 'raw' => now()->format('Y-m-d')],
'human_date' => '19.11.2022',
'promised_at' => now()->format('Y-m-d'),
'activity' => [
'name' => '€ LeiterIn',
'id' => $member->memberships->first()->activity->id,
@ -141,9 +147,10 @@ it('testItShowsSingleMember', function () {
'status' => 'Neu',
]
], $response, 'data.invoicePositions.0');
});
}
it('testItShowsMinimalSingleMember', function () {
public function testItShowsMinimalSingleMember(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
$member = Member::factory()
->for(Group::factory())
@ -169,9 +176,18 @@ it('testItShowsMinimalSingleMember', function () {
'multiply_pv' => false,
'multiply_more_pv' => false,
], $response, 'data');
});
}
it('testItShowsIfMembershipIsActive', function (Carbon $from, ?Carbon $to, bool $isActive) {
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
{
$this->withoutExceptionHandling()->login()->loginNami();
$member = Member::factory()
->defaults()
@ -181,8 +197,5 @@ it('testItShowsIfMembershipIsActive', function (Carbon $from, ?Carbon $to, bool
$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],
]);
}
}