summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Maintenance/ExceptionFileLoggerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Maintenance/ExceptionFileLoggerTest.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Maintenance/ExceptionFileLoggerTest.php76
1 files changed, 76 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Maintenance/ExceptionFileLoggerTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Maintenance/ExceptionFileLoggerTest.php
new file mode 100644
index 00000000..b64a75af
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Maintenance/ExceptionFileLoggerTest.php
@@ -0,0 +1,76 @@
+<?php
+
+namespace SMW\Tests\Maintenance\Jobs;
+
+use SMW\Maintenance\ExceptionFileLogger;
+use SMW\Options;
+
+/**
+ * @covers \SMW\Maintenance\ExceptionFileLogger
+ * @group semantic-mediawiki
+ *
+ * @license GNU GPL v2+
+ * @since 2.4
+ *
+ * @author mwjames
+ */
+class ExceptionFileLoggerTest extends \PHPUnit_Framework_TestCase {
+
+ private $file;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $this->file = $this->getMockBuilder( '\SMW\Utils\File' )
+ ->disableOriginalConstructor()
+ ->getMock();
+ }
+
+ public function testCanConstruct() {
+
+ $this->assertInstanceOf(
+ ExceptionFileLogger::class,
+ new ExceptionFileLogger()
+ );
+ }
+
+ public function testGetter() {
+
+ $instance = new ExceptionFileLogger();
+
+ $instance->setOptions( new Options( [
+ 'exception-log' => __DIR__
+ ] ) );
+
+ $this->assertInternalType(
+ 'boolean',
+ $instance->getExceptionFile()
+ );
+
+ $this->assertInternalType(
+ 'integer',
+ $instance->getExceptionCount()
+ );
+ }
+
+ public function testDoWriteExceptionLog() {
+
+ $this->file->expects( $this->once() )
+ ->method( 'write' );
+
+ $instance = new ExceptionFileLogger( 'foo', $this->file );
+
+ $instance->recordException(
+ 'Foo',
+ new \Exception( 'Bar' )
+ );
+
+ $this->assertEquals(
+ 1,
+ $instance->getExceptionCount()
+ );
+
+ $instance->doWrite();
+ }
+
+}