blob: 89c89c74950fffbd698977a81e3a2e19c5f7f880 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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' );
}
}
|