Tests bad URL handling by ExternalStore::fetchFromURL()
authorAntoine Musso <hashar@users.mediawiki.org>
Sun, 7 Nov 2010 13:07:19 +0000 (13:07 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Sun, 7 Nov 2010 13:07:19 +0000 (13:07 +0000)
Follow up r68900

maintenance/tests/phpunit/includes/ExternalStoreTest.php [new file with mode: 0644]

diff --git a/maintenance/tests/phpunit/includes/ExternalStoreTest.php b/maintenance/tests/phpunit/includes/ExternalStoreTest.php
new file mode 100644 (file)
index 0000000..3c15f69
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+/**
+ * External Store tests
+ */
+
+class ExternalStoreTest extends PHPUnit_Framework_TestCase {
+       private $saved_wgExternalStores;
+
+       function setUp() {
+               global $wgExternalStores;
+               $this->saved_wgExternalStores = $wgExternalStores ;
+       }
+
+       function tearDown() {
+               global $wgExternalStores;
+               $wgExternalStores = $this->saved_wgExternalStores ;
+       }
+
+       function testExternalStoreDoesNotFetchIncorrectURL() {
+               global $wgExternalStores;
+               $wgExternalStores = true;
+
+               # Assertions for r68900
+               $this->assertFalse(
+                       ExternalStore::fetchFromURL( 'http://' ) );
+               $this->assertFalse(
+                       ExternalStore::fetchFromURL( 'ftp.wikimedia.org' ) );
+               $this->assertFalse(
+                       ExternalStore::fetchFromURL( '/super.txt' ) );
+       }
+}
+