4 * @covers WikiReference
6 class WikiReferenceTest
extends MediaWikiIntegrationTestCase
{
8 public function provideGetDisplayName() {
10 'http' => [ 'foo.bar', 'http://foo.bar' ],
11 'https' => [ 'foo.bar', 'http://foo.bar' ],
13 // apparently, this is the expected behavior
14 'invalid' => [ 'purple kittens', 'purple kittens' ],
19 * @dataProvider provideGetDisplayName
21 public function testGetDisplayName( $expected, $canonicalServer ) {
22 $reference = new WikiReference( $canonicalServer, '/wiki/$1' );
23 $this->assertEquals( $expected, $reference->getDisplayName() );
26 public function testGetCanonicalServer() {
27 $reference = new WikiReference( 'https://acme.com', '/wiki/$1', '//acme.com' );
28 $this->assertEquals( 'https://acme.com', $reference->getCanonicalServer() );
31 public function provideGetCanonicalUrl() {
34 'https://acme.com/wiki/Foo',
42 'https://acme.com/wiki/Foo',
50 'https://acme.com/wiki/Foo#Bar',
57 'double fragment' => [
58 'https://acme.com/wiki/Foo#Bar%23Xus',
65 'escaped fragment' => [
66 'https://acme.com/wiki/Foo%23Bar',
74 'https://acme.com/Foo',
85 * @dataProvider provideGetCanonicalUrl
87 public function testGetCanonicalUrl(
88 $expected, $canonicalServer, $server, $path, $page, $fragmentId
90 $reference = new WikiReference( $canonicalServer, $path, $server );
91 $this->assertEquals( $expected, $reference->getCanonicalUrl( $page, $fragmentId ) );
95 * @dataProvider provideGetCanonicalUrl
96 * @note getUrl is an alias for getCanonicalUrl
98 public function testGetUrl( $expected, $canonicalServer, $server, $path, $page, $fragmentId ) {
99 $reference = new WikiReference( $canonicalServer, $path, $server );
100 $this->assertEquals( $expected, $reference->getUrl( $page, $fragmentId ) );
103 public function provideGetFullUrl() {
106 '//acme.com/wiki/Foo',
113 'empty fragment' => [
114 '//acme.com/wiki/Foo',
122 '//acme.com/wiki/Foo#Bar',
129 'double fragment' => [
130 '//acme.com/wiki/Foo#Bar%23Xus',
137 'escaped fragment' => [
138 '//acme.com/wiki/Foo%23Bar',
157 * @dataProvider provideGetFullUrl
159 public function testGetFullUrl( $expected, $canonicalServer, $server, $path, $page, $fragmentId ) {
160 $reference = new WikiReference( $canonicalServer, $path, $server );
161 $this->assertEquals( $expected, $reference->getFullUrl( $page, $fragmentId ) );