コード例 #1
0
 /**
  * @param int     $level
  * @param boolean $bubble
  * @dataProvider provideLevels
  */
 public function testCreateHandler($level, $bubble)
 {
     $job = new Job();
     $job->setTicket('JobTicket');
     $handler = $this->subject->createHandler($job, $level, $bubble);
     $this->assertInstanceOf(StreamHandler::class, $handler);
 }
コード例 #2
0
ファイル: JobTest.php プロジェクト: aboutcoders/job-bundle
 public function testClone()
 {
     $job = new Job();
     $job->setTicket('ticket');
     $clone = clone $job;
     $this->assertTrue($job !== $clone);
     $this->assertNotEquals($job->getTicket(), $clone->getTicket());
 }
コード例 #3
0
 public function testDeleteByJob()
 {
     $job = new Job();
     $job->setTicket('Ticket');
     $log_A = $this->buildLog('ChannelA', 'LevelA', 'MessageA');
     $this->subject = $this->getMockForAbstractClass(LogManager::class, [], '', null, null, null, ['delete']);
     $this->subject->expects($this->once())->method('findBy')->with(['jobTicket' => $job->getTicket()])->willReturn([$log_A]);
     $this->subject->expects($this->once())->method('delete')->with($log_A);
     $this->assertEquals(1, $this->subject->deleteByJob($job));
 }
コード例 #4
0
 public function testWrite()
 {
     $log = new Log();
     $job = new Job();
     $job->setTicket('JobTicket');
     $record = [];
     $record['extra']['job_ticket'] = $job->getTicket();
     $this->manager->expects($this->once())->method('create')->willReturn($log);
     $this->subject->expects($this->once())->method('populateLog')->with($log, $record);
     $this->manager->expects($this->once())->method('save')->with($log);
     $this->subject->setJob($job);
     $this->invokeMethod($this->subject, 'write', [[]]);
 }
コード例 #5
0
 /**
  * @return Job
  */
 public static function createJob($ticket = null, $type = null, $status = null, $processingTime = null, $parameters = null, array $schedules = array())
 {
     $job = new Job();
     $job->setTicket($ticket);
     $job->setType($type);
     $job->setParameters($parameters);
     $job->setProcessingTime($processingTime);
     foreach ($schedules as $schedule) {
         $job->addSchedule($schedule);
     }
     if ($status != null) {
         $job->setStatus($status);
     }
     return $job;
 }
コード例 #6
0
 public function testOnSchedule()
 {
     $job = new Job();
     $job->setType('type');
     $job->setTicket('ticket');
     $schedule = new Schedule();
     $schedule->setJob($job);
     $event = new SchedulerEvent($schedule);
     $self = $this;
     $this->producer->expects($this->once())->method('produce')->willReturnCallback(function (Message $message) use($self) {
         $this->assertEquals('ticket', $message->getTicket());
         $this->assertEquals('type', $message->getType());
     });
     $this->subject->onSchedule($event);
 }
コード例 #7
0
 public function testDeleteLogWithNonExistingFile()
 {
     $job = new Job();
     $job->setTicket('job-ticket');
     $job->setType('job-type');
     $this->subject->deleteByJob($job);
 }
コード例 #8
0
 public function testRestartAction()
 {
     $job = new Job();
     $job->setTicket('12345');
     $client = static::createClient();
     $this->mockServices(['abc.job.manager' => $this->manager]);
     $this->manager->expects($this->once())->method('restart')->willThrowException(new TicketNotFoundException($job->getTicket()));
     $client->request('POST', '/api/jobs/12345/restart');
     $this->assertEquals(404, $client->getResponse()->getStatusCode());
 }
コード例 #9
0
 public function testUpdate()
 {
     $job = new Job();
     $job->setTicket('JobTicket');
     $existingJob = new Job();
     $this->jobManager->expects($this->once())->method('findByTicket')->with($job->getTicket())->willReturn($existingJob);
     $this->helper->expects($this->once())->method('copyJob')->with($job, $existingJob)->willReturn($existingJob);
     $this->jobManager->expects($this->once())->method('save')->with($existingJob);
     $this->loggerFactory->expects($this->once())->method('create')->with($existingJob)->willReturn(new NullLogger());
     $this->subject->update($job);
 }