From 697620896bc5bd1dcfd9340565cb43eedfd646af Mon Sep 17 00:00:00 2001 From: philipp lang <philipp@aweos.de> Date: Wed, 17 Nov 2021 23:41:04 +0100 Subject: [PATCH] Fixed pagination in search --- packages/laravel-nami | 2 +- tests/Feature/Initialize/InitializeTest.php | 86 +++++++++++++++++++-- 2 files changed, 79 insertions(+), 9 deletions(-) diff --git a/packages/laravel-nami b/packages/laravel-nami index a39c8513..b8c67aa5 160000 --- a/packages/laravel-nami +++ b/packages/laravel-nami @@ -1 +1 @@ -Subproject commit a39c8513c9c1ac65f94e1010a45124054da5d0b0 +Subproject commit b8c67aa5edfcb950435d66211976e26ddadcde91 diff --git a/tests/Feature/Initialize/InitializeTest.php b/tests/Feature/Initialize/InitializeTest.php index 0398bce8..5eccfe1d 100644 --- a/tests/Feature/Initialize/InitializeTest.php +++ b/tests/Feature/Initialize/InitializeTest.php @@ -17,10 +17,9 @@ class InitializeTest extends TestCase use RefreshDatabase; - public function testItInitializesGenders(): void + public function initializeProvider(callable $callback = null): void { - $this->withoutExceptionHandling(); - app(FakeBackend::class) + $backend = app(FakeBackend::class) ->fakeLogin('123', []) ->addSearch(123, ['entries_vorname' => '::firstname::', 'entries_nachname' => '::lastname::', 'entries_gruppierungId' => 1000]) ->fakeNationalities([['name' => 'deutsch', 'id' => 291]]) @@ -29,8 +28,10 @@ class InitializeTest extends TestCase ->fakeCountries([['name' => 'Germany', 'id' => 302]]) ->fakeGenders([['name' => 'Male', 'id' => 303]]) ->fakeRegions([['name' => 'nrw', 'id' => 304]]) - ->fakeActivities(1000, [['name' => 'leiter', 'id' => 305]]) - ->fakeMember([ + ->fakeActivities(1000, [['name' => 'leiter', 'id' => 305]]); + + if (!$callback) { + $backend->fakeMember([ 'vorname' => '::firstname::', 'nachname' => '::lastname::', 'beitragsartId' => 300, @@ -47,10 +48,20 @@ class InitializeTest extends TestCase 'plz' => '12345', 'ort' => '::location::', 'version' => 40, - ]) - ->fakeSubactivities([ - 305 => [['name' => 'wö', 'id' => 306]] ]); + } else { + $callback($backend); + } + + $backend->fakeSubactivities([ + 305 => [['name' => 'wö', 'id' => 306]] + ]); + } + + public function testItInitializesGenders(): void + { + $this->withoutExceptionHandling(); + $this->initializeProvider(); $this->post('/login', [ 'mglnr' => 123, 'password' => 'secret', @@ -101,4 +112,63 @@ class InitializeTest extends TestCase Http::assertSentCount(13); } + + /** + * @return array<int, array<int, int>> + */ + public function pageProvider(): array + { + return [ + [99], + [100], + [101], + [199], + [200], + [201], + ]; + } + + /** + * @dataProvider pageProvider + */ + public function testItInitializesPages($num): void + { + $this->withoutExceptionHandling(); + $this->initializeProvider(function($backend) use ($num) { + $members = collect([]); + + foreach (range(1, $num) as $i) { + $members->push([ + 'vorname' => '::firstname::', + 'nachname' => '::lastname::', + 'beitragsartId' => 300, + 'geburtsDatum' => '2014-07-11 00:00:00', + 'gruppierungId' => 1000, + 'geschlechtId' => 303, + 'id' => $i, + 'eintrittsdatum' => '2020-11-17 00:00:00', + 'geschlechtId' => 303, + 'landId' => 302, + 'staatsangehoerigkeitId' => 291, + 'zeitschriftenversand' => true, + 'strasse' => '::street', + 'plz' => '12345', + 'ort' => '::location::', + 'version' => 40, + ]); + } + + $backend->fakeMembers($members->toArray()); + }); + + $this->post('/login', [ + 'mglnr' => 123, + 'password' => 'secret', + ]); + + $this->post('/initialize'); + + $this->assertDatabaseCount('members', $num); + } + }