Пример #1
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->command('inspire')->hourly();
     $schedule->call(function () {
         \App\Model\ActionQueue\ActionCommandScheduled::run();
     })->daily();
 }
 public function test_suspend_company_with_command_on_expiration_date()
 {
     $expirationDate = new Carbon('2017-06-30');
     $company = factory(Company::class)->create();
     $user = factory(User::class, 'admin')->create();
     $this->actingAs($user)->visit('/company/' . $company->id . '/edit')->see($company->name)->see('name="licence_expire_at"')->type($expirationDate->toDateString(), 'licence_expire_at')->press('Save Edit')->seeInDatabase('companies', ['id' => $company->id, 'licence_expire_at' => $expirationDate->toDateString(), 'is_suspended' => false])->seeInDatabase('schedules', ['who_object' => Company::class, 'who_id' => $company->id, 'run_at' => $expirationDate->toDateString(), 'action' => ActionCommandSuspendCompanyCommand::class]);
     // enter to testing time - set date to be expiration date
     Carbon::setTestNow($expirationDate);
     $company = Company::findOrFail($company->id);
     $this->assertEquals(false, $company->is_suspended);
     $results = \App\Model\ActionQueue\ActionCommandScheduled::run();
     $company = Company::findOrFail($company->id);
     $this->assertEquals(true, $company->is_suspended);
     // exit from testing time - reset current time
     Carbon::setTestNow();
 }
Пример #3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->comment(PHP_EOL . ActionCommandScheduled::run() . PHP_EOL);
 }