Skip to content
Snippets Groups Projects
Commit 916bcf1d authored by dyszczo's avatar dyszczo
Browse files

logger factory tests

parent e36a4dd9
No related branches found
No related tags found
2 merge requests!3Devel,!2Feature/tests
<?php
use Monolog\Logger;
use WPDesk\Logger\BasicLoggerFactory;
class TestBasicLoggerFactory extends WP_UnitTestCase {
const LOGGER_NAME = 'test-channel';
public function testCanCreateLogger() {
$factory = new BasicLoggerFactory();
$logger = $factory->createLogger(self::LOGGER_NAME);
$this->assertInstanceOf(Logger::class, $logger, "Logger should be created");
}
public function testCanReturnLoggerFromRegistry() {
$factory = new BasicLoggerFactory();
$logger1 = $factory->createLogger(self::LOGGER_NAME);
$logger2 = $factory->createLogger(self::LOGGER_NAME);
$logger3 = $factory->getLogger();
$this->assertSame($logger1, $logger2, "Should return the same loggers");
$this->assertSame($logger2, $logger3, "Should return the same loggers");
$otherLogger = $factory->createLogger('other-name');
$this->assertNotSame($logger1, $otherLogger, "Should return different loggers");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment