blob: af5503a5549cfb81dd4d2696f1feb6a722d2e205 (
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
<?php
namespace SMW\Tests\Page;
use SMW\Page\PageFactory;
use SMW\Tests\PHPUnitCompat;
/**
* @covers \SMW\Page\PageFactory
* @group semantic-mediawiki
*
* @license GNU GPL v2+
* @since 3.0
*
* @author mwjames
*/
class PageFactoryTest extends \PHPUnit_Framework_TestCase {
use PHPUnitCompat;
private $store;
protected function setUp() {
parent::setUp();
$this->store = $this->getMockBuilder( '\SMW\Store' )
->disableOriginalConstructor()
->getMockForAbstractClass();
}
public function testCanConstruct() {
$this->assertInstanceOf(
PageFactory::class,
new PageFactory( $this->store )
);
}
public function testNewPageFromNotRegisteredNamespaceThrowsException() {
$title = $this->getMockBuilder( '\Title' )
->disableOriginalConstructor()
->getMock();
$title->expects( $this->atLeastOnce() )
->method( 'getNamespace' )
->will( $this->returnValue( NS_MAIN ) );
$instance = new PageFactory( $this->store );
$this->setExpectedException( 'RuntimeException' );
$instance->newPageFromTitle( $title );
}
/**
* @dataProvider namespaceProvider
*/
public function testNewPageFromTitle( $namespace, $expected ) {
$title = $this->getMockBuilder( '\Title' )
->disableOriginalConstructor()
->getMock();
$title->expects( $this->atLeastOnce() )
->method( 'getNamespace' )
->will( $this->returnValue( $namespace ) );
$instance = new PageFactory( $this->store );
$this->assertInstanceOf(
$expected,
$instance->newPageFromTitle( $title )
);
}
public function namespaceProvider() {
$provider[] = [
SMW_NS_PROPERTY,
'SMW\Page\PropertyPage'
];
$provider[] = [
SMW_NS_CONCEPT,
'SMW\Page\ConceptPage'
];
return $provider;
}
}
|