r95074 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95073‎ | r95074 | r95075 >
Date:10:41, 20 August 2011
Author:catrope
Status:ok
Tags:
Comment:
Followup r95072: add tests for wfMatchesDomainList
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/GlobalFunctions/GlobalTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/GlobalFunctions/GlobalTest.php
@@ -877,6 +877,33 @@
878878 // are less consistent.
879879 );
880880 }
 881+
 882+ /**
 883+ * @dataProvider provideWfMatchesDomainList
 884+ */
 885+ function testWfMatchesDomainList( $url, $domains, $expected, $description ) {
 886+ $actual = wfMatchesDomainList( $url, $domains );
 887+ $this->assertEquals( $expected, $actual, $description );
 888+ }
 889+
 890+ function provideWfMatchesDomainList() {
 891+ $a = array();
 892+ $protocols = array( 'HTTP' => 'http:', 'HTTPS' => 'https:', 'protocol-relative' => '' );
 893+ foreach ( $protocols as $pDesc => $p ) {
 894+ $a = array_merge( $a, array(
 895+ array( "$p//www.example.com", array(), false, "No matches for empty domains array, $pDesc URL" ),
 896+ array( "$p//www.example.com", array( 'www.example.com' ), true, "Exact match in domains array, $pDesc URL" ),
 897+ array( "$p//www.example.com", array( 'example.com' ), true, "Match without subdomain in domains array, $pDesc URL" ),
 898+ array( "$p//www.example2.com", array( 'www.example.com', 'www.example2.com', 'www.example3.com' ), true, "Exact match with other domains in array, $pDesc URL" ),
 899+ array( "$p//www.example2.com", array( 'example.com', 'example2.com', 'example3,com' ), true, "Match without subdomain with other domains in array, $pDesc URL" ),
 900+ array( "$p//www.example4.com", array( 'example.com', 'example2.com', 'example3,com' ), false, "Domain not in array, $pDesc URL" ),
 901+
 902+ // FIXME: This is a bug in wfMatchesDomainList(). If and when this is fixed, update this test case
 903+ array( "$p//nds-nl.wikipedia.org", array( 'nl.wikipedia.org' ), true, "Substrings of domains match while they shouldn't, $pDesc URL" ),
 904+ ) );
 905+ }
 906+ return $a;
 907+ }
881908
882909 /* TODO: many more! */
883910 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r95072Per r90849, factor out most of the code that's duplicated between Parser::get...catrope10:18, 20 August 2011

Status & tagging log