Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T2893 logger date format #14648

Merged
merged 7 commits into from
Dec 23, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[#2893] - Added tests
  • Loading branch information
niden committed Dec 23, 2019
commit 005d755602944204f091d49af1b059905dd337aa
31 changes: 31 additions & 0 deletions tests/unit/Logger/Formatter/Line/FormatCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Phalcon\Test\Unit\Logger\Formatter\Line;

use DateTime;
use Phalcon\Logger;
use Phalcon\Logger\Formatter\Line;
use Phalcon\Logger\Item;
Expand Down Expand Up @@ -83,4 +84,34 @@ public function loggerFormatterLineFormatCustom(UnitTester $I)
$formatter->format($item)
);
}

/**
* Tests Phalcon\Logger\Formatter\Line :: format() -custom with miliseconds
*
* @author Phalcon Team <team@phalcon.io>
* @since 2019-12-23
*/
public function loggerFormatterLineFormatCustomWithMiliseconds(UnitTester $I)
{
$I->wantToTest('Logger\Formatter\Line - format() - custom - with milliseconds');

$formatter = new Line(
'%message%-[%type%]-%date%',
'U.u'
);

$item = new Item(
'log message',
'debug',
Logger::DEBUG,
time()
);

$result = $formatter->format($item);
$parts = explode('-', $result);
$parts = explode('.', $parts[2]);
$I->assertCount(2, $parts);
$I->assertGreaterThan(0, (int) $parts[0]);
$I->assertGreaterThan(0, (int) $parts[1]);
}
}