Add some tests for wfExpandUrl. Definitely not complete (needs some for protocol...
authorChad Horohoe <demon@users.mediawiki.org>
Wed, 13 Jul 2011 01:54:40 +0000 (01:54 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Wed, 13 Jul 2011 01:54:40 +0000 (01:54 +0000)
tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php [new file with mode: 0644]

diff --git a/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php b/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php
new file mode 100644 (file)
index 0000000..a59fcc0
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+/* 
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+class wfExpandUrl extends MediaWikiTestCase {
+       /** @dataProvider provideExpandableUrls */
+       public function testWfExpandUrl( $fullUrl, $shortUrl, $message ) {
+               $this->assertEquals( $fullUrl, wfExpandUrl( $shortUrl ), $message );
+       }
+
+       /**
+        * Provider of URL examples for testing wfExpandUrl()
+        */
+       public function provideExpandableUrls() {
+               global $wgServer;
+               return array(
+                       array( "$wgServer/wiki/FooBar", '/wiki/FooBar', 'Testing expanding URL beginning with /' ),
+                       array( 'http://example.com', 'http://example.com', 'Testing fully qualified http URLs (no need to expand)' ),
+                       array( 'https://example.com', 'https://example.com', 'Testing fully qualified https URLs (no need to expand)' ),
+                       # Would be nice to support this, see fixme on wfExpandUrl()
+                       array( "wiki/FooBar", 'wiki/FooBar', "Test non-expandable relative URLs" ),
+               );
+       }
+}