MediaWiki  1.23.13
MediaWikiSiteTest.php
Go to the documentation of this file.
1 <?php
2 
32 class MediaWikiSiteTest extends SiteTest {
33 
34  public function testNormalizePageTitle() {
35  $site = new MediaWikiSite();
36  $site->setGlobalId( 'enwiki' );
37 
38  //NOTE: this does not actually call out to the enwiki site to perform the normalization,
39  // but uses a local Title object to do so. This is hardcoded on SiteLink::normalizePageTitle
40  // for the case that MW_PHPUNIT_TEST is set.
41  $this->assertEquals( 'Foo', $site->normalizePageName( ' foo ' ) );
42  }
43 
44  public function fileUrlProvider() {
45  return array(
46  // url, filepath, path arg, expected
47  array( 'https://en.wikipedia.org', '/w/$1', 'api.php', 'https://en.wikipedia.org/w/api.php' ),
48  array( 'https://en.wikipedia.org', '/w/', 'api.php', 'https://en.wikipedia.org/w/' ),
49  array( 'https://en.wikipedia.org', '/foo/page.php?name=$1', 'api.php', 'https://en.wikipedia.org/foo/page.php?name=api.php' ),
50  array( 'https://en.wikipedia.org', '/w/$1', '', 'https://en.wikipedia.org/w/' ),
51  array( 'https://en.wikipedia.org', '/w/$1', 'foo/bar/api.php', 'https://en.wikipedia.org/w/foo/bar/api.php' ),
52  );
53  }
54 
59  public function testGetFileUrl( $url, $filePath, $pathArgument, $expected ) {
60  $site = new MediaWikiSite();
61  $site->setFilePath( $url . $filePath );
62 
63  $this->assertEquals( $expected, $site->getFileUrl( $pathArgument ) );
64  }
65 
66  public static function provideGetPageUrl() {
67  return array(
68  // path, page, expected substring
69  array( 'http://acme.test/wiki/$1', 'Berlin', '/wiki/Berlin' ),
70  array( 'http://acme.test/wiki/', 'Berlin', '/wiki/' ),
71  array( 'http://acme.test/w/index.php?title=$1', 'Berlin', '/w/index.php?title=Berlin' ),
72  array( 'http://acme.test/wiki/$1', '', '/wiki/' ),
73  array( 'http://acme.test/wiki/$1', 'Berlin/sub page', '/wiki/Berlin/sub_page' ),
74  array( 'http://acme.test/wiki/$1', 'Cork (city) ', '/Cork_(city)' ),
75  array( 'http://acme.test/wiki/$1', 'M&M', '/wiki/M%26M' ),
76  );
77  }
78 
83  public function testGetPageUrl( $path, $page, $expected ) {
84  $site = new MediaWikiSite();
85  $site->setLinkPath( $path );
86 
87  $this->assertContains( $path, $site->getPageUrl() );
88  $this->assertContains( $expected, $site->getPageUrl( $page ) );
89  }
90 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
MediaWikiSiteTest
Definition: MediaWikiSiteTest.php:32
MediaWikiSiteTest\testGetPageUrl
testGetPageUrl( $path, $page, $expected)
@dataProvider provideGetPageUrl @covers MediaWikiSite::getPageUrl
Definition: MediaWikiSiteTest.php:83
MediaWikiSiteTest\provideGetPageUrl
static provideGetPageUrl()
Definition: MediaWikiSiteTest.php:66
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
MediaWikiSiteTest\testGetFileUrl
testGetFileUrl( $url, $filePath, $pathArgument, $expected)
@dataProvider fileUrlProvider @covers MediaWikiSite::getFileUrl
Definition: MediaWikiSiteTest.php:59
MediaWikiSiteTest\fileUrlProvider
fileUrlProvider()
Definition: MediaWikiSiteTest.php:44
MediaWikiSiteTest\testNormalizePageTitle
testNormalizePageTitle()
Definition: MediaWikiSiteTest.php:34
SiteTest
Definition: SiteTest.php:32
$path
$path
Definition: NoLocalSettings.php:35
MediaWikiSite
Class representing a MediaWiki site.
Definition: MediaWikiSite.php:35