Exemplo n.º 1
0
 public function testLogINFORESETMessage()
 {
     $this->_logSrv->write_log('info', 'Yun ji info');
     $expectedFilePath = 'output/login/login.' . date('Y-m-d') . '.log';
     $this->assertTrue(file_exists($expectedFilePath));
     $contents = $this->_get_log_json_array($expectedFilePath);
     $this->assertNotNull($contents);
     // Test the row just inserted.
     $lastRow = sizeof($contents) - 1;
     $this->assertEquals(15, strlen($contents[$lastRow]->logid));
     $logid = $contents[$lastRow]->logid;
     $timestamp = $contents[$lastRow]->timestamp;
     sleep(1);
     $this->_logSrv->write_log('info', 'Yun ji info');
     $expectedFilePath = 'output/login/login.' . date('Y-m-d') . '.log';
     $this->assertTrue(file_exists($expectedFilePath));
     $contents = $this->_get_log_json_array($expectedFilePath);
     $this->assertNotNull($contents);
     // Test the row just inserted.
     $lastRow = sizeof($contents) - 1;
     $this->assertEquals($logid, $contents[$lastRow]->logid);
     $this->assertEquals($timestamp, $contents[$lastRow]->timestamp);
     sleep(1);
     $this->_logSrv->init_notice(true);
     $this->_logSrv->write_log('info', 'Yun ji info');
     $expectedFilePath = 'output/login/login.' . date('Y-m-d') . '.log';
     $this->assertTrue(file_exists($expectedFilePath));
     $contents = $this->_get_log_json_array($expectedFilePath);
     $this->assertNotNull($contents);
     // Test the row just inserted.
     $lastRow = sizeof($contents) - 1;
     $this->assertEquals($logid, $contents[$lastRow]->logid);
     $this->assertFalse($timestamp === $contents[$lastRow]->timestamp);
     sleep(1);
     LIB_Log::genLogID(true);
     $this->_logSrv->init_notice(true);
     $this->_logSrv->write_log('info', 'Yun ji info');
     $expectedFilePath = 'output/login/login.' . date('Y-m-d') . '.log';
     $this->assertTrue(file_exists($expectedFilePath));
     $contents = $this->_get_log_json_array($expectedFilePath);
     $this->assertNotNull($contents);
     // Test the row just inserted.
     $lastRow = sizeof($contents) - 1;
     $this->assertFalse($logid === $contents[$lastRow]->logid);
     $this->assertFalse($timestamp === $contents[$lastRow]->timestamp);
 }
Exemplo n.º 2
0
 public function setUp()
 {
     date_default_timezone_set(self::DEFAULT_TIME_ZONE);
     $this->_logSrv = new LIB_Log();
     $this->_logid = LIB_Log::genLogID();
 }