Phalcon\Test\Unit\Logger\Adapter\FileTest::testLoggerAdapterFileNewFormatFormatsDateCorrectly PHP Method

testLoggerAdapterFileNewFormatFormatsDateCorrectly() public method

Tests new format logs correctly
Since: 2012-09-17
Author: Nikos Dimopoulos ([email protected])
    public function testLoggerAdapterFileNewFormatFormatsDateCorrectly()
    {
        $fileName = $this->tester->getNewFileName('log', 'log');
        $logger = new File($this->logPath . $fileName);
        $formatter = new Line('%type%|%date%|%message%');
        $logger->setFormatter($formatter);
        $logger->log('Hello');
        $logger->close();
        $contents = \file($this->logPath . $fileName);
        $message = explode('|', $contents[0]);
        $this->tester->cleanFile($this->logPath, $fileName);
        $date = new \DateTime($message[1]);
        $expected = date('Y-m-d H');
        $actual = $date->format('Y-m-d H');
        $this->assertEquals($expected, $actual, 'Date format not set properly');
    }
FileTest