blob: 5ce43f8dae8791680e0be1d71f1dbbf318c4acf5 (
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
|
<?php
namespace SMW\Tests\Util\Mock;
/**
* @ingroup Test
*
* @group SMW
* @group SMWExtension
*
* @license GNU GPL v2+
* @since 2.0
*
* @author mwjames
*/
class MockTitle extends \PHPUnit_Framework_TestCase {
public static function buildMock( $text = __METHOD__ ) {
$instance = new self();
$contentModel = class_exists( 'ContentHandler' ) ? CONTENT_MODEL_WIKITEXT : null;
$title = $instance->getMockBuilder( 'Title' )
->disableOriginalConstructor()
->getMock();
$title->expects( $instance->any() )
->method( 'getDBkey' )
->will( $instance->returnValue( str_replace( ' ', '_', $text ) ) );
$title->expects( $instance->any() )
->method( 'getContentModel' )
->will( $instance->returnValue( $contentModel ) );
return $title;
}
public static function buildMockForMainNamespace( $text = __METHOD__ ) {
$instance = new self();
$title = $instance->buildMock( $text );
$title->expects( $instance->any() )
->method( 'getNamespace' )
->will( $instance->returnValue( NS_MAIN ) );
$title->expects( $instance->any() )
->method( 'getArticleID' )
->will( $instance->returnValue( 9001 ) );
$title->expects( $instance->any() )
->method( 'isSpecialPage' )
->will( $instance->returnValue( false ) );
return $title;
}
}
|