From aaa236fcd501a4efe28f7f4a90f4551f6fa29fc3 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sun, 22 Sep 2024 01:41:56 +0200 Subject: [PATCH] Fix tests --- app/Member/Data/NestedGroup.php | 9 ++++----- packages/laravel-nami | 2 +- tests/Feature/Initialize/InitializeActivitiesTest.php | 2 +- tests/Feature/Member/PreventionTest.php | 6 +++--- tests/Feature/Member/ShowTest.php | 2 +- tests/Feature/Membership/IndexTest.php | 2 +- tests/Unit/Mailman/ServiceTest.php | 8 ++++---- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/Member/Data/NestedGroup.php b/app/Member/Data/NestedGroup.php index 68007842..02cba277 100644 --- a/app/Member/Data/NestedGroup.php +++ b/app/Member/Data/NestedGroup.php @@ -5,7 +5,6 @@ namespace App\Member\Data; use App\Group; use Illuminate\Support\Collection; use Spatie\LaravelData\Data; -use Spatie\LaravelData\DataCollection; class NestedGroup extends Data { @@ -23,7 +22,7 @@ class NestedGroup extends Data $groups = collect([]); foreach (Group::where('parent_id', $parentId)->orderBy('name')->get()->toBase() as $group) { - $groups->push(['name' => str_repeat('- ', $level).$group->name, 'id' => $group->id]); + $groups->push(['name' => str_repeat('- ', $level) . $group->name, 'id' => $group->id]); $groups = $groups->merge(static::forSelect($group->id, $level + 1)); } @@ -31,10 +30,10 @@ class NestedGroup extends Data } /** - * @return DataCollection + * @return Collection */ - public static function cacheForSelect(): DataCollection + public static function cacheForSelect(): Collection { - return static::collection(static::forSelect()); + return static::collect(static::forSelect()); } } diff --git a/packages/laravel-nami b/packages/laravel-nami index b735186c..565cf2b1 160000 --- a/packages/laravel-nami +++ b/packages/laravel-nami @@ -1 +1 @@ -Subproject commit b735186c2d4f844f67992f86f460d6c3deaf5f28 +Subproject commit 565cf2b158dc60283f3ca1daadd7b9317281d8be diff --git a/tests/Feature/Initialize/InitializeActivitiesTest.php b/tests/Feature/Initialize/InitializeActivitiesTest.php index cc44f9b3..9d6d5b91 100644 --- a/tests/Feature/Initialize/InitializeActivitiesTest.php +++ b/tests/Feature/Initialize/InitializeActivitiesTest.php @@ -55,7 +55,7 @@ class InitializeActivitiesTest extends TestCase ]); } - public function activityDataProvider(): Generator + public static function activityDataProvider(): Generator { yield [ fn (ActivityFake $fake) => $fake->fetches(1000, [ diff --git a/tests/Feature/Member/PreventionTest.php b/tests/Feature/Member/PreventionTest.php index 3dff014a..6a277c67 100644 --- a/tests/Feature/Member/PreventionTest.php +++ b/tests/Feature/Member/PreventionTest.php @@ -109,7 +109,7 @@ class PreventionTest extends TestCase $this->assertNotNull($participant->fresh()->last_remembered_at); } - protected function attributes(): Generator + public static function attributes(): Generator { yield [ 'attrs' => ['has_vk' => true, 'efz' => null, 'ps_at' => now()], @@ -172,12 +172,12 @@ class PreventionTest extends TestCase * @param array $memberAttributes */ #[DataProvider('attributes')] - public function testItRemembersMember(array $memberAttributes, array $preventions): void + public function testItRemembersMember(array $attrs, array $preventions): void { Mail::fake(); $form = $this->createForm(); $participant = $this->createParticipant($form); - $participant->member->update($memberAttributes); + $participant->member->update($attrs); PreventionRememberAction::run(); diff --git a/tests/Feature/Member/ShowTest.php b/tests/Feature/Member/ShowTest.php index 8104a757..6d1d76d0 100644 --- a/tests/Feature/Member/ShowTest.php +++ b/tests/Feature/Member/ShowTest.php @@ -171,7 +171,7 @@ class ShowTest extends TestCase ], $response, 'data'); } - public function membershipDataProvider(): Generator + public static function membershipDataProvider(): Generator { yield [now()->subMonths(2), null, true]; yield [now()->subMonths(2), now()->subDay(), false]; diff --git a/tests/Feature/Membership/IndexTest.php b/tests/Feature/Membership/IndexTest.php index e52f9c64..0e58c6ac 100644 --- a/tests/Feature/Membership/IndexTest.php +++ b/tests/Feature/Membership/IndexTest.php @@ -46,7 +46,7 @@ class IndexTest extends TestCase ->assertJsonPath('meta.links.store', route('member.membership.store', ['member' => $member])); } - public function membershipDataProvider(): Generator + public static function membershipDataProvider(): Generator { yield [now()->subMonths(2), null, true]; yield [now()->subMonths(2), now()->subDay(), false]; diff --git a/tests/Unit/Mailman/ServiceTest.php b/tests/Unit/Mailman/ServiceTest.php index 56dbedda..5a3772b2 100644 --- a/tests/Unit/Mailman/ServiceTest.php +++ b/tests/Unit/Mailman/ServiceTest.php @@ -52,7 +52,7 @@ class ServiceTest extends TestCase ]), 200), ]); - $result = app(MailmanService::class)->setCredentials('http://mailman.test/api/', 'user', 'secret')->members(MailingList::factory()->id('listid')->toData())->first(); + $result = app(MailmanService::class)->setCredentials('http://mailman.test/api/', 'user', 'secret')->members(MailingList::toFactory()->id('listid')->toData())->first(); $this->assertEquals(994, $result->memberId); $this->assertEquals('test@example.com', $result->email); @@ -67,7 +67,7 @@ class ServiceTest extends TestCase 'http://mailman.test/api/lists/listid/roster/member?page=1&count=10' => Http::response('', 401), ]); - app(MailmanService::class)->setCredentials('http://mailman.test/api/', 'user', 'secret')->members(MailingList::factory()->id('listid')->toData())->first(); + app(MailmanService::class)->setCredentials('http://mailman.test/api/', 'user', 'secret')->members(MailingList::toFactory()->id('listid')->toData())->first(); } public function testItCanGetLists(): void @@ -90,7 +90,7 @@ class ServiceTest extends TestCase $this->assertEquals('Eltern', $lists[0]->displayName); } - public function listDataProvider(): Generator + public static function listDataProvider(): Generator { foreach (range(3, 40) as $i) { yield [ @@ -114,7 +114,7 @@ class ServiceTest extends TestCase ]); } - $result = app(MailmanService::class)->setCredentials('http://mailman.test/api/', 'user', 'secret')->members(MailingList::factory()->id('listid')->toData()); + $result = app(MailmanService::class)->setCredentials('http://mailman.test/api/', 'user', 'secret')->members(MailingList::toFactory()->id('listid')->toData()); $this->assertCount($totals->count(), $result->toArray()); Http::assertSentCount($totals->chunk(10)->count());