Compare commits
3 Commits
3a4c99f154
...
aaa236fcd5
Author | SHA1 | Date |
---|---|---|
|
aaa236fcd5 | |
|
4d74e53fc2 | |
|
b8d389bdb9 |
|
@ -5,7 +5,6 @@ namespace App\Member\Data;
|
||||||
use App\Group;
|
use App\Group;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Spatie\LaravelData\Data;
|
use Spatie\LaravelData\Data;
|
||||||
use Spatie\LaravelData\DataCollection;
|
|
||||||
|
|
||||||
class NestedGroup extends Data
|
class NestedGroup extends Data
|
||||||
{
|
{
|
||||||
|
@ -31,10 +30,10 @@ class NestedGroup extends Data
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return DataCollection<int, static>
|
* @return Collection<int, static>
|
||||||
*/
|
*/
|
||||||
public static function cacheForSelect(): DataCollection
|
public static function cacheForSelect(): Collection
|
||||||
{
|
{
|
||||||
return static::collection(static::forSelect());
|
return static::collect(static::forSelect());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit b735186c2d4f844f67992f86f460d6c3deaf5f28
|
Subproject commit 565cf2b158dc60283f3ca1daadd7b9317281d8be
|
|
@ -5,14 +5,10 @@ namespace Tests\Feature\Activity;
|
||||||
use App\Activity;
|
use App\Activity;
|
||||||
use App\Subactivity;
|
use App\Subactivity;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Tests\TestCase;
|
|
||||||
|
|
||||||
class EditTest extends TestCase
|
uses(DatabaseTransactions::class);
|
||||||
{
|
|
||||||
use DatabaseTransactions;
|
|
||||||
|
|
||||||
public function testItEditsAnActivity(): void
|
it('testItEditsAnActivity', function () {
|
||||||
{
|
|
||||||
$this->login()->loginNami()->withoutExceptionHandling();
|
$this->login()->loginNami()->withoutExceptionHandling();
|
||||||
$activity = Activity::factory()->name('Asas')->hasAttached(Subactivity::factory()->name('Pupu')->filterable())->create();
|
$activity = Activity::factory()->name('Asas')->hasAttached(Subactivity::factory()->name('Pupu')->filterable())->create();
|
||||||
|
|
||||||
|
@ -43,5 +39,4 @@ class EditTest extends TestCase
|
||||||
'update' => route('api.subactivity.update', ['subactivity' => $activity->subactivities->first()->id]),
|
'update' => route('api.subactivity.update', ['subactivity' => $activity->subactivities->first()->id]),
|
||||||
],
|
],
|
||||||
], $response, 'meta.subactivities.0');
|
], $response, 'meta.subactivities.0');
|
||||||
}
|
});
|
||||||
}
|
|
||||||
|
|
|
@ -3,18 +3,17 @@
|
||||||
namespace Tests\Feature\Activity;
|
namespace Tests\Feature\Activity;
|
||||||
|
|
||||||
use App\Activity;
|
use App\Activity;
|
||||||
|
use App\Activity\Actions\ActivityUpdateAction;
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
use App\Member\Membership;
|
use App\Member\Membership;
|
||||||
use App\Subactivity;
|
use App\Subactivity;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Tests\TestCase;
|
|
||||||
|
|
||||||
class UpdateTest extends TestCase
|
covers(ActivityUpdateAction::class);
|
||||||
{
|
|
||||||
use DatabaseTransactions;
|
|
||||||
|
|
||||||
public function testItCannotUpdateAnActivityFromNami(): void
|
uses(DatabaseTransactions::class);
|
||||||
{
|
|
||||||
|
it('testItCannotUpdateAnActivityFromNami', function () {
|
||||||
$this->login()->loginNami();
|
$this->login()->loginNami();
|
||||||
$activity = Activity::factory()->inNami(67)->name('abc')->create();
|
$activity = Activity::factory()->inNami(67)->name('abc')->create();
|
||||||
|
|
||||||
|
@ -25,10 +24,9 @@ class UpdateTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response->assertSessionHasErrors(['nami_id' => 'Aktivität ist in NaMi. Update des Namens nicht möglich.']);
|
$response->assertSessionHasErrors(['nami_id' => 'Aktivität ist in NaMi. Update des Namens nicht möglich.']);
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testItCanUpdateSubactivitiesOfNamiActivity(): void
|
it('testItCanUpdateSubactivitiesOfNamiActivity', function () {
|
||||||
{
|
|
||||||
$this->login()->loginNami();
|
$this->login()->loginNami();
|
||||||
$activity = Activity::factory()->inNami(67)->name('abc')->create();
|
$activity = Activity::factory()->inNami(67)->name('abc')->create();
|
||||||
$subactivity = Subactivity::factory()->create();
|
$subactivity = Subactivity::factory()->create();
|
||||||
|
@ -40,10 +38,9 @@ class UpdateTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertDatabaseHas('activity_subactivity', ['activity_id' => $activity->id, 'subactivity_id' => $subactivity->id]);
|
$this->assertDatabaseHas('activity_subactivity', ['activity_id' => $activity->id, 'subactivity_id' => $subactivity->id]);
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testItCannotRemoveANamiSubactivityFromANamiActivity(): void
|
it('testItCannotRemoveANamiSubactivityFromANamiActivity', function () {
|
||||||
{
|
|
||||||
$this->login()->loginNami();
|
$this->login()->loginNami();
|
||||||
$activity = Activity::factory()->inNami(67)->name('abc')->has(Subactivity::factory()->inNami(69))->create();
|
$activity = Activity::factory()->inNami(67)->name('abc')->has(Subactivity::factory()->inNami(69))->create();
|
||||||
|
|
||||||
|
@ -54,10 +51,9 @@ class UpdateTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response->assertSessionHasErrors(['nami_id' => 'Untertätigkeit kann nicht entfernt werden.']);
|
$response->assertSessionHasErrors(['nami_id' => 'Untertätigkeit kann nicht entfernt werden.']);
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testItCannotAddANamiSubactivityToANamiActivity(): void
|
it('testItCannotAddANamiSubactivityToANamiActivity', function () {
|
||||||
{
|
|
||||||
$this->login()->loginNami();
|
$this->login()->loginNami();
|
||||||
$activity = Activity::factory()->inNami(67)->name('abc')->create();
|
$activity = Activity::factory()->inNami(67)->name('abc')->create();
|
||||||
$subactivity = Subactivity::factory()->inNami(60)->create();
|
$subactivity = Subactivity::factory()->inNami(60)->create();
|
||||||
|
@ -69,10 +65,21 @@ class UpdateTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response->assertSessionHasErrors(['nami_id' => 'Untertätigkeit kann nicht hinzugefügt werden.']);
|
$response->assertSessionHasErrors(['nami_id' => 'Untertätigkeit kann nicht hinzugefügt werden.']);
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testItCannotRemoveANamiSubactivityFromANamiActivityAndSetAnother(): void
|
it('test it cannot set subactivity to a string', function () {
|
||||||
{
|
$this->login()->loginNami();
|
||||||
|
$activity = Activity::factory()->create();
|
||||||
|
|
||||||
|
$this->patch(route('activity.update', ['activity' => $activity]), [
|
||||||
|
'name' => 'abc',
|
||||||
|
'is_filterable' => false,
|
||||||
|
'subactivities' => ['AAA'],
|
||||||
|
])->assertSessionHasErrors('subactivities.0');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('testItCannotRemoveANamiSubactivityFromANamiActivityAndSetAnother', function () {
|
||||||
$this->login()->loginNami();
|
$this->login()->loginNami();
|
||||||
$activity = Activity::factory()->inNami(67)->name('abc')->has(Subactivity::factory()->inNami(69))->create();
|
$activity = Activity::factory()->inNami(67)->name('abc')->has(Subactivity::factory()->inNami(69))->create();
|
||||||
$otherSubactivity = Subactivity::factory()->create();
|
$otherSubactivity = Subactivity::factory()->create();
|
||||||
|
@ -84,10 +91,9 @@ class UpdateTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response->assertSessionHasErrors(['nami_id' => 'Untertätigkeit kann nicht entfernt werden.']);
|
$response->assertSessionHasErrors(['nami_id' => 'Untertätigkeit kann nicht entfernt werden.']);
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testNameIsRequired(): void
|
it('testNameIsRequired', function () {
|
||||||
{
|
|
||||||
$this->login()->loginNami();
|
$this->login()->loginNami();
|
||||||
$activity = Activity::factory()->create();
|
$activity = Activity::factory()->create();
|
||||||
|
|
||||||
|
@ -98,10 +104,9 @@ class UpdateTest extends TestCase
|
||||||
|
|
||||||
$response->assertSessionHasErrors(['name' => 'Name ist erforderlich.']);
|
$response->assertSessionHasErrors(['name' => 'Name ist erforderlich.']);
|
||||||
$response->assertSessionHasErrors(['subactivities' => 'Untergliederungen muss vorhanden sein.']);
|
$response->assertSessionHasErrors(['subactivities' => 'Untergliederungen muss vorhanden sein.']);
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testItUpdatesName(): void
|
it('testItUpdatesName', function () {
|
||||||
{
|
|
||||||
$this->login()->loginNami();
|
$this->login()->loginNami();
|
||||||
$activity = Activity::factory()->name('UUU')->create();
|
$activity = Activity::factory()->name('UUU')->create();
|
||||||
|
|
||||||
|
@ -113,10 +118,9 @@ class UpdateTest extends TestCase
|
||||||
|
|
||||||
$response->assertRedirect('/activity');
|
$response->assertRedirect('/activity');
|
||||||
$this->assertDatabaseHas('activities', ['name' => 'Lorem', 'is_filterable' => true]);
|
$this->assertDatabaseHas('activities', ['name' => 'Lorem', 'is_filterable' => true]);
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testItSetsSubactivities(): void
|
it('testItSetsSubactivities', function () {
|
||||||
{
|
|
||||||
$this->login()->loginNami();
|
$this->login()->loginNami();
|
||||||
$activity = Activity::factory()->create();
|
$activity = Activity::factory()->create();
|
||||||
$subactivity = Subactivity::factory()->create();
|
$subactivity = Subactivity::factory()->create();
|
||||||
|
@ -128,10 +132,9 @@ class UpdateTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertDatabaseHas('activity_subactivity', ['activity_id' => $activity->id, 'subactivity_id' => $subactivity->id]);
|
$this->assertDatabaseHas('activity_subactivity', ['activity_id' => $activity->id, 'subactivity_id' => $subactivity->id]);
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testItCannotSetNamiId(): void
|
it('testItCannotSetNamiId', function () {
|
||||||
{
|
|
||||||
$this->login()->loginNami();
|
$this->login()->loginNami();
|
||||||
$activity = Activity::factory()->create();
|
$activity = Activity::factory()->create();
|
||||||
|
|
||||||
|
@ -143,10 +146,9 @@ class UpdateTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertDatabaseHas('activities', ['nami_id' => null]);
|
$this->assertDatabaseHas('activities', ['nami_id' => null]);
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testItUnsetsSubactivities(): void
|
it('testItUnsetsSubactivities', function () {
|
||||||
{
|
|
||||||
$this->login()->loginNami();
|
$this->login()->loginNami();
|
||||||
$activity = Activity::factory()
|
$activity = Activity::factory()
|
||||||
->hasAttached(Subactivity::factory())
|
->hasAttached(Subactivity::factory())
|
||||||
|
@ -159,22 +161,52 @@ class UpdateTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertDatabaseEmpty('activity_subactivity');
|
$this->assertDatabaseEmpty('activity_subactivity');
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testItCannotSetSubactivityIfItStillHasMembers(): void
|
it('testItCannotSetSubactivityIfItStillHasMembers', function () {
|
||||||
{
|
|
||||||
$this->login()->loginNami();
|
$this->login()->loginNami();
|
||||||
$activity = Activity::factory()->create();
|
$activity = Activity::factory()
|
||||||
$subactivity = Subactivity::factory()->hasAttached($activity)->create();
|
->hasAttached(Subactivity::factory())
|
||||||
$newSubactivity = Subactivity::factory()->create();
|
->create();
|
||||||
Member::factory()->defaults()->has(Membership::factory()->for($activity)->for($subactivity))->create();
|
Member::factory()->defaults()->has(Membership::factory()->for($activity)->for($activity->subactivities->first()))->create();
|
||||||
|
|
||||||
$response = $this->patch(route('activity.update', ['activity' => $activity]), [
|
$response = $this->patch(route('activity.update', ['activity' => $activity]), [
|
||||||
'name' => 'abc',
|
'name' => 'abc',
|
||||||
'is_filterable' => false,
|
'is_filterable' => false,
|
||||||
'subactivities' => [$newSubactivity->id],
|
'subactivities' => [],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response->assertSessionHasErrors(['subactivities' => 'Untergliederung hat noch Mitglieder.']);
|
$response->assertSessionHasErrors(['subactivities' => 'Untergliederung hat noch Mitglieder.']);
|
||||||
}
|
});
|
||||||
}
|
|
||||||
|
it('test it succeeds when membership is not of removing subactivity', function () {
|
||||||
|
$this->login()->loginNami();
|
||||||
|
$activity = Activity::factory()
|
||||||
|
->hasAttached(Subactivity::factory())
|
||||||
|
->create();
|
||||||
|
Member::factory()->defaults()->has(Membership::factory()->for($activity)->for(Subactivity::factory()))->create();
|
||||||
|
|
||||||
|
$response = $this->patch(route('activity.update', ['activity' => $activity]), [
|
||||||
|
'name' => 'abc',
|
||||||
|
'is_filterable' => false,
|
||||||
|
'subactivities' => [],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertSessionDoesntHaveErrors();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('test it succeeds when membership is not of removing activity', function () {
|
||||||
|
$this->login()->loginNami();
|
||||||
|
$activity = Activity::factory()
|
||||||
|
->hasAttached(Subactivity::factory())
|
||||||
|
->create();
|
||||||
|
Member::factory()->defaults()->has(Membership::factory()->for(Activity::factory())->for($activity->subactivities->first()))->create();
|
||||||
|
|
||||||
|
$response = $this->patch(route('activity.update', ['activity' => $activity]), [
|
||||||
|
'name' => 'abc',
|
||||||
|
'is_filterable' => false,
|
||||||
|
'subactivities' => [],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertSessionDoesntHaveErrors();
|
||||||
|
});
|
||||||
|
|
|
@ -55,7 +55,7 @@ class InitializeActivitiesTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function activityDataProvider(): Generator
|
public static function activityDataProvider(): Generator
|
||||||
{
|
{
|
||||||
yield [
|
yield [
|
||||||
fn (ActivityFake $fake) => $fake->fetches(1000, [
|
fn (ActivityFake $fake) => $fake->fetches(1000, [
|
||||||
|
|
|
@ -109,7 +109,7 @@ class PreventionTest extends TestCase
|
||||||
$this->assertNotNull($participant->fresh()->last_remembered_at);
|
$this->assertNotNull($participant->fresh()->last_remembered_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function attributes(): Generator
|
public static function attributes(): Generator
|
||||||
{
|
{
|
||||||
yield [
|
yield [
|
||||||
'attrs' => ['has_vk' => true, 'efz' => null, 'ps_at' => now()],
|
'attrs' => ['has_vk' => true, 'efz' => null, 'ps_at' => now()],
|
||||||
|
@ -172,12 +172,12 @@ class PreventionTest extends TestCase
|
||||||
* @param array<string, mixed> $memberAttributes
|
* @param array<string, mixed> $memberAttributes
|
||||||
*/
|
*/
|
||||||
#[DataProvider('attributes')]
|
#[DataProvider('attributes')]
|
||||||
public function testItRemembersMember(array $memberAttributes, array $preventions): void
|
public function testItRemembersMember(array $attrs, array $preventions): void
|
||||||
{
|
{
|
||||||
Mail::fake();
|
Mail::fake();
|
||||||
$form = $this->createForm();
|
$form = $this->createForm();
|
||||||
$participant = $this->createParticipant($form);
|
$participant = $this->createParticipant($form);
|
||||||
$participant->member->update($memberAttributes);
|
$participant->member->update($attrs);
|
||||||
|
|
||||||
PreventionRememberAction::run();
|
PreventionRememberAction::run();
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ class ShowTest extends TestCase
|
||||||
], $response, 'data');
|
], $response, 'data');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function membershipDataProvider(): Generator
|
public static function membershipDataProvider(): Generator
|
||||||
{
|
{
|
||||||
yield [now()->subMonths(2), null, true];
|
yield [now()->subMonths(2), null, true];
|
||||||
yield [now()->subMonths(2), now()->subDay(), false];
|
yield [now()->subMonths(2), now()->subDay(), false];
|
||||||
|
|
|
@ -46,7 +46,7 @@ class IndexTest extends TestCase
|
||||||
->assertJsonPath('meta.links.store', route('member.membership.store', ['member' => $member]));
|
->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), null, true];
|
||||||
yield [now()->subMonths(2), now()->subDay(), false];
|
yield [now()->subMonths(2), now()->subDay(), false];
|
||||||
|
|
|
@ -52,7 +52,7 @@ class ServiceTest extends TestCase
|
||||||
]), 200),
|
]), 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(994, $result->memberId);
|
||||||
$this->assertEquals('test@example.com', $result->email);
|
$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),
|
'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
|
public function testItCanGetLists(): void
|
||||||
|
@ -90,7 +90,7 @@ class ServiceTest extends TestCase
|
||||||
$this->assertEquals('Eltern', $lists[0]->displayName);
|
$this->assertEquals('Eltern', $lists[0]->displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listDataProvider(): Generator
|
public static function listDataProvider(): Generator
|
||||||
{
|
{
|
||||||
foreach (range(3, 40) as $i) {
|
foreach (range(3, 40) as $i) {
|
||||||
yield [
|
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());
|
$this->assertCount($totals->count(), $result->toArray());
|
||||||
Http::assertSentCount($totals->chunk(10)->count());
|
Http::assertSentCount($totals->chunk(10)->count());
|
||||||
|
|
Loading…
Reference in New Issue