diff options
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Maintenance/MaintenanceLoggerTest.php')
-rw-r--r-- | www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Maintenance/MaintenanceLoggerTest.php | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Maintenance/MaintenanceLoggerTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Maintenance/MaintenanceLoggerTest.php new file mode 100644 index 00000000..89c89c74 --- /dev/null +++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Maintenance/MaintenanceLoggerTest.php @@ -0,0 +1,67 @@ +<?php + +namespace SMW\Tests\Maintenance; + +use SMW\Maintenance\MaintenanceLogger; +use SMW\Tests\PHPUnitCompat; + +/** + * @covers \SMW\Maintenance\MaintenanceLogger + * @group semantic-mediawiki + * + * @license GNU GPL v2+ + * @since 2.4 + * + * @author mwjames + */ +class MaintenanceLoggerTest extends \PHPUnit_Framework_TestCase { + + use PHPUnitCompat; + + public function testCanConstruct() { + + $manualEntryLogger = $this->getMockBuilder( '\SMW\MediaWiki\ManualEntryLogger' ) + ->disableOriginalConstructor() + ->getMock(); + + $this->assertInstanceOf( + '\SMW\Maintenance\MaintenanceLogger', + new MaintenanceLogger( 'Foo', $manualEntryLogger ) + ); + } + + public function testLog() { + + $manualEntryLogger = $this->getMockBuilder( '\SMW\MediaWiki\ManualEntryLogger' ) + ->disableOriginalConstructor() + ->getMock(); + + $manualEntryLogger->expects( $this->once() ) + ->method( 'log' ) + ->with( + $this->stringContains( 'maintenance' ), + $this->equalTo( 'Foo' ), + $this->equalTo( 'Foo' ), + $this->stringContains( 'bar' ) ); + + $instance = new MaintenanceLogger( 'Foo', $manualEntryLogger ); + $instance->log( 'bar' ); + } + + public function testLogWithInvalidNameLengthThrowsException() { + + $manualEntryLogger = $this->getMockBuilder( '\SMW\MediaWiki\ManualEntryLogger' ) + ->disableOriginalConstructor() + ->getMock(); + + $manualEntryLogger->expects( $this->never() ) + ->method( 'log' ); + + $instance = new MaintenanceLogger( 'Foo', $manualEntryLogger ); + $instance->setMaxNameChars( 2 ); + + $this->setExpectedException( 'RuntimeException' ); + $instance->log( 'bar' ); + } + +} |