public function testExpandIRI() {
$this->assertEquals(
"https://te.wikibooks.org/wiki/ఉబుంటు_వాడుకరి_మార్గదర్శని",
- wfExpandIRI( "https://te.wikibooks.org/wiki/%E0%B0%89%E0%B0%AC%E0%B1%81%E0%B0%82%E0%B0%9F%E0%B1%81_%E0%B0%B5%E0%B0%BE%E0%B0%A1%E0%B1%81%E0%B0%95%E0%B0%B0%E0%B0%BF_%E0%B0%AE%E0%B0%BE%E0%B0%B0%E0%B1%8D%E0%B0%97%E0%B0%A6%E0%B0%B0%E0%B1%8D%E0%B0%B6%E0%B0%A8%E0%B0%BF" ) );
+ wfExpandIRI( "https://te.wikibooks.org/wiki/"
+ . "%E0%B0%89%E0%B0%AC%E0%B1%81%E0%B0%82%E0%B0%9F%E0%B1%81_"
+ . "%E0%B0%B5%E0%B0%BE%E0%B0%A1%E0%B1%81%E0%B0%95%E0%B0%B0%E0%B0%BF_"
+ . "%E0%B0%AE%E0%B0%BE%E0%B0%B0%E0%B1%8D%E0%B0%97%E0%B0%A6%E0%B0%B0"
+ . "%E0%B1%8D%E0%B0%B6%E0%B0%A8%E0%B0%BF" ) );
}
/**
array( array( 'foo' => false ), '' ), // false test
array( array( 'foo' => null ), '' ), // null test
array( array( 'foo' => 'A&B=5+6@!"\'' ), 'foo=A%26B%3D5%2B6%40%21%22%27' ), // urlencoding test
- array( array( 'foo' => 'bar', 'baz' => 'is', 'asdf' => 'qwerty' ), 'foo=bar&baz=is&asdf=qwerty' ), // multi-item test
+ array(
+ array( 'foo' => 'bar', 'baz' => 'is', 'asdf' => 'qwerty' ),
+ 'foo=bar&baz=is&asdf=qwerty'
+ ), // multi-item test
array( array( 'foo' => array( 'bar' => 'baz' ) ), 'foo%5Bbar%5D=baz' ),
- array( array( 'foo' => array( 'bar' => 'baz', 'qwerty' => 'asdf' ) ), 'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf' ),
+ array(
+ array( 'foo' => array( 'bar' => 'baz', 'qwerty' => 'asdf' ) ),
+ 'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf'
+ ),
array( array( 'foo' => array( 'bar', 'baz' ) ), 'foo%5B0%5D=bar&foo%5B1%5D=baz' ),
- array( array( 'foo' => array( 'bar' => array( 'bar' => 'baz' ) ) ), 'foo%5Bbar%5D%5Bbar%5D=baz' ),
+ array(
+ array( 'foo' => array( 'bar' => array( 'bar' => 'baz' ) ) ),
+ 'foo%5Bbar%5D%5Bbar%5D=baz'
+ ),
);
}
array( 'foo=bar&qwerty=asdf', array( 'foo' => 'bar', 'qwerty' => 'asdf' ) ), // multiple value
array( 'foo=A%26B%3D5%2B6%40%21%22%27', array( 'foo' => 'A&B=5+6@!"\'' ) ), // urldecoding test
array( 'foo%5Bbar%5D=baz', array( 'foo' => array( 'bar' => 'baz' ) ) ),
- array( 'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf', array( 'foo' => array( 'bar' => 'baz', 'qwerty' => 'asdf' ) ) ),
+ array(
+ 'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf',
+ array( 'foo' => array( 'bar' => 'baz', 'qwerty' => 'asdf' ) )
+ ),
array( 'foo%5B0%5D=bar&foo%5B1%5D=baz', array( 'foo' => array( 0 => 'bar', 1 => 'baz' ) ) ),
- array( 'foo%5Bbar%5D%5Bbar%5D=baz', array( 'foo' => array( 'bar' => array( 'bar' => 'baz' ) ) ) ),
+ array(
+ 'foo%5Bbar%5D%5Bbar%5D=baz',
+ array( 'foo' => array( 'bar' => array( 'bar' => 'baz' ) ) )
+ ),
);
}
unlink( $wgDebugLogFile );
wfDebug( "\00305This has böth UTF and control chars\003" );
- $this->assertEquals( " 05This has böth UTF and control chars ", file_get_contents( $wgDebugLogFile ) );
+ $this->assertEquals(
+ " 05This has böth UTF and control chars ",
+ file_get_contents( $wgDebugLogFile )
+ );
unlink( $wgDebugLogFile );
wfDebugMem();
- $this->assertGreaterThan( 1000, preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) ) );
+ $this->assertGreaterThan(
+ 1000,
+ preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) )
+ );
unlink( $wgDebugLogFile );
wfDebugMem( true );
- $this->assertGreaterThan( 1000000, preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) ) );
+ $this->assertGreaterThan(
+ 1000000,
+ preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) )
+ );
unlink( $wgDebugLogFile );
$wgDebugLogFile = $old_log_file;
$protocols = array( 'HTTP' => 'http:', 'HTTPS' => 'https:', 'protocol-relative' => '' );
foreach ( $protocols as $pDesc => $p ) {
$a = array_merge( $a, array(
- array( "$p//www.example.com", array(), false, "No matches for empty domains array, $pDesc URL" ),
- array( "$p//www.example.com", array( 'www.example.com' ), true, "Exact match in domains array, $pDesc URL" ),
- array( "$p//www.example.com", array( 'example.com' ), true, "Match without subdomain in domains array, $pDesc URL" ),
- 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" ),
- array( "$p//www.example2.com", array( 'example.com', 'example2.com', 'example3,com' ), true, "Match without subdomain with other domains in array, $pDesc URL" ),
- array( "$p//www.example4.com", array( 'example.com', 'example2.com', 'example3,com' ), false, "Domain not in array, $pDesc URL" ),
- array( "$p//nds-nl.wikipedia.org", array( 'nl.wikipedia.org' ), false, "Non-matching substring of domain, $pDesc URL" ),
+ array(
+ "$p//www.example.com",
+ array(),
+ false,
+ "No matches for empty domains array, $pDesc URL"
+ ),
+ array(
+ "$p//www.example.com",
+ array( 'www.example.com' ),
+ true,
+ "Exact match in domains array, $pDesc URL"
+ ),
+ array(
+ "$p//www.example.com",
+ array( 'example.com' ),
+ true,
+ "Match without subdomain in domains array, $pDesc URL"
+ ),
+ 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"
+ ),
+ array(
+ "$p//www.example2.com",
+ array( 'example.com', 'example2.com', 'example3,com' ),
+ true,
+ "Match without subdomain with other domains in array, $pDesc URL"
+ ),
+ array(
+ "$p//www.example4.com",
+ array( 'example.com', 'example2.com', 'example3,com' ),
+ false,
+ "Domain not in array, $pDesc URL"
+ ),
+ array(
+ "$p//nds-nl.wikipedia.org",
+ array( 'nl.wikipedia.org' ),
+ false,
+ "Non-matching substring of domain, $pDesc URL"
+ ),
) );
}
* @dataProvider provideWfShellMaintenanceCmdList
* @covers ::wfShellMaintenanceCmd
*/
- public function testWfShellMaintenanceCmd( $script, $parameters, $options, $expected, $description ) {
+ public function testWfShellMaintenanceCmd( $script, $parameters, $options,
+ $expected, $description
+ ) {
if ( wfIsWindows() ) {
// Approximation that's good enough for our purposes just now
$expected = str_replace( "'", '"', $expected );
array( 'eval.php', array( '--help', '--test', 'X' ), array( 'wrapper' => 'MWScript.php' ),
"'$wgPhpCli' 'MWScript.php' 'eval.php' '--help' '--test' 'X'",
"Called eval.php --help --test with wrapper option" ),
- array( 'eval.php', array( '--help', '--test', 'y' ), array( 'php' => 'php5', 'wrapper' => 'MWScript.php' ),
+ array(
+ 'eval.php',
+ array( '--help', '--test', 'y' ),
+ array( 'php' => 'php5', 'wrapper' => 'MWScript.php' ),
"'php5' 'MWScript.php' 'eval.php' '--help' '--test' 'y'",
- "Called eval.php --help --test with wrapper and php option" ),
+ "Called eval.php --help --test with wrapper and php option"
+ ),
);
}
/* @TODO many more! */
public function testPadding() {
$number = "10101010101";
- $this->assertSame( strlen( $number ) + 5, strlen( wfBaseConvert( $number, 2, 2, strlen( $number ) + 5 ) ) );
- $this->assertSame( strlen( $number ), strlen( wfBaseConvert( $number, 2, 2, strlen( $number ) - 5 ) ) );
+ $this->assertSame(
+ strlen( $number ) + 5,
+ strlen( wfBaseConvert( $number, 2, 2, strlen( $number ) + 5 ) )
+ );
+ $this->assertSame(
+ strlen( $number ),
+ strlen( wfBaseConvert( $number, 2, 2, strlen( $number ) - 5 ) )
+ );
}
}
array( '/aaaa/', 'aaaa' ),
array( '\\aaaa\\', 'aaaa' ),
array( '\\aaaa\\', 'aaaa' ),
- array( '/mnt/upload3/wikipedia/en/thumb/8/8b/Zork_Grand_Inquisitor_box_cover.jpg/93px-Zork_Grand_Inquisitor_box_cover.jpg',
- '93px-Zork_Grand_Inquisitor_box_cover.jpg' ),
+ array(
+ '/mnt/upload3/wikipedia/en/thumb/8/8b/'
+ . 'Zork_Grand_Inquisitor_box_cover.jpg/93px-Zork_Grand_Inquisitor_box_cover.jpg',
+ '93px-Zork_Grand_Inquisitor_box_cover.jpg'
+ ),
array( 'C:\\Progra~1\\Wikime~1\\Wikipe~1\\VIEWER.EXE', 'VIEWER.EXE' ),
array( 'Östergötland_coat_of_arms.png', 'Östergötland_coat_of_arms.png' ),
);
/**
* @dataProvider provideExpandableUrls
*/
- public function testWfExpandUrl( $fullUrl, $shortUrl, $defaultProto, $server, $canServer, $httpsMode, $message ) {
+ public function testWfExpandUrl( $fullUrl, $shortUrl, $defaultProto,
+ $server, $canServer, $httpsMode, $message
+ ) {
// Fake $wgServer, $wgCanonicalServer and $wgRequest->getProtocol()
$this->setMwGlobals( array(
'wgServer' => $server,
$retval[] = array(
'http://example.com', 'http://example.com',
$defaultProto, $server, $canServer, $httpsMode,
- "Testing fully qualified http URLs (no need to expand) ' .
- '(defaultProto: $protoDesc , wgServer: $server, wgCanonicalServer: $canServer, current request protocol: $mode )"
+ "Testing fully qualified http URLs (no need to expand) "
+ . "(defaultProto: $protoDesc , wgServer: $server, "
+ . "wgCanonicalServer: $canServer, current request protocol: $mode )"
);
$retval[] = array(
'https://example.com', 'https://example.com',
$defaultProto, $server, $canServer, $httpsMode,
- "Testing fully qualified https URLs (no need to expand) ' .
- '(defaultProto: $protoDesc , wgServer: $server, wgCanonicalServer: $canServer, current request protocol: $mode )"
+ "Testing fully qualified https URLs (no need to expand) "
+ . "(defaultProto: $protoDesc , wgServer: $server, "
+ . "wgCanonicalServer: $canServer, current request protocol: $mode )"
);
# Would be nice to support this, see fixme on wfExpandUrl()
$retval[] = array(
"wiki/FooBar", 'wiki/FooBar',
$defaultProto, $server, $canServer, $httpsMode,
- "Test non-expandable relative URLs ' .
- '(defaultProto: $protoDesc , wgServer: $server, wgCanonicalServer: $canServer, current request protocol: $mode )"
+ "Test non-expandable relative URLs (defaultProto: $protoDesc, "
+ . "wgServer: $server, wgCanonicalServer: $canServer, "
+ . "current request protocol: $mode )"
);
// Determine expected protocol
$retval[] = array(
"$p//wikipedia.org", '//wikipedia.org',
$defaultProto, $server, $canServer, $httpsMode,
- "Test protocol-relative URL ' .
- '(defaultProto: $protoDesc, wgServer: $server, wgCanonicalServer: $canServer, current request protocol: $mode )"
+ "Test protocol-relative URL (defaultProto: $protoDesc, "
+ . "wgServer: $server, wgCanonicalServer: $canServer, "
+ . "current request protocol: $mode )"
);
$retval[] = array(
- "$srv/wiki/FooBar", '/wiki/FooBar',
- $defaultProto, $server, $canServer, $httpsMode,
- "Testing expanding URL beginning with / ' .
- '(defaultProto: $protoDesc , wgServer: $server, wgCanonicalServer: $canServer, current request protocol: $mode )"
+ "$srv/wiki/FooBar",
+ '/wiki/FooBar',
+ $defaultProto,
+ $server,
+ $canServer,
+ $httpsMode,
+ "Testing expanding URL beginning with / (defaultProto: $protoDesc, "
+ . "wgServer: $server, wgCanonicalServer: $canServer, "
+ . "current request protocol: $mode )"
);
}
}
* @covers ::wfGetCaller
*/
class WfGetCallerTest extends MediaWikiTestCase {
-
public function testZero() {
$this->assertEquals( __METHOD__, wfGetCaller( 1 ) );
}
public function testN() {
$this->assertEquals( 'WfGetCallerTest::testN', self::intermediateFunction( 2, 0 ) );
- $this->assertEquals( 'WfGetCallerTest::intermediateFunction', self::intermediateFunction( 1, 0 ) );
+ $this->assertEquals(
+ 'WfGetCallerTest::intermediateFunction',
+ self::intermediateFunction( 1, 0 )
+ );
for ( $i = 0; $i < 10; $i++ ) {
- $this->assertEquals( 'WfGetCallerTest::intermediateFunction', self::intermediateFunction( $i + 1, $i ) );
+ $this->assertEquals(
+ 'WfGetCallerTest::intermediateFunction',
+ self::intermediateFunction( $i + 1, $i )
+ );
}
}
}
array( '2001-01-15 12:34:56', TS_MW, '20010115123456', 'TS_DB to TS_MW' ),
array( '2001-01-15 12:34:56', TS_UNIX, 979562096, 'TS_DB to TS_UNIX' ),
array( '2001-01-15 12:34:56', TS_DB, '2001-01-15 12:34:56', 'TS_DB to TS_DB' ),
- array( '2001-01-15 12:34:56', TS_ISO_8601_BASIC, '20010115T123456Z', 'TS_DB to TS_ISO_8601_BASIC' ),
+ array(
+ '2001-01-15 12:34:56',
+ TS_ISO_8601_BASIC,
+ '20010115T123456Z',
+ 'TS_DB to TS_ISO_8601_BASIC'
+ ),
# rfc2822 section 3.3
array( '20010115123456', TS_RFC2822, 'Mon, 15 Jan 2001 12:34:56 GMT', 'TS_MW to TS_RFC2822' ),
array( 'Mon, 15 Jan 2001 12:34:56 GMT', TS_MW, '20010115123456', 'TS_RFC2822 to TS_MW' ),
- array( ' Mon, 15 Jan 2001 12:34:56 GMT', TS_MW, '20010115123456', 'TS_RFC2822 with leading space to TS_MW' ),
- array( '15 Jan 2001 12:34:56 GMT', TS_MW, '20010115123456', 'TS_RFC2822 without optional day-of-week to TS_MW' ),
+ array(
+ ' Mon, 15 Jan 2001 12:34:56 GMT',
+ TS_MW,
+ '20010115123456',
+ 'TS_RFC2822 with leading space to TS_MW'
+ ),
+ array(
+ '15 Jan 2001 12:34:56 GMT',
+ TS_MW,
+ '20010115123456',
+ 'TS_RFC2822 without optional day-of-week to TS_MW'
+ ),
# FWS = ([*WSP CRLF] 1*WSP) / obs-FWS ; Folding white space
# obs-FWS = 1*WSP *(CRLF 1*WSP) ; Section 4.2
array( 'Mon, 15 Jan 2001 12:34:56 GMT', TS_MW, '20010115123456', 'TS_RFC2822 to TS_MW' ),
# WSP = SP / HTAB ; rfc2234
- array( "Mon, 15 Jan\x092001 12:34:56 GMT", TS_MW, '20010115123456', 'TS_RFC2822 with HTAB to TS_MW' ),
- array( "Mon, 15 Jan\x09 \x09 2001 12:34:56 GMT", TS_MW, '20010115123456', 'TS_RFC2822 with HTAB and SP to TS_MW' ),
- array( 'Sun, 6 Nov 94 08:49:37 GMT', TS_MW, '19941106084937', 'TS_RFC2822 with obsolete year to TS_MW' ),
+ array(
+ "Mon, 15 Jan\x092001 12:34:56 GMT",
+ TS_MW,
+ '20010115123456',
+ 'TS_RFC2822 with HTAB to TS_MW'
+ ),
+ array(
+ "Mon, 15 Jan\x09 \x09 2001 12:34:56 GMT",
+ TS_MW,
+ '20010115123456',
+ 'TS_RFC2822 with HTAB and SP to TS_MW'
+ ),
+ array(
+ 'Sun, 6 Nov 94 08:49:37 GMT',
+ TS_MW,
+ '19941106084937',
+ 'TS_RFC2822 with obsolete year to TS_MW'
+ ),
);
}
public static function provideOldTimestamps() {
return array(
- array( '19011213204554', TS_RFC2822, 'Fri, 13 Dec 1901 20:45:54 GMT', 'Earliest time according to php documentation' ),
+ array(
+ '19011213204554',
+ TS_RFC2822,
+ 'Fri, 13 Dec 1901 20:45:54 GMT',
+ 'Earliest time according to PHP documentation'
+ ),
array( '20380119031407', TS_RFC2822, 'Tue, 19 Jan 2038 03:14:07 GMT', 'Latest 32 bit time' ),
array( '19011213204552', TS_UNIX, '-2147483648', 'Earliest 32 bit unix time' ),
array( '20380119031407', TS_UNIX, '2147483647', 'Latest 32 bit unix time' ),
array( '19011213204552', TS_RFC2822, 'Fri, 13 Dec 1901 20:45:52 GMT', 'Earliest 32 bit time' ),
- array( '19011213204551', TS_RFC2822, 'Fri, 13 Dec 1901 20:45:51 GMT', 'Earliest 32 bit time - 1' ),
+ array(
+ '19011213204551',
+ TS_RFC2822,
+ 'Fri, 13 Dec 1901 20:45:51 GMT', 'Earliest 32 bit time - 1'
+ ),
array( '20380119031408', TS_RFC2822, 'Tue, 19 Jan 2038 03:14:08 GMT', 'Latest 32 bit time + 1' ),
array( '19011212000000', TS_MW, '19011212000000', 'Convert to itself r74778#c10645' ),
array( '19011213204551', TS_UNIX, '-2147483649', 'Earliest 32 bit unix time - 1' ),
array( '20380119031408', TS_UNIX, '2147483648', 'Latest 32 bit unix time + 1' ),
array( '-2147483649', TS_MW, '19011213204551', '1901 negative unix time to MediaWiki' ),
array( '-5331871504', TS_MW, '18010115123456', '1801 negative unix time to MediaWiki' ),
- array( '0117-08-09 12:34:56', TS_RFC2822, 'Tue, 09 Aug 0117 12:34:56 GMT', 'Death of Roman Emperor [[Trajan]]' ),
+ array(
+ '0117-08-09 12:34:56',
+ TS_RFC2822,
+ 'Tue, 09 Aug 0117 12:34:56 GMT',
+ 'Death of Roman Emperor [[Trajan]]'
+ ),
/* @todo FIXME: 00 to 101 years are taken as being in [1970-2069] */
array( '-58979923200', TS_RFC2822, 'Sun, 01 Jan 0101 00:00:00 GMT', '1/1/101' ),
* We are completely off RFC2822 requirement of year being
* 1900 or later.
*/
- array( '-62142076800', TS_RFC2822, 'Wed, 18 Oct 0000 00:00:00 GMT', 'ISO 8601:2004 [[year 0]], also called [[1 BC]]' ),
+ array(
+ '-62142076800',
+ TS_RFC2822,
+ 'Wed, 18 Oct 0000 00:00:00 GMT',
+ 'ISO 8601:2004 [[year 0]], also called [[1 BC]]'
+ ),
);
}
array( 'Sunday, 06-Nov-94 08:49:37 GMT', '19941106084937', 'RFC 850 date' ),
array( 'Sun Nov 6 08:49:37 1994', '19941106084937', "ANSI C's asctime() format" ),
// See http://www.squid-cache.org/mail-archive/squid-users/200307/0122.html and r77171
- array( 'Mon, 22 Nov 2010 14:12:42 GMT; length=52626', '20101122141242', 'Netscape extension to HTTP/1.0' ),
+ array(
+ 'Mon, 22 Nov 2010 14:12:42 GMT; length=52626',
+ '20101122141242',
+ 'Netscape extension to HTTP/1.0'
+ ),
);
}
return $expectations;
} elseif ( is_array( $expectations ) ) {
if ( !array_key_exists( $server, $expectations ) ) {
- throw new MWException( __METHOD__ . " expectation does not have any value for server name $server. Check the provider array.\n" );
+ throw new MWException( __METHOD__ . " expectation does not have any "
+ . "value for server name $server. Check the provider array.\n" );
} else {
return $expectations[$server];
}
} else {
- throw new MWException( __METHOD__ . " given invalid expectation for '$server'. Should be a string or an array( <http server name> => <string> ).\n" );
+ throw new MWException( __METHOD__ . " given invalid expectation for "
+ . "'$server'. Should be a string or an array( <http server name> => <string> ).\n" );
}
}