Exemple #1
0
 public function testClone()
 {
     $job = new Job();
     $job->setTicket('ticket');
     $clone = clone $job;
     $this->assertTrue($job !== $clone);
     $this->assertNotEquals($job->getTicket(), $clone->getTicket());
 }
 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));
 }
 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', [[]]);
 }
 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());
 }
 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);
 }