X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FWikiReferenceTest.php;h=724dd6056a154a5b7ea9cac55b458dd2517a940c;hb=a3209e467b14adbbebdaaf5a9c513824bdd4beaf;hp=1d907ebfe3b01f8ec7f93daf98250c534b667eb3;hpb=8e655d8dd34c9b5b7857532753b4f1faa7d8571d;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/WikiReferenceTest.php b/tests/phpunit/includes/WikiReferenceTest.php index 1d907ebfe3..724dd6056a 100644 --- a/tests/phpunit/includes/WikiReferenceTest.php +++ b/tests/phpunit/includes/WikiReferenceTest.php @@ -7,13 +7,13 @@ class WikiReferenceTest extends PHPUnit_Framework_TestCase { public function provideGetDisplayName() { - return array( - 'http' => array( 'foo.bar', 'http://foo.bar' ), - 'https' => array( 'foo.bar', 'http://foo.bar' ), + return [ + 'http' => [ 'foo.bar', 'http://foo.bar' ], + 'https' => [ 'foo.bar', 'http://foo.bar' ], // apparently, this is the expected behavior - 'invalid' => array( 'purple kittens', 'purple kittens' ), - ); + 'invalid' => [ 'purple kittens', 'purple kittens' ], + ]; } /** @@ -30,20 +30,64 @@ class WikiReferenceTest extends PHPUnit_Framework_TestCase { } public function provideGetCanonicalUrl() { - return array( - 'no fragement' => array( 'https://acme.com/wiki/Foo', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo', null ), - 'empty fragement' => array( 'https://acme.com/wiki/Foo', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo', '' ), - 'fragment' => array( 'https://acme.com/wiki/Foo#Bar', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo', 'Bar' ), - 'double fragment' => array( 'https://acme.com/wiki/Foo#Bar%23Xus', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo', 'Bar#Xus' ), - 'escaped fragement' => array( 'https://acme.com/wiki/Foo%23Bar', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo#Bar', null ), - 'empty path' => array( 'https://acme.com/Foo', 'https://acme.com', '//acme.com', '/$1', 'Foo', null ), - ); + return [ + 'no fragment' => [ + 'https://acme.com/wiki/Foo', + 'https://acme.com', + '//acme.com', + '/wiki/$1', + 'Foo', + null + ], + 'empty fragment' => [ + 'https://acme.com/wiki/Foo', + 'https://acme.com', + '//acme.com', + '/wiki/$1', + 'Foo', + '' + ], + 'fragment' => [ + 'https://acme.com/wiki/Foo#Bar', + 'https://acme.com', + '//acme.com', + '/wiki/$1', + 'Foo', + 'Bar' + ], + 'double fragment' => [ + 'https://acme.com/wiki/Foo#Bar%23Xus', + 'https://acme.com', + '//acme.com', + '/wiki/$1', + 'Foo', + 'Bar#Xus' + ], + 'escaped fragment' => [ + 'https://acme.com/wiki/Foo%23Bar', + 'https://acme.com', + '//acme.com', + '/wiki/$1', + 'Foo#Bar', + null + ], + 'empty path' => [ + 'https://acme.com/Foo', + 'https://acme.com', + '//acme.com', + '/$1', + 'Foo', + null + ], + ]; } /** * @dataProvider provideGetCanonicalUrl */ - public function testGetCanonicalUrl( $expected, $canonicalServer, $server, $path, $page, $fragmentId ) { + public function testGetCanonicalUrl( + $expected, $canonicalServer, $server, $path, $page, $fragmentId + ) { $reference = new WikiReference( $canonicalServer, $path, $server ); $this->assertEquals( $expected, $reference->getCanonicalUrl( $page, $fragmentId ) ); } @@ -58,14 +102,56 @@ class WikiReferenceTest extends PHPUnit_Framework_TestCase { } public function provideGetFullUrl() { - return array( - 'no fragement' => array( '//acme.com/wiki/Foo', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo', null ), - 'empty fragement' => array( '//acme.com/wiki/Foo', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo', '' ), - 'fragment' => array( '//acme.com/wiki/Foo#Bar', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo', 'Bar' ), - 'double fragment' => array( '//acme.com/wiki/Foo#Bar%23Xus', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo', 'Bar#Xus' ), - 'escaped fragement' => array( '//acme.com/wiki/Foo%23Bar', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo#Bar', null ), - 'empty path' => array( '//acme.com/Foo', 'https://acme.com', '//acme.com', '/$1', 'Foo', null ), - ); + return [ + 'no fragment' => [ + '//acme.com/wiki/Foo', + 'https://acme.com', + '//acme.com', + '/wiki/$1', + 'Foo', + null + ], + 'empty fragment' => [ + '//acme.com/wiki/Foo', + 'https://acme.com', + '//acme.com', + '/wiki/$1', + 'Foo', + '' + ], + 'fragment' => [ + '//acme.com/wiki/Foo#Bar', + 'https://acme.com', + '//acme.com', + '/wiki/$1', + 'Foo', + 'Bar' + ], + 'double fragment' => [ + '//acme.com/wiki/Foo#Bar%23Xus', + 'https://acme.com', + '//acme.com', + '/wiki/$1', + 'Foo', + 'Bar#Xus' + ], + 'escaped fragment' => [ + '//acme.com/wiki/Foo%23Bar', + 'https://acme.com', + '//acme.com', + '/wiki/$1', + 'Foo#Bar', + null + ], + 'empty path' => [ + '//acme.com/Foo', + 'https://acme.com', + '//acme.com', + '/$1', + 'Foo', + null + ], + ]; } /**