10 public static function suite( $className ) {
13 $suite =
new PHPUnit_Framework_TestSuite;
14 $suite->setName( $className );
17 $className,
'Cannot run TitleLibrary tests when $wgInterwikiCache is set'
23 return parent::suite( $className );
33 $wgHooks[
'InterwikiLoadPrefix'][] =
function ( $prefix, &$data ) {
34 if ( $prefix !==
'interwikiprefix' ) {
39 'iw_prefix' =>
'interwikiprefix',
40 'iw_url' =>
'//test.wikipedia.org/wiki/$1',
53 '{{int:mainpage}}<includeonly>...</includeonly><noinclude>...</noinclude>'
57 $testPageId = $page->getId();
74 $title->mRestrictionsLoaded =
true;
75 $title->mRestrictions = [
'edit' => [],
'move' => [] ];
76 $title->mCascadeSources = [
80 $title->mCascadingRestrictions = [
'edit' => [
'sysop' ] ];
82 $title->mRestrictionsLoaded =
true;
84 'edit' => [
'sysop',
'bogus' ],
85 'move' => [
'sysop',
'bogus' ],
87 $title->mCascadeSources = [];
88 $title->mCascadingRestrictions = [];
90 $title->mRestrictionsLoaded =
true;
91 $title->mRestrictions = [];
92 $title->mCascadeSources = [];
93 $title->mCascadingRestrictions = [];
95 $title->mRestrictionsLoaded =
true;
96 $title->mRestrictions = [
'create' => [
'sysop' ] ];
97 $title->mCascadeSources = [];
98 $title->mCascadingRestrictions = [];
100 $title->mRestrictionsLoaded =
true;
101 $title->mRestrictions = [
'edit' => [
'autoconfirmed' ],
'move' => [
'sysop' ] ];
102 $title->mCascadeSources = [];
103 $title->mCascadingRestrictions = [];
105 $title->mRestrictionsLoaded =
true;
106 $title->mRestrictions = [
'edit' => [],
'move' => [
'sysop' ] ];
107 $title->mCascadeSources = [];
108 $title->mCascadingRestrictions = [];
111 $this->
getEngine()->getParser()->getOptions()->setExpensiveParserFunctionLimit( 10 );
114 $interpreter = $this->
getEngine()->getInterpreter();
115 $interpreter->callFunction(
116 $interpreter->loadString(
"mw.title.testPageId = $testPageId",
'fortest' )
119 $this->setMwGlobals( [
120 'wgServer' =>
'//wiki.local',
121 'wgCanonicalServer' =>
'http://wiki.local',
122 'wgUsePathInfo' =>
true,
123 'wgActionPaths' => [],
124 'wgScript' =>
'/w/index.php',
125 'wgScriptPath' =>
'/w',
126 'wgArticlePath' =>
'/wiki/$1',
137 return parent::getTestModules() + [
138 'TitleLibraryTests' => __DIR__ .
'/TitleLibraryTests.lua',
144 $interpreter =
$engine->getInterpreter();
147 $links =
$engine->getParser()->getOutput()->getLinks();
148 $this->assertFalse( isset( $links[
NS_PROJECT][
'Referenced_from_Lua'] ) );
150 $interpreter->callFunction( $interpreter->loadString(
151 'local _ = mw.title.new( "Project:Referenced from Lua" ).id',
'reference title'
154 $links =
$engine->getParser()->getOutput()->getLinks();
155 $this->assertArrayHasKey(
NS_PROJECT, $links );
156 $this->assertArrayHasKey(
'Referenced_from_Lua', $links[
NS_PROJECT] );
159 $templates =
$engine->getParser()->getOutput()->getTemplates();
160 $this->assertFalse( isset( $links[
NS_PROJECT][
'Loaded_from_Lua'] ) );
162 $interpreter->callFunction( $interpreter->loadString(
163 'mw.title.new( "Project:Loaded from Lua" ):getContent()',
'load title'
166 $templates =
$engine->getParser()->getOutput()->getTemplates();
167 $this->assertArrayHasKey(
NS_PROJECT, $templates );
168 $this->assertArrayHasKey(
'Loaded_from_Lua', $templates[
NS_PROJECT] );