blob: b76cc65fe415440f489b5f4e9e54ce23212fb8dd (
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
|
<?php
namespace SMW\Tests\Integration\MediaWiki;
use MWNamespace;
use SMW\NamespaceManager;
use SMW\Settings;
use SMW\Tests\Utils\MwHooksHandler;
/**
* @group semantic-mediawiki
*
* @license GNU GPL v2+
* @since 1.9
*
* @author mwjames
*/
class MWNamespaceCanonicalNameMatchTest extends \PHPUnit_Framework_TestCase {
private $mwHooksHandler;
protected function setUp() {
parent::setUp();
$this->mwHooksHandler = new MwHooksHandler();
}
public function tearDown() {
$this->mwHooksHandler->restoreListedHooks();
parent::tearDown();
}
public function testRunNamespaceManagerWithNoConstantsDefined() {
$this->mwHooksHandler->deregisterListedHooks();
$default = [
'smwgNamespacesWithSemanticLinks' => [],
'wgNamespacesWithSubpages' => [],
'wgExtraNamespaces' => [],
'wgNamespaceAliases' => [],
'wgContentNamespaces' => [],
'wgNamespacesToBeSearchedDefault' => [],
'wgLanguageCode' => 'en'
];
$instance = $this->getMockBuilder( '\SMW\NamespaceManager' )
->setMethods( [ 'isDefinedConstant' ] )
->getMock();
$instance->expects( $this->atLeastOnce() )
->method( 'isDefinedConstant' )
->will( $this->returnValue( false ) );
$instance->init( $default );
}
public function testCanonicalNames() {
$this->mwHooksHandler->deregisterListedHooks();
$count = 0;
$index = NamespaceManager::buildNamespaceIndex( Settings::newFromGlobals()->get( 'smwgNamespaceIndex' ) );
$names = NamespaceManager::getCanonicalNames();
$this->assertInternalType( 'array', $names );
$this->assertInternalType( 'array', $index );
foreach ( $index as $ns => $idx ) {
$mwNamespace = MWNamespace::getCanonicalName( $idx );
if ( $mwNamespace && isset( $names[$idx] ) ) {
$this->assertEquals( $mwNamespace, $names[$idx] );
$count++;
}
}
$this->assertCount(
$count,
$names,
"Asserts that expected amount of cannonical names have been verified"
);
}
}
|