37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
use App\Models\Incentive;
|
|
use App\Models\IncentiveParticipant;
|
|
use App\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('markiert Teilnehmer ohne Teilnahmebestaetigung als nicht oeffentlich (hasAcceptedTerms)', function () {
|
|
$incentive = Incentive::factory()->create();
|
|
|
|
$userA = User::forceCreate([
|
|
'email' => 'a-'.uniqid('', true).'@example.com',
|
|
'password' => bcrypt('secret'),
|
|
'lang' => 'de',
|
|
]);
|
|
$userB = User::forceCreate([
|
|
'email' => 'b-'.uniqid('', true).'@example.com',
|
|
'password' => bcrypt('secret'),
|
|
'lang' => 'de',
|
|
]);
|
|
|
|
$anonymous = IncentiveParticipant::factory()->unconfirmed()->create([
|
|
'incentive_id' => $incentive->id,
|
|
'user_id' => $userA->id,
|
|
]);
|
|
|
|
$confirmed = IncentiveParticipant::factory()->create([
|
|
'incentive_id' => $incentive->id,
|
|
'user_id' => $userB->id,
|
|
'accepted_terms_at' => now(),
|
|
]);
|
|
|
|
expect($anonymous->hasAcceptedTerms())->toBeFalse()
|
|
->and($confirmed->hasAcceptedTerms())->toBeTrue();
|
|
});
|