예제 #1
0
 public function testSimpleModel()
 {
     if (!$this->doConsole()) {
         return;
     }
     //create data
     ob_start();
     $status = \Artisan::call('db:seed', ['--class' => 'OptimisationDemoSeeder', '--force' => true]);
     ob_end_clean();
     $this->assertEquals(0, $status);
     //get company
     $company = \plunner\Company::all()->last();
     //optimise
     $status = \Artisan::call('optimise:meetings', ['companyId' => $company->id]);
     $this->assertEquals(0, $status);
     //check if the meetings are correctly optimised looking the users number that attend to them
     $meetingShort = \plunner\Meeting::whereIn('group_id', $company->groups->pluck('id'))->where('duration', config('app.timeslots.duration'))->firstOrfail();
     $meetingLong = \plunner\Meeting::whereIn('group_id', $company->groups->pluck('id'))->where('duration', config('app.timeslots.duration') * 3)->firstOrfail();
     $this->assertEquals(1, $meetingShort->employees->count());
     $this->assertEquals(2, $meetingLong->employees->count());
 }
예제 #2
0
 private function syncAll()
 {
     //TODO if are there no companies?
     $companies = Company::all();
     if ($this->option('background')) {
         \Log::debug(self::BACKGROUND_MOD_MEX);
         $this->info(self::BACKGROUND_MOD_MEX);
         foreach ($companies as $company) {
             $this->makeBackground($company);
         }
         \Log::debug(self::BACKGROUND_COMPLETED_MEX);
         $this->info(self::BACKGROUND_COMPLETED_MEX);
     } else {
         foreach ($companies as $company) {
             $this->makeForeground($company);
         }
     }
 }