Ejemplo n.º 1
0
 public function testAddLogPriority()
 {
     $logger = new Logger($this->writer);
     $logger->addPriority('EIGHT', $priority = 8);
     $logger->eight($message = 'eight message');
     rewind($this->log);
     $logdata = stream_get_contents($this->log);
     $this->assertContains((string) $priority, $logdata);
     $this->assertContains($message, $logdata);
 }
Ejemplo n.º 2
0
 /**
  * @group ZF-10170
  */
 public function testPriorityDuplicates()
 {
     $logger = new Logger();
     $mock = new Log\Writer\Mock();
     $logger->addWriter($mock);
     try {
         $logger->addPriority('emerg', 8);
         $this->fail();
     } catch (\Exception $e) {
         $this->assertType('Zend\\Log\\Exception', $e);
         $this->assertEquals('Existing priorities cannot be overwritten', $e->getMessage());
     }
     try {
         $logger->log('zf10170', 0);
         $logger->log('clone zf10170', 8);
         $this->fail();
     } catch (\Exception $e) {
         $this->assertType('Zend\\Log\\Exception', $e);
         $this->assertEquals('Bad log priority', $e->getMessage());
     }
     $this->assertEquals(0, $mock->events[0]['priority']);
     $this->assertEquals('EMERG', $mock->events[0]['priorityName']);
     $this->assertFalse(array_key_exists(1, $mock->events));
 }
Ejemplo n.º 3
0
 /**
  * @group ZF-10170
  */
 public function testExceptionIsThrownOnPriorityDuplicates()
 {
     $logger = new Logger();
     $mock = new Log\Writer\Mock();
     $logger->addWriter($mock);
     $this->setExpectedException('Zend\\Log\\Exception\\InvalidArgumentException', 'Existing priorities cannot be overwritten');
     $logger->addPriority('emerg', 8);
 }