mirror of
https://github.com/Aviortheking/DeltaCMS.git
synced 2025-04-22 19:02:12 +00:00
Updated Logger tests
This commit is contained in:
parent
5c48243306
commit
783f33381a
@ -2,13 +2,16 @@
|
|||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use AdminPanel\Cache\FileCache;
|
use AdminPanel\Cache\FileCache;
|
||||||
use AdminPanel\Logger\Logger;
|
use AdminPanel\Logger;
|
||||||
|
|
||||||
final class LoggerTest extends TestCase
|
final class LoggerTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testCanLog()
|
public function testCanLog()
|
||||||
{
|
{
|
||||||
$file = "tests/logs.log";
|
$file = "tests/logs.log";
|
||||||
|
if (file_exists($file)) {
|
||||||
|
unlink($file);
|
||||||
|
}
|
||||||
$logger = new Logger($file);
|
$logger = new Logger($file);
|
||||||
$this->assertFileExists($file);
|
$this->assertFileExists($file);
|
||||||
|
|
||||||
@ -17,6 +20,24 @@ final class LoggerTest extends TestCase
|
|||||||
$file,
|
$file,
|
||||||
"[Info]: " . (new \DateTime())->format("Y-m-d H:i:s") . " test\n"
|
"[Info]: " . (new \DateTime())->format("Y-m-d H:i:s") . " test\n"
|
||||||
);
|
);
|
||||||
unlink($file);
|
}
|
||||||
|
|
||||||
|
public function testCanLogExceptions()
|
||||||
|
{
|
||||||
|
$file = "tests/logs.log";
|
||||||
|
if (file_exists($file)) {
|
||||||
|
unlink($file);
|
||||||
|
}
|
||||||
|
$logger = new Logger($file);
|
||||||
|
$this->assertFileExists($file);
|
||||||
|
|
||||||
|
$exception = new Exception("hello phpunit");
|
||||||
|
$logger->alert("test", array(
|
||||||
|
'exception' => $exception
|
||||||
|
));
|
||||||
|
$this->assertStringEqualsFile(
|
||||||
|
$file,
|
||||||
|
"[Alert]: " . (new \DateTime())->format("Y-m-d H:i:s") . " test\n[Alert]: " . (new \DateTime())->format("Y-m-d H:i:s") . " 0 " . $exception->getFile() . "[Exception] 0 " . $exception->getMessage() . "\n"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user