Compare commits
No commits in common. "ef4cf07647245402e06cb77dca3b1bb0d0615217" and "fd8c0f1085ec03a26d84ac45d840f7b6a39ad673" have entirely different histories.
ef4cf07647
...
fd8c0f1085
|
@ -9,23 +9,29 @@ 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;
|
||||||
|
|
||||||
uses(DatabaseTransactions::class);
|
class ShowTest extends TestCase
|
||||||
covers(MembershipData::class);
|
{
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
beforeEach(function () {
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
Country::factory()->create(['name' => 'Deutschland']);
|
Country::factory()->create(['name' => 'Deutschland']);
|
||||||
});
|
}
|
||||||
|
|
||||||
it('testItShowsSingleMember', function () {
|
public function testItShowsSingleMember(): void
|
||||||
|
{
|
||||||
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();
|
||||||
|
@ -113,8 +119,8 @@ it('testItShowsSingleMember', function () {
|
||||||
], $response, 'data');
|
], $response, 'data');
|
||||||
$this->assertInertiaHas([
|
$this->assertInertiaHas([
|
||||||
'id' => $member->memberships->first()->id,
|
'id' => $member->memberships->first()->id,
|
||||||
'from' => ['human' => '19.11.2022', 'raw' => '2022-11-19'],
|
'human_date' => '19.11.2022',
|
||||||
'promised_at' => ['human' => now()->format('d.m.Y'), 'raw' => now()->format('Y-m-d')],
|
'promised_at' => now()->format('Y-m-d'),
|
||||||
'activity' => [
|
'activity' => [
|
||||||
'name' => '€ LeiterIn',
|
'name' => '€ LeiterIn',
|
||||||
'id' => $member->memberships->first()->activity->id,
|
'id' => $member->memberships->first()->activity->id,
|
||||||
|
@ -141,9 +147,10 @@ it('testItShowsSingleMember', function () {
|
||||||
'status' => 'Neu',
|
'status' => 'Neu',
|
||||||
]
|
]
|
||||||
], $response, 'data.invoicePositions.0');
|
], $response, 'data.invoicePositions.0');
|
||||||
});
|
}
|
||||||
|
|
||||||
it('testItShowsMinimalSingleMember', function () {
|
public function testItShowsMinimalSingleMember(): void
|
||||||
|
{
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
$member = Member::factory()
|
$member = Member::factory()
|
||||||
->for(Group::factory())
|
->for(Group::factory())
|
||||||
|
@ -169,9 +176,18 @@ it('testItShowsMinimalSingleMember', function () {
|
||||||
'multiply_pv' => false,
|
'multiply_pv' => false,
|
||||||
'multiply_more_pv' => false,
|
'multiply_more_pv' => false,
|
||||||
], $response, 'data');
|
], $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();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
$member = Member::factory()
|
$member = Member::factory()
|
||||||
->defaults()
|
->defaults()
|
||||||
|
@ -181,8 +197,5 @@ it('testItShowsIfMembershipIsActive', function (Carbon $from, ?Carbon $to, bool
|
||||||
$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],
|
|
||||||
]);
|
|
||||||
|
|
Loading…
Reference in New Issue