Fixed tests

This commit is contained in:
philipp lang 2024-02-22 11:13:20 +01:00
parent 458c643615
commit a12cb53274
17 changed files with 30 additions and 28 deletions

View File

@ -52,7 +52,7 @@ class MemberFactory extends Factory
: Nationality::factory()->create();
$subscription = Subscription::count()
? Subscription::get()->random()
: Subscription::factory()->for(Fee::factory())->create();
: Subscription::factory()->forFee()->create();
return $this
->for($country)

View File

@ -19,10 +19,16 @@ class SubscriptionFactory extends Factory
{
return [
'name' => $this->faker->word,
'fee_id' => Fee::factory()->createOne()->id,
];
}
public function forFee(?int $namiId = null): self
{
$namiId = $namiId ?: $this->faker->numberBetween(600, 800);
return $this->for(Fee::factory()->inNami($namiId));
}
public function name(string $name): self
{
return $this->state(['name' => $name]);

@ -1 +1 @@
Subproject commit 49a88577ad5a8b1cd1c4f4219f1c9fd0fef80491
Subproject commit e0ab18a469a831b85f61e10f32d1ad6ede366f43

View File

@ -19,7 +19,7 @@ class InvoiceIndexActionTest extends TestCase
public function testItDisplaysInvoices(): void
{
$this->login()->loginNami()->withoutExceptionHandling();
$subscription = Subscription::factory()->name('Beitrag')->create();
$subscription = Subscription::factory()->forFee()->name('Beitrag')->create();
$member = Member::factory()->defaults()->create(['firstname' => 'Aaaa', 'lastname' => 'Aaab']);
$invoice = Invoice::factory()
->has(InvoicePosition::factory()->price(1100)->for($member)->state(['description' => 'lala']), 'positions')

View File

@ -46,7 +46,7 @@ class MassStoreActionTest extends TestCase
public function testItCreatesPayments(): void
{
$member = Member::factory()->defaults()
->for(Subscription::factory()->children([
->for(Subscription::factory()->forFee()->children([
new Child('beitrag {name}', 4466),
new Child('beitrag2 für {name} für {year}', 2290),
]))->emailBillKind()->create(['firstname' => 'Max', 'lastname' => 'Muster', 'address' => 'Maxstr 4', 'zip' => '33445', 'location' => 'Solingen', 'email' => 'lala@b.de']);
@ -82,7 +82,7 @@ class MassStoreActionTest extends TestCase
public function testItCreatesOneInvoiceForFamilyMember(): void
{
$subscription = Subscription::factory()->children([new Child('beitrag {name}', 4466)])->create();
$subscription = Subscription::factory()->forFee()->children([new Child('beitrag {name}', 4466)])->create();
$member = Member::factory()->defaults()->for($subscription)->emailBillKind()->create(['firstname' => 'Max', 'lastname' => 'Muster']);
Member::factory()->defaults()->for($subscription)->sameFamilyAs($member)->emailBillKind()->create(['firstname' => 'Jane']);
@ -96,7 +96,7 @@ class MassStoreActionTest extends TestCase
public function testItSeparatesBillKinds(): void
{
$subscription = Subscription::factory()->children([new Child('beitrag {name]', 4466)])->create();
$subscription = Subscription::factory()->forFee()->children([new Child('beitrag {name]', 4466)])->create();
$member = Member::factory()->defaults()->for($subscription)->emailBillKind()->create();
Member::factory()->defaults()->for($subscription)->sameFamilyAs($member)->postBillKind()->create();

View File

@ -21,7 +21,7 @@ class MemberNewInvoiceActionTest extends TestCase
public function testItReturnsNewInvoiceOfMember(): void
{
$subscription = Subscription::factory()->children([
$subscription = Subscription::factory()->forFee()->children([
new Child('beitrag {name}', 4466),
new Child('beitrag2 für {name} für {year}', 2290),
])->create();

View File

@ -17,7 +17,7 @@ class DavTest extends TestCase
public function testItCanStoreAMemberFromAVcard(): void
{
Nationality::factory()->create(['name' => 'englisch']);
$subscription = Subscription::factory()->create(['name' => 'Voll']);
$subscription = Subscription::factory()->forFee()->create(['name' => 'Voll']);
$nationality = Nationality::factory()->create(['name' => 'deutsch']);
$group = Group::factory()->create();
NamiSettings::fake(['default_group_id' => $group->id]);

View File

@ -33,7 +33,7 @@ class NamiPutMemberActionTest extends TestCase
$country = Country::factory()->create();
$region = Region::factory()->create();
$nationality = Nationality::factory()->inNami(565)->create();
$subscription = Subscription::factory()->create();
$subscription = Subscription::factory()->forFee()->create();
$group = Group::factory()->inNami(55)->create();
$confession = Confession::factory()->inNami(567)->create(['is_null' => true]);
app(MemberFake::class)->stores(55, 993);

View File

@ -27,7 +27,7 @@ class PullCoursesActionTest extends TestCase
{
parent::setUp();
Subscription::factory()->name('test')->for(Fee::factory()->inNami(300))->create();
Subscription::factory()->name('test')->forFee(300)->create();
Gender::factory()->inNami(303)->create();
Country::factory()->inNami(302)->create();
Nationality::factory()->inNami(1054)->create();

View File

@ -22,7 +22,7 @@ class PullMemberActionTest extends TestCase
{
parent::setUp();
Subscription::factory()->name('test')->for(Fee::factory()->inNami(300))->create();
Subscription::factory()->name('test')->forFee(300)->create();
Gender::factory()->inNami(303)->create();
Country::factory()->inNami(302)->create();
Nationality::factory()->inNami(1054)->create();
@ -97,9 +97,7 @@ class PullMemberActionTest extends TestCase
public function testItSetsFirstSubscriptionFromFee(): void
{
Region::factory()->inNami(999)->name('nicht-de')->create(['is_null' => true]);
Subscription::factory()->for(Fee::factory()->inNami(54))->create();
$should = Subscription::factory()->for(Fee::factory()->inNami(55))->create();
Subscription::factory()->for(Fee::factory()->inNami(56))->create();
$should = Subscription::factory()->forFee(55)->create();
app(MemberFake::class)->shows(1000, 1001, [
'beitragsartId' => 55,
]);

View File

@ -28,7 +28,7 @@ class PullMembershipsActionTest extends TestCase
{
parent::setUp();
Subscription::factory()->name('test')->for(Fee::factory()->inNami(300))->create();
Subscription::factory()->name('test')->forFee(300)->create();
Gender::factory()->inNami(303)->create();
Country::factory()->inNami(302)->create();
Nationality::factory()->inNami(1054)->create();

View File

@ -39,7 +39,7 @@ class ShowTest extends TestCase
->for(Region::factory()->name('NRW'))
->postBillKind()
->inNami(123)
->for(Subscription::factory()->name('Sub')->for(Fee::factory()))
->for(Subscription::factory()->name('Sub')->forFee())
->has(CourseMember::factory()->for(Course::factory()->name(' Baustein 2e - Gewalt gegen Kinder und Jugendliche: Vertiefung, Prävention '))->state(['organizer' => 'DPSG', 'event_name' => 'Wochenende', 'completed_at' => '2022-03-03']), 'courses')
->create([
'birthday' => '1991-04-20',
@ -143,7 +143,7 @@ class ShowTest extends TestCase
$member = Member::factory()
->for(Group::factory())
->for(Nationality::factory()->name('deutsch'))
->for(Subscription::factory()->for(Fee::factory()))
->for(Subscription::factory()->forFee())
->create(['firstname' => 'Max', 'lastname' => 'Muster']);
$response = $this->get("/member/{$member->id}");

View File

@ -36,7 +36,7 @@ class StoreTest extends TestCase
$nationality = Nationality::factory()->create();
$activity = Activity::factory()->inNami(89)->create();
$subactivity = Subactivity::factory()->inNami(90)->create();
$subscription = Subscription::factory()->create();
$subscription = Subscription::factory()->forFee()->create();
$confesstion = Confession::factory()->create(['is_null' => true]);
PullMemberAction::shouldRun();
PullMembershipsAction::shouldRun();
@ -225,7 +225,7 @@ class StoreTest extends TestCase
{
$country = Country::factory()->create();
$nationality = Nationality::factory()->create();
$subscription = Subscription::factory()->create();
$subscription = Subscription::factory()->forFee()->create();
return [
'address' => 'Bavert 50',

View File

@ -197,7 +197,7 @@ class UpdateTest extends TestCase
->for(Group::factory()->state(['nami_id' => 10]))
->for(Confession::factory())
->for(Nationality::factory())
->for(Subscription::factory()->for(Fee::factory()))
->for(Subscription::factory()->forFee())
->for(Country::factory())
->create(['nami_id' => 135, ...$overwrites]);
}

View File

@ -2,7 +2,6 @@
namespace Tests\Feature\Subscription;
use App\Fee;
use App\Payment\Subscription;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\RequestFactories\Child;
@ -15,7 +14,7 @@ class DestroyTest extends TestCase
public function testItDeletesChildrenWithSubscription(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
$subscription = Subscription::factory()->name('hi')->for(Fee::factory())->children([
$subscription = Subscription::factory()->name('hi')->forFee()->children([
new Child('a', 1400),
new Child('b', 1500),
])->create();

View File

@ -2,7 +2,6 @@
namespace Tests\Feature\Subscription;
use App\Fee;
use App\Payment\Subscription;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\RequestFactories\Child;
@ -15,7 +14,7 @@ class EditTest extends TestCase
public function testItReturnsChildren(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
$subscription = Subscription::factory()->name('hi')->for(Fee::factory())->children([
$subscription = Subscription::factory()->name('hi')->forFee()->children([
new Child('a', 1400),
new Child('b', 1500),
])->create();

View File

@ -16,7 +16,7 @@ class UpdateTest extends TestCase
public function testItUpdatesASubscription(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
$subscription = Subscription::factory()->name('hi')->for(Fee::factory())->create();
$subscription = Subscription::factory()->name('hi')->forFee()->create();
$fee = Fee::factory()->create();
$response = $this->from("/subscription/{$subscription->id}")->patch(
@ -35,7 +35,7 @@ class UpdateTest extends TestCase
public function testItUpdatesChildren(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
$subscription = Subscription::factory()->name('hi')->for(Fee::factory())->children([
$subscription = Subscription::factory()->name('hi')->forFee()->children([
new Child('a', 1400),
new Child('b', 1500),
])->create();
@ -59,7 +59,7 @@ class UpdateTest extends TestCase
public function testItValidatesRequest(): void
{
$this->login()->loginNami();
$subscription = Subscription::factory()->name('hi')->for(Fee::factory())->create();
$subscription = Subscription::factory()->name('hi')->forFee()->create();
$response = $this->from("/subscription/{$subscription->id}")->patch(
"/subscription/{$subscription->id}",