4 * @covers WikiReference
7 class WikiReferenceTest
extends PHPUnit_Framework_TestCase
{
9 public function provideGetHostname() {
11 'http' => array( 'foo.bar', 'http://foo.bar' ),
12 'https' => array( 'foo.bar', 'https://foo.bar' ),
17 * @dataProvider provideGetHostname
19 public function testGetHostname( $expected, $canonicalServer ) {
20 $this->markTestSkipped( 'The implementation is patently broken.' );
22 $reference = new WikiReference( 'wiki', 'xx', $canonicalServer, '/wiki/$1' );
23 $this->assertEquals( $expected, $reference->getHostname() );
26 public function provideGetDisplayName() {
28 'http' => array( 'foo.bar', 'http://foo.bar' ),
29 'https' => array( 'foo.bar', 'http://foo.bar' ),
31 // apparently, this is the expected behavior
32 'invalid' => array( 'purple kittens/wiki/', 'purple kittens' ),
37 * @dataProvider provideGetDisplayName
39 public function testGetDisplayName( $expected, $canonicalServer ) {
40 $reference = new WikiReference( 'wiki', 'xx', $canonicalServer, '/wiki/$1' );
41 $this->assertEquals( $expected, $reference->getDisplayName() );
44 public function testGetCanonicalServer() {
45 $reference = new WikiReference( 'wiki', 'xx', 'https://acme.com', '/wiki/$1', '//acme.com' );
46 $this->assertEquals( 'https://acme.com', $reference->getCanonicalServer() );
49 public function provideGetCanonicalUrl() {
51 'no fragement' => array( 'https://acme.com/wiki/Foo', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo', null ),
52 'empty fragement' => array( 'https://acme.com/wiki/Foo', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo', '' ),
53 'fragment' => array( 'https://acme.com/wiki/Foo#Bar', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo', 'Bar' ),
54 'double fragment' => array( 'https://acme.com/wiki/Foo#Bar%23Xus', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo', 'Bar#Xus' ),
55 'escaped fragement' => array( 'https://acme.com/wiki/Foo%23Bar', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo#Bar', null ),
56 'empty path' => array( 'https://acme.com/Foo', 'https://acme.com', '//acme.com', '/$1', 'Foo', null ),
61 * @dataProvider provideGetCanonicalUrl
63 public function testGetCanonicalUrl( $expected, $canonicalServer, $server, $path, $page, $fragmentId ) {
64 $reference = new WikiReference( 'wiki', 'xx', $canonicalServer, $path, $server );
65 $this->assertEquals( $expected, $reference->getCanonicalUrl( $page, $fragmentId ) );
69 * @dataProvider provideGetCanonicalUrl
71 public function testGetUrl( $expected, $canonicalServer, $server, $path, $page, $fragmentId ) {
72 $reference = new WikiReference( 'wiki', 'xx', $canonicalServer, $path, $server );
73 $this->assertEquals( $expected, $reference->getUrl( $page, $fragmentId ) );
76 public function provideGetFullUrl() {
78 'no fragement' => array( '//acme.com/wiki/Foo', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo', null ),
79 'empty fragement' => array( '//acme.com/wiki/Foo', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo', '' ),
80 'fragment' => array( '//acme.com/wiki/Foo#Bar', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo', 'Bar' ),
81 'double fragment' => array( '//acme.com/wiki/Foo#Bar%23Xus', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo', 'Bar#Xus' ),
82 'escaped fragement' => array( '//acme.com/wiki/Foo%23Bar', 'https://acme.com', '//acme.com', '/wiki/$1', 'Foo#Bar', null ),
83 'empty path' => array( '//acme.com/Foo', 'https://acme.com', '//acme.com', '/$1', 'Foo', null ),
88 * @dataProvider provideGetFullUrl
90 public function testGetFullUrl( $expected, $canonicalServer, $server, $path, $page, $fragmentId ) {
91 $reference = new WikiReference( 'wiki', 'xx', $canonicalServer, $path, $server );
92 $this->assertEquals( $expected, $reference->getFullUrl( $page, $fragmentId ) );