gplx/mediawiki/extensions/SemanticMediaWiki/tests/phpunit/Utils/LoggerTest.php

59 lines
1000 B
PHP

<?php
namespace SMW\Tests\Utils;
use SMW\Utils\Logger;
/**
* @covers \SMW\Utils\Logger
* @group semantic-mediawiki
*
* @license GPL-2.0-or-later
* @since 3.0
*
* @author mwjames
*/
class LoggerTest extends \PHPUnit\Framework\TestCase {
private $logger;
protected function setUp(): void {
$this->logger = $this->getMockBuilder( '\Psr\Log\LoggerInterface' )
->disableOriginalConstructor()
->getMock();
}
public function testCanConstruct() {
$this->assertInstanceOf(
Logger::class,
new Logger( $this->logger )
);
}
/**
* @dataProvider logProvider
*/
public function testLog( $role, $message, $context ) {
$this->logger->expects( $this->once() )
->method( 'log' );
$instance = new Logger( $this->logger, $role );
$instance->log( 'Foo', $message, $context );
}
public function logProvider() {
yield [
Logger::ROLE_DEVELOPER,
'Foo',
[ 'Foo' ]
];
yield [
Logger::ROLE_DEVELOPER,
'Foo',
[ 'Foo', [ 'Bar' => 123 ] ]
];
}
}