app[Kernel::class]->handle( new ArrayInput(array_merge(['command' => $command], $parameters)), $output ); $this->assertSame(0, $status, $output->fetch()); return $status; } protected function setUp() { parent::setUp(); // Small, explicit fixtures; no dependency on demo data or fixed IDs. $scope = $this->record(Scope::class, ['name' => 'Test scope']); foreach ([1 => 'Einnahme', -1 => 'Ausgabe'] as $factor => $name) { $io = $this->record(IOType::class, compact('name', 'factor')); $class = $this->record(AccountClass::class, [ 'name' => $name, 'number' => $factor > 0 ? 10 : 20, 'scope_id' => $scope->id, 'io_type_id' => $io->id, ]); $account = $this->record(AccountType::class, [ 'name' => $name, 'number' => $factor > 0 ? 100 : 200, 'account_class_id' => $class->id, ]); if ($factor > 0) { $this->incomeAccount = $account; } else { $this->expenseAccount = $account; } } $this->project = $this->record(Project::class, [ 'name' => 'Test project', 'start_date' => '2019-01-01', 'end_date' => '2020-12-31', ]); $this->user = $this->record(User::class, [ 'name' => 'Test user', 'email' => 'test@example.com', 'password' => bcrypt('test-password'), ]); } protected function record($class, array $attributes) { $model = new $class; $model->forceFill($attributes)->save(); return $model; } protected function booking($date, $amount, $account = null, array $attributes = []) { $booking = $this->record(Booking::class, [ 'date' => $date, 'reference' => 'Test booking', 'person_or_company' => 'Test company', ]); $this->record(SubBooking::class, array_merge([ 'booking_id' => $booking->id, 'reference' => 'Test line', 'amount' => $amount, 'account_type_id' => ($account ?: $this->incomeAccount)->id, 'project_id' => $this->project->id, ], $attributes)); return $booking; } protected function target($amount = 100, $account = null) { $person = $this->record(Person::class, ['title' => 'Firma', 'name_or_company' => 'Test company']); return $this->record(PersonTarget::class, [ 'person_id' => $person->id, 'date' => '2020-01-01', 'reference' => 'Test target', 'amount' => $amount, 'io_type_id' => ($account ?: $this->incomeAccount)->accountClass->io_type_id, ]); } }