MediaWiki
REL1_21
|
00001 <?php 00002 00032 class MediaWikiSiteTest extends SiteTest { 00033 00034 public function testNormalizePageTitle() { 00035 $site = new MediaWikiSite(); 00036 $site->setGlobalId( 'enwiki' ); 00037 00038 //NOTE: this does not actually call out to the enwiki site to perform the normalization, 00039 // but uses a local Title object to do so. This is hardcoded on SiteLink::normalizePageTitle 00040 // for the case that MW_PHPUNIT_TEST is set. 00041 $this->assertEquals( 'Foo', $site->normalizePageName( ' foo ' ) ); 00042 } 00043 00044 public function fileUrlProvider() { 00045 return array( 00046 // url, filepath, path arg, expected 00047 array( 'https://en.wikipedia.org', '/w/$1', 'api.php', 'https://en.wikipedia.org/w/api.php' ), 00048 array( 'https://en.wikipedia.org', '/w/', 'api.php', 'https://en.wikipedia.org/w/' ), 00049 array( 'https://en.wikipedia.org', '/foo/page.php?name=$1', 'api.php', 'https://en.wikipedia.org/foo/page.php?name=api.php' ), 00050 array( 'https://en.wikipedia.org', '/w/$1', '', 'https://en.wikipedia.org/w/' ), 00051 array( 'https://en.wikipedia.org', '/w/$1', 'foo/bar/api.php', 'https://en.wikipedia.org/w/foo/bar/api.php' ), 00052 ); 00053 } 00054 00058 public function testGetFileUrl( $url, $filePath, $pathArgument, $expected ) { 00059 $site = new MediaWikiSite(); 00060 $site->setFilePath( $url . $filePath ); 00061 00062 $this->assertEquals( $expected, $site->getFileUrl( $pathArgument ) ); 00063 } 00064 00065 public function provideGetPageUrl() { 00066 return array( 00067 // path, page, expected substring 00068 array( 'http://acme.test/wiki/$1', 'Berlin', '/wiki/Berlin' ), 00069 array( 'http://acme.test/wiki/', 'Berlin', '/wiki/' ), 00070 array( 'http://acme.test/w/index.php?title=$1', 'Berlin', '/w/index.php?title=Berlin' ), 00071 array( 'http://acme.test/wiki/$1', '', '/wiki/' ), 00072 array( 'http://acme.test/wiki/$1', 'Berlin/sub page', '/wiki/Berlin/sub_page' ), 00073 array( 'http://acme.test/wiki/$1', 'Cork (city) ', '/Cork_(city)' ), 00074 array( 'http://acme.test/wiki/$1', 'M&M', '/wiki/M%26M' ), 00075 ); 00076 } 00077 00081 public function testGetPageUrl( $path, $page, $expected ) { 00082 $site = new MediaWikiSite(); 00083 $site->setLinkPath( $path ); 00084 00085 $this->assertContains( $path, $site->getPageUrl() ); 00086 $this->assertContains( $expected, $site->getPageUrl( $page ) ); 00087 } 00088 00089 }