Fixed tests

This commit is contained in:
philipp lang 2021-11-11 23:46:56 +01:00
parent 5a83b5a8b4
commit 574825843e
2 changed files with 20 additions and 4 deletions

View File

@ -6,6 +6,15 @@ class InitializeActivities {
private $bar;
private $api;
private array $tries = [
'Schnuppermitgliedschaft',
];
private array $members = [
'€ Mitglied',
'Schnuppermitgliedschaft',
];
public function __construct($bar, $api) {
$this->bar = $bar;
@ -15,11 +24,20 @@ class InitializeActivities {
public function handle() {
$this->bar->task('Synchronisiere Tätigkeiten', function() {
$this->api->group(auth()->user()->getNamiGroupId())->activities()->each(function($activity) {
$activity = \App\Activity::create(['nami_id' => $activity->id, 'name' => $activity->name]);
$activity = \App\Activity::create([
'nami_id' => $activity->id,
'name' => $activity->name,
'is_try' => in_array($group->name, $this->tries),
'is_member' => in_array($group->name, $this->members),
]);
$groups = [];
$this->api->subactivitiesOf($activity->id)->each(function($group) use ($activity, &$groups) {
$group = \App\Subactivity::updateOrCreate(['nami_id' => $group->id], ['nami_id' => $group->id, 'name' => $group->name]);
$group = \App\Subactivity::updateOrCreate(['nami_id' => $group->id], [
'nami_id' => $group->id,
'name' => $group->name,
]);
$groups[] = $group->id;
});
$activity->subactivities()->sync($groups);

View File

@ -20,8 +20,6 @@ class CreateActivitiesIsMemberColumn extends Migration
Schema::table('activities', function (Blueprint $table) {
$table->boolean('is_try')->default(false);
});
Activity::firstWhere('name', 'Schnuppermitgliedschaft')->update(['is_try' => true]);
Activity::whereIn('name', ['€ Mitglied', 'Schnuppermitgliedschaft'])->update(['is_member' => true]);
}
/**