Exemplo n.º 1
0
 public function testSetPriority()
 {
     $msg = 'msg de test debug without define priority, by default all';
     $expected = '/^\\w+ \\d+ \\d+:\\d+:\\d+ \\[DEBUG\\] ' . $msg . '$/';
     $this->object->debug($msg);
     $file = file(self::$_filename);
     $this->assertRegExp($expected, $file[count($file) - 1]);
     $this->object->setPriority(Phigrate_Logger::ERROR);
     $msg = 'msg de test warn with priority err';
     $expected = '/^\\w+ \\d+ \\d+:\\d+:\\d+ \\[WARN\\] ' . $msg . '$/';
     $this->object->warn($msg);
     $file = file(self::$_filename);
     $this->assertNotRegExp($expected, $file[count($file) - 1]);
     $this->object->setPriority(Phigrate_Logger::WARNING);
     $msg = 'msg de test err with priority warn';
     $expected = '/^\\w+ \\d+ \\d+:\\d+:\\d+ \\[ERR\\] ' . $msg . '$/';
     $this->object->err($msg);
     $file = file(self::$_filename);
     $this->assertRegExp($expected, $file[count($file) - 1]);
     $msg = 'msg de test warn with priority warn';
     $expected = '/^\\w+ \\d+ \\d+:\\d+:\\d+ \\[WARN\\] ' . $msg . '$/';
     $this->object->warn($msg);
     $file = file(self::$_filename);
     $this->assertRegExp($expected, $file[count($file) - 1]);
     $msg = 'msg de test info with priority warn';
     $expected = '/^\\w+ \\d+ \\d+:\\d+:\\d+ \\[INFO\\] ' . $msg . '$/';
     $this->object->info($msg);
     $file = file(self::$_filename);
     $this->assertNotRegExp($expected, $file[count($file) - 1]);
     $this->object->setPriority(Phigrate_Logger::INFO);
     $msg = 'msg de test err with priority info';
     $expected = '/^\\w+ \\d+ \\d+:\\d+:\\d+ \\[ERR\\] ' . $msg . '$/';
     $this->object->err($msg);
     $file = file(self::$_filename);
     $this->assertRegExp($expected, $file[count($file) - 1]);
     $msg = 'msg de test warn with priority info';
     $expected = '/^\\w+ \\d+ \\d+:\\d+:\\d+ \\[WARN\\] ' . $msg . '$/';
     $this->object->warn($msg);
     $file = file(self::$_filename);
     $this->assertRegExp($expected, $file[count($file) - 1]);
     $msg = 'msg de test info with priority info';
     $expected = '/^\\w+ \\d+ \\d+:\\d+:\\d+ \\[INFO\\] ' . $msg . '$/';
     $this->object->info($msg);
     $file = file(self::$_filename);
     $this->assertRegExp($expected, $file[count($file) - 1]);
     $msg = 'msg de test debug with priority info';
     $expected = '/^\\w+ \\d+ \\d+:\\d+:\\d+ \\[DEBUG\\] ' . $msg . '$/';
     $this->object->debug($msg);
     $file = file(self::$_filename);
     $this->assertNotRegExp($expected, $file[count($file) - 1]);
     $this->object->setPriority(Phigrate_Logger::DEBUG);
     $msg = 'msg de test err with priority debug';
     $expected = '/^\\w+ \\d+ \\d+:\\d+:\\d+ \\[ERR\\] ' . $msg . '$/';
     $this->object->err($msg);
     $file = file(self::$_filename);
     $this->assertRegExp($expected, $file[count($file) - 1]);
     $msg = 'msg de test warn with priority debug';
     $expected = '/^\\w+ \\d+ \\d+:\\d+:\\d+ \\[WARN\\] ' . $msg . '$/';
     $this->object->warn($msg);
     $file = file(self::$_filename);
     $this->assertRegExp($expected, $file[count($file) - 1]);
     $msg = 'msg de test info with priority debug';
     $expected = '/^\\w+ \\d+ \\d+:\\d+:\\d+ \\[INFO\\] ' . $msg . '$/';
     $this->object->info($msg);
     $file = file(self::$_filename);
     $this->assertRegExp($expected, $file[count($file) - 1]);
     $msg = 'msg de test debug with priority debug';
     $expected = '/^\\w+ \\d+ \\d+:\\d+:\\d+ \\[DEBUG\\] ' . $msg . '$/';
     $this->object->debug($msg);
     $file = file(self::$_filename);
     $this->assertRegExp($expected, $file[count($file) - 1]);
     $this->object->setPriority(Phigrate_Logger::DEBUG);
 }