/**
  * @return void
  * @covers ::run
  */
 public function testRunExecuteJob()
 {
     $table = $this->getModel('\\DelayedJobs\\Model\\Table\\DelayedJobsTable', ['get'], 'DelayedJobs', 'delayed_jobs');
     TableRegistry::set('DelayedJobs.DelayedJobs', $table);
     $job_data = Fabricate::attributes_for('DelayedJobs.DelayedJobs')[0];
     $job = $this->getMock('\\DelayedJobs\\Model\\Entity\\DelayedJob', ['execute'], [$job_data]);
     $job_output = 'Test completed';
     $table->expects($this->once())->method('get')->willReturn($job);
     $job->expects($this->once())->method('execute')->willReturn($job_output);
     $this->get('/delayed_jobs/run/' . $job->id);
     $this->assertSession('Job Completed: ' . $job_output, 'Flash.flash.message');
     $this->assertResponseSuccess();
     $this->assertRedirect(['action' => 'index']);
 }
Exemplo n.º 2
0
 protected function _buildJobMock()
 {
     $job_data = Fabricate::attributes_for('DelayedJobs.DelayedJobs', 1, function () {
         return ['status' => DelayedJobsTable::STATUS_BUSY];
     })[0];
     $job = $this->getMock('\\DelayedJobs\\Model\\Entity\\DelayedJob', ['execute'], [$job_data]);
     $this->Shell->DelayedJobs = $this->getMockForModel('DelayedJobs.DelayedJobs', ['failed', 'completed', 'get'], ['table' => 'delayed_jobs']);
     $this->Shell->Lock->expects($this->once())->method('lock')->with('DelayedJobs.WorkerShell.main.1')->willReturn(true);
     $this->Shell->DelayedJobs->expects($this->once())->method('get')->with($job->id)->willReturn($job);
     return $job;
 }
Exemplo n.º 3
0
 public function testContextHasFakerFactory()
 {
     $results = Fabricate::attributes_for('User', function ($data, $world) {
         return ['user' => $world->faker()->name];
     });
     $this->assertNotEmpty($results[0]['user']);
 }