36 $site->setGlobalId(
'enwiki' );
41 $this->assertEquals(
'Foo', $site->normalizePageName(
' foo ' ) );
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' ),
59 public function testGetFileUrl( $url, $filePath, $pathArgument, $expected ) {
61 $site->setFilePath( $url . $filePath );
63 $this->assertEquals( $expected, $site->getFileUrl( $pathArgument ) );
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' ),
85 $site->setLinkPath(
$path );
87 $this->assertContains(
$path, $site->getPageUrl() );
88 $this->assertContains( $expected, $site->getPageUrl( $page ) );