Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function save(LogInterface $log, $andFlush = true)
 {
     if (!$log instanceof $this->class) {
         throw new InvalidArgumentException('1st argument must be an instanceof ' . $this->getClass());
     }
     $extra = $log->getExtra();
     if (is_array($extra) && isset($extra['job_ticket'])) {
         /** @var \Abc\Bundle\JobBundle\Entity\Log $log */
         $log->setJobTicket($extra['job_ticket']);
         unset($extra['job_ticket']);
         $log->setExtra($extra);
     }
     parent::save($log, $andFlush);
 }
Пример #2
0
 public function testCRUD()
 {
     $log = $this->subject->create();
     $log->setChannel('Channel');
     $log->setLevel(200);
     $log->setLevelName('info');
     $log->setMessage('Message');
     $log->setDatetime(new \DateTime());
     $log->setContext(['context' => 'Context']);
     $log->setExtra(['extra' => 'Extra']);
     $this->subject->save($log);
     $this->getEntityManager()->clear();
     /** @var Log[] $logs */
     $logs = $this->subject->findAll();
     /** @var Log $log */
     $log = $logs[0];
     $this->assertCount(1, $logs);
     $this->assertEquals($log, $logs[0]);
     $this->subject->delete($log);
     $this->getEntityManager()->clear();
     $this->assertEmpty($this->subject->findAll());
 }
Пример #3
0
 public function testFindByChannel()
 {
     $channel = 'Channel';
     $this->repository->expects($this->once())->method('findBy')->with(['channel' => $channel]);
     $this->subject->findByChannel($channel);
 }