4 * @covers WikiReference
7 class WikiReferenceTest
extends PHPUnit_Framework_TestCase
{
9 public function provideGetDisplayName() {
11 'http' => array( 'foo.bar', 'http://foo.bar' ),
12 'https' => array( 'foo.bar', 'http://foo.bar' ),
14 // apparently, this is the expected behavior
15 'invalid' => array( 'purple kittens', 'purple kittens' ),
20 * @dataProvider provideGetDisplayName
22 public function testGetDisplayName( $expected, $canonicalServer ) {
23 $reference = new WikiReference( $canonicalServer, '/wiki/$1' );
24 $this->assertEquals( $expected, $reference->getDisplayName() );
27 public function testGetCanonicalServer() {
28 $reference = new WikiReference( 'https://acme.com', '/wiki/$1', '//acme.com' );
29 $this->assertEquals( 'https://acme.com', $reference->getCanonicalServer() );
32 public function provideGetCanonicalUrl() {
34 'no fragment' => array(
35 'https://acme.com/wiki/Foo',
42 'empty fragment' => array(
43 'https://acme.com/wiki/Foo',
51 'https://acme.com/wiki/Foo#Bar',
58 'double fragment' => array(
59 'https://acme.com/wiki/Foo#Bar%23Xus',
66 'escaped fragment' => array(
67 'https://acme.com/wiki/Foo%23Bar',
74 'empty path' => array(
75 'https://acme.com/Foo',
86 * @dataProvider provideGetCanonicalUrl
88 public function testGetCanonicalUrl( $expected, $canonicalServer, $server, $path, $page, $fragmentId ) {
89 $reference = new WikiReference( $canonicalServer, $path, $server );
90 $this->assertEquals( $expected, $reference->getCanonicalUrl( $page, $fragmentId ) );
94 * @dataProvider provideGetCanonicalUrl
95 * @note getUrl is an alias for getCanonicalUrl
97 public function testGetUrl( $expected, $canonicalServer, $server, $path, $page, $fragmentId ) {
98 $reference = new WikiReference( $canonicalServer, $path, $server );
99 $this->assertEquals( $expected, $reference->getUrl( $page, $fragmentId ) );
102 public function provideGetFullUrl() {
104 'no fragment' => array(
105 '//acme.com/wiki/Foo',
112 'empty fragment' => array(
113 '//acme.com/wiki/Foo',
121 '//acme.com/wiki/Foo#Bar',
128 'double fragment' => array(
129 '//acme.com/wiki/Foo#Bar%23Xus',
136 'escaped fragment' => array(
137 '//acme.com/wiki/Foo%23Bar',
144 'empty path' => array(
156 * @dataProvider provideGetFullUrl
158 public function testGetFullUrl( $expected, $canonicalServer, $server, $path, $page, $fragmentId ) {
159 $reference = new WikiReference( $canonicalServer, $path, $server );
160 $this->assertEquals( $expected, $reference->getFullUrl( $page, $fragmentId ) );