summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/parser/ParserOutputTest.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-09-04 05:51:59 +0200
committerPierre Schmitz <pierre@archlinux.de>2013-09-04 05:51:59 +0200
commit91e194556c52d2f354344f930419eef2dd6267f0 (patch)
tree0cd12490d3cd3499274017c9b799d0f738d3719e /tests/phpunit/includes/parser/ParserOutputTest.php
parent08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 (diff)
Update to MediaWiki 1.21.2
Diffstat (limited to 'tests/phpunit/includes/parser/ParserOutputTest.php')
-rw-r--r--tests/phpunit/includes/parser/ParserOutputTest.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/phpunit/includes/parser/ParserOutputTest.php b/tests/phpunit/includes/parser/ParserOutputTest.php
new file mode 100644
index 00000000..68f77ab5
--- /dev/null
+++ b/tests/phpunit/includes/parser/ParserOutputTest.php
@@ -0,0 +1,55 @@
+<?php
+
+class ParserOutputTest extends MediaWikiTestCase {
+
+ function dataIsLinkInternal() {
+ return array(
+ // Different domains
+ array( false, 'http://example.org', 'http://mediawiki.org' ),
+ // Same domains
+ array( true, 'http://example.org', 'http://example.org' ),
+ array( true, 'https://example.org', 'https://example.org' ),
+ array( true, '//example.org', '//example.org' ),
+ // Same domain different cases
+ array( true, 'http://example.org', 'http://EXAMPLE.ORG' ),
+ // Paths, queries, and fragments are not relevant
+ array( true, 'http://example.org', 'http://example.org/wiki/Main_Page' ),
+ array( true, 'http://example.org', 'http://example.org?my=query' ),
+ array( true, 'http://example.org', 'http://example.org#its-a-fragment' ),
+ // Different protocols
+ array( false, 'http://example.org', 'https://example.org' ),
+ array( false, 'https://example.org', 'http://example.org' ),
+ // Protocol relative servers always match http and https links
+ array( true, '//example.org', 'http://example.org' ),
+ array( true, '//example.org', 'https://example.org' ),
+ // But they don't match strange things like this
+ array( false, '//example.org', 'irc://example.org' ),
+ );
+ }
+
+ /**
+ * Test to make sure ParserOutput::isLinkInternal behaves properly
+ * @dataProvider dataIsLinkInternal
+ */
+ function testIsLinkInternal( $shouldMatch, $server, $url ) {
+
+ $this->assertEquals( $shouldMatch, ParserOutput::isLinkInternal( $server, $url ) );
+ }
+
+ public function testExtensionData() {
+ $po = new ParserOutput();
+
+ $po->setExtensionData( "one", "Foo" );
+
+ $this->assertEquals( "Foo", $po->getExtensionData( "one" ) );
+ $this->assertNull( $po->getExtensionData( "spam" ) );
+
+ $po->setExtensionData( "two", "Bar" );
+ $this->assertEquals( "Foo", $po->getExtensionData( "one" ) );
+ $this->assertEquals( "Bar", $po->getExtensionData( "two" ) );
+
+ $po->setExtensionData( "one", null );
+ $this->assertNull( $po->getExtensionData( "one" ) );
+ $this->assertEquals( "Bar", $po->getExtensionData( "two" ) );
+ }
+}