summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/GlobalFunctions
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-01-28 09:50:25 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-01-28 09:50:25 -0500
commit5744df39e15f85c6cc8a9faf8924d77e76d2b216 (patch)
treea8c8dd40a94d1fa0d5377566aa5548ae55a163da /tests/phpunit/includes/GlobalFunctions
parent4bb2aeca1d198391ca856aa16c40b8559c68daec (diff)
parent224b22a051051f6c2e494c3a2fb4adb42898e2d1 (diff)
Merge branch 'archwiki'
Conflicts: extensions/FluxBBAuthPlugin.php extensions/SyntaxHighlight_GeSHi/README extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.i18n.php extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php extensions/SyntaxHighlight_GeSHi/geshi/docs/CHANGES extensions/SyntaxHighlight_GeSHi/geshi/docs/THANKS extensions/SyntaxHighlight_GeSHi/geshi/docs/TODO extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractClass.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractClass_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractMethod.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractPrivateClass.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractPrivateClass_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractPrivateMethod.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Class.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Class_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Constant.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Constructor.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Destructor.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Function.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Global.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/I.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Index.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Interface.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Interface_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/L.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Lminus.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Lplus.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Method.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Page.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Page_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateClass.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateClass_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateMethod.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateVariable.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/StaticMethod.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/StaticVariable.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/T.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Tminus.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Tplus.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Variable.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/blank.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/class_folder.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/file.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/folder.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/function_folder.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/next_button.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/next_button_disabled.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/package.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/package_folder.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/previous_button.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/previous_button_disabled.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/private_class_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/tutorial.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/tutorial_folder.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/up_button.png extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.html extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.txt extensions/SyntaxHighlight_GeSHi/geshi/geshi.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/4cs.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/6502acme.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/6502kickass.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/6502tasm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/68000devpac.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/abap.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/actionscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/actionscript3.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ada.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/algol68.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/apache.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/applescript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/apt_sources.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/asm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/asp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/autoconf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/autohotkey.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/autoit.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/avisynth.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/awk.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/bascomavr.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/bash.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/basic4gl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/bf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/bibtex.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/blitzbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/bnf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/boo.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/c.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/c_loadrunner.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/c_mac.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/caddcl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cadlisp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cfdg.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cfm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/chaiscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cil.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/clojure.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cmake.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cobol.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/coffeescript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cpp-qt.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cpp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/csharp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/css.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cuesheet.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/d.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/dcs.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/delphi.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/diff.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/div.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/dos.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/dot.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/e.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ecmascript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/eiffel.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/email.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/epc.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/erlang.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/euphoria.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/f1.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/falcon.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/fo.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/fortran.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/freebasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/fsharp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gambas.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gdb.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/genero.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/genie.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gettext.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/glsl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gml.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gnuplot.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/go.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/groovy.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gwbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/haskell.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/hicest.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/hq9plus.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/html4strict.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/html5.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/icon.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/idl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ini.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/inno.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/intercal.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/io.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/j.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/java.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/java5.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/javascript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/jquery.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/kixtart.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/klonec.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/klonecpp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/latex.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lb.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lisp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/llvm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/locobasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/logtalk.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lolcode.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lotusformulas.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lotusscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lsl2.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lua.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/m68k.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/magiksf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/make.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mapbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/matlab.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mirc.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mmix.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/modula2.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/modula3.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mpasm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mxml.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mysql.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/newlisp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/nsis.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oberon2.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/objc.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/objeck.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ocaml-brief.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ocaml.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oobas.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oracle11.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oracle8.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oxygene.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oz.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pascal.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pcre.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/per.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/perl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/perl6.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/php-brief.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/php.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pic16.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pike.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pixelbender.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pli.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/plsql.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/postgresql.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/povray.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/powerbuilder.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/powershell.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/proftpd.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/progress.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/prolog.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/properties.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/providex.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/purebasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pycon.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/python.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/q.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/qbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/rails.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/rebol.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/reg.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/robots.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/rpmspec.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/rsplus.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ruby.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/sas.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/scala.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/scheme.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/scilab.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/sdlbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/smalltalk.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/smarty.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/sql.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/systemverilog.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/tcl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/teraterm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/text.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/thinbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/tsql.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/typoscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/unicon.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/uscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/vala.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/vb.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/vbnet.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/verilog.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/vhdl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/vim.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/visualfoxpro.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/visualprolog.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/whitespace.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/whois.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/winbatch.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/xbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/xml.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/xorg_conf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/xpp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/yaml.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/z80.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/zxbasic.php
Diffstat (limited to 'tests/phpunit/includes/GlobalFunctions')
-rw-r--r--tests/phpunit/includes/GlobalFunctions/GlobalTest.php542
-rw-r--r--tests/phpunit/includes/GlobalFunctions/GlobalWithDBTest.php6
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php14
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfBCP47Test.php65
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfBaseConvertTest.php182
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php12
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php77
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php31
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfParseUrlTest.php146
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php11
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php10
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php30
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php51
13 files changed, 793 insertions, 384 deletions
diff --git a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php
index 9097d301..6154df1d 100644
--- a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php
@@ -1,67 +1,92 @@
<?php
class GlobalTest extends MediaWikiTestCase {
- function setUp() {
- global $wgReadOnlyFile, $wgUrlProtocols;
- $this->originals['wgReadOnlyFile'] = $wgReadOnlyFile;
- $this->originals['wgUrlProtocols'] = $wgUrlProtocols;
- $wgReadOnlyFile = tempnam( wfTempDir(), "mwtest_readonly" );
- $wgUrlProtocols[] = 'file://';
- unlink( $wgReadOnlyFile );
+ protected function setUp() {
+ parent::setUp();
+
+ $readOnlyFile = tempnam( wfTempDir(), "mwtest_readonly" );
+ unlink( $readOnlyFile );
+
+ $this->setMwGlobals( array(
+ 'wgReadOnlyFile' => $readOnlyFile,
+ 'wgUrlProtocols' => array(
+ 'http://',
+ 'https://',
+ 'mailto:',
+ '//',
+ 'file://', # Non-default
+ ),
+ ) );
}
- function tearDown() {
- global $wgReadOnlyFile, $wgUrlProtocols;
+ protected function tearDown() {
+ global $wgReadOnlyFile;
+
if ( file_exists( $wgReadOnlyFile ) ) {
unlink( $wgReadOnlyFile );
}
- $wgReadOnlyFile = $this->originals['wgReadOnlyFile'];
- $wgUrlProtocols = $this->originals['wgUrlProtocols'];
+
+ parent::tearDown();
}
- /** @dataProvider provideForWfArrayDiff2 */
+ /**
+ * @dataProvider provideForWfArrayDiff2
+ * @covers ::wfArrayDiff2
+ */
public function testWfArrayDiff2( $a, $b, $expected ) {
$this->assertEquals(
- wfArrayDiff2( $a, $b), $expected
+ wfArrayDiff2( $a, $b ), $expected
);
}
// @todo Provide more tests
- public function provideForWfArrayDiff2() {
+ public static function provideForWfArrayDiff2() {
// $a $b $expected
return array(
array(
- array( 'a', 'b'),
- array( 'a', 'b'),
+ array( 'a', 'b' ),
+ array( 'a', 'b' ),
array(),
),
array(
- array( array( 'a'), array( 'a', 'b', 'c' )),
- array( array( 'a'), array( 'a', 'b' )),
+ array( array( 'a' ), array( 'a', 'b', 'c' ) ),
+ array( array( 'a' ), array( 'a', 'b' ) ),
array( 1 => array( 'a', 'b', 'c' ) ),
),
);
}
- function testRandom() {
+ /**
+ * @covers ::wfRandom
+ */
+ public function testRandom() {
# This could hypothetically fail, but it shouldn't ;)
$this->assertFalse(
wfRandom() == wfRandom() );
}
- function testUrlencode() {
+ /**
+ * @covers ::wfUrlencode
+ */
+ public function testUrlencode() {
$this->assertEquals(
"%E7%89%B9%E5%88%A5:Contributions/Foobar",
wfUrlencode( "\xE7\x89\xB9\xE5\x88\xA5:Contributions/Foobar" ) );
}
- function testExpandIRI() {
+ /**
+ * @covers ::wfExpandIRI
+ */
+ 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" ) );
}
- function testReadOnlyEmpty() {
+ /**
+ * @covers ::wfReadOnly
+ */
+ public function testReadOnlyEmpty() {
global $wgReadOnly;
$wgReadOnly = null;
@@ -69,7 +94,10 @@ class GlobalTest extends MediaWikiTestCase {
$this->assertFalse( wfReadOnly() );
}
- function testReadOnlySet() {
+ /**
+ * @covers ::wfReadOnly
+ */
+ public function testReadOnlySet() {
global $wgReadOnly, $wgReadOnlyFile;
$f = fopen( $wgReadOnlyFile, "wt" );
@@ -87,20 +115,7 @@ class GlobalTest extends MediaWikiTestCase {
$this->assertFalse( wfReadOnly() );
}
- function testQuotedPrintable() {
- $this->assertEquals(
- "=?UTF-8?Q?=C4=88u=20legebla=3F?=",
- UserMailer::quotedPrintable( "\xc4\x88u legebla?", "UTF-8" ) );
- }
-
- function testTime() {
- $start = wfTime();
- $this->assertInternalType( 'float', $start );
- $end = wfTime();
- $this->assertTrue( $end > $start, "Time is running backwards!" );
- }
-
- function dataArrayToCGI() {
+ public static function provideArrayToCGI() {
return array(
array( array(), '' ), // empty
array( array( 'foo' => 'bar' ), 'foo=bar' ), // string test
@@ -119,22 +134,26 @@ class GlobalTest extends MediaWikiTestCase {
}
/**
- * @dataProvider dataArrayToCGI
+ * @dataProvider provideArrayToCGI
+ * @covers ::wfArrayToCgi
*/
- function testArrayToCGI( $array, $result ) {
- $this->assertEquals( $result, wfArrayToCGI( $array ) );
+ public function testArrayToCGI( $array, $result ) {
+ $this->assertEquals( $result, wfArrayToCgi( $array ) );
}
- function testArrayToCGI2() {
+ /**
+ * @covers ::testWfArrayDiff2
+ */
+ public function testArrayToCGI2() {
$this->assertEquals(
"baz=bar&foo=bar",
- wfArrayToCGI(
+ wfArrayToCgi(
array( 'baz' => 'bar' ),
array( 'foo' => 'bar', 'baz' => 'overridden value' ) ) );
}
- function dataCgiToArray() {
+ public static function provideCgiToArray() {
return array(
array( '', array() ), // empty
array( 'foo=bar', array( 'foo' => 'bar' ) ), // string
@@ -150,13 +169,14 @@ class GlobalTest extends MediaWikiTestCase {
}
/**
- * @dataProvider dataCgiToArray
+ * @dataProvider provideCgiToArray
+ * @covers ::wfCgiToArray
*/
- function testCgiToArray( $cgi, $result ) {
+ public function testCgiToArray( $cgi, $result ) {
$this->assertEquals( $result, wfCgiToArray( $cgi ) );
}
- function dataCgiRoundTrip() {
+ public static function provideCgiRoundTrip() {
return array(
array( '' ),
array( 'foo=bar' ),
@@ -170,166 +190,104 @@ class GlobalTest extends MediaWikiTestCase {
}
/**
- * @dataProvider dataCgiRoundTrip
+ * @dataProvider provideCgiRoundTrip
+ * @covers ::wfArrayToCgi
*/
- function testCgiRoundTrip( $cgi ) {
- $this->assertEquals( $cgi, wfArrayToCGI( wfCgiToArray( $cgi ) ) );
+ public function testCgiRoundTrip( $cgi ) {
+ $this->assertEquals( $cgi, wfArrayToCgi( wfCgiToArray( $cgi ) ) );
}
- function testMimeTypeMatch() {
+ /**
+ * @covers ::mimeTypeMatch
+ */
+ public function testMimeTypeMatch() {
$this->assertEquals(
'text/html',
mimeTypeMatch( 'text/html',
array( 'application/xhtml+xml' => 1.0,
- 'text/html' => 0.7,
- 'text/plain' => 0.3 ) ) );
+ 'text/html' => 0.7,
+ 'text/plain' => 0.3 ) ) );
$this->assertEquals(
'text/*',
mimeTypeMatch( 'text/html',
array( 'image/*' => 1.0,
- 'text/*' => 0.5 ) ) );
+ 'text/*' => 0.5 ) ) );
$this->assertEquals(
'*/*',
mimeTypeMatch( 'text/html',
array( '*/*' => 1.0 ) ) );
$this->assertNull(
mimeTypeMatch( 'text/html',
- array( 'image/png' => 1.0,
- 'image/svg+xml' => 0.5 ) ) );
+ array( 'image/png' => 1.0,
+ 'image/svg+xml' => 0.5 ) ) );
}
- function testNegotiateType() {
+ /**
+ * @covers ::wfNegotiateType
+ */
+ public function testNegotiateType() {
$this->assertEquals(
'text/html',
wfNegotiateType(
array( 'application/xhtml+xml' => 1.0,
- 'text/html' => 0.7,
- 'text/plain' => 0.5,
- 'text/*' => 0.2 ),
- array( 'text/html' => 1.0 ) ) );
+ 'text/html' => 0.7,
+ 'text/plain' => 0.5,
+ 'text/*' => 0.2 ),
+ array( 'text/html' => 1.0 ) ) );
$this->assertEquals(
'application/xhtml+xml',
wfNegotiateType(
array( 'application/xhtml+xml' => 1.0,
- 'text/html' => 0.7,
- 'text/plain' => 0.5,
- 'text/*' => 0.2 ),
+ 'text/html' => 0.7,
+ 'text/plain' => 0.5,
+ 'text/*' => 0.2 ),
array( 'application/xhtml+xml' => 1.0,
- 'text/html' => 0.5 ) ) );
+ 'text/html' => 0.5 ) ) );
$this->assertEquals(
'text/html',
wfNegotiateType(
- array( 'text/html' => 1.0,
- 'text/plain' => 0.5,
- 'text/*' => 0.5,
- 'application/xhtml+xml' => 0.2 ),
+ array( 'text/html' => 1.0,
+ 'text/plain' => 0.5,
+ 'text/*' => 0.5,
+ 'application/xhtml+xml' => 0.2 ),
array( 'application/xhtml+xml' => 1.0,
- 'text/html' => 0.5 ) ) );
+ 'text/html' => 0.5 ) ) );
$this->assertEquals(
'text/html',
wfNegotiateType(
- array( 'text/*' => 1.0,
- 'image/*' => 0.7,
- '*/*' => 0.3 ),
+ array( 'text/*' => 1.0,
+ 'image/*' => 0.7,
+ '*/*' => 0.3 ),
array( 'application/xhtml+xml' => 1.0,
- 'text/html' => 0.5 ) ) );
+ 'text/html' => 0.5 ) ) );
$this->assertNull(
wfNegotiateType(
- array( 'text/*' => 1.0 ),
+ array( 'text/*' => 1.0 ),
array( 'application/xhtml+xml' => 1.0 ) ) );
}
-
- function testFallbackMbstringFunctions() {
-
- if( !extension_loaded( 'mbstring' ) ) {
- $this->markTestSkipped( "The mb_string functions must be installed to test the fallback functions" );
- }
-
- $sampleUTF = "Östergötland_coat_of_arms.png";
-
-
- //mb_substr
- $substr_params = array(
- array( 0, 0 ),
- array( 5, -4 ),
- array( 33 ),
- array( 100, -5 ),
- array( -8, 10 ),
- array( 1, 1 ),
- array( 2, -1 )
- );
-
- foreach( $substr_params as $param_set ) {
- $old_param_set = $param_set;
- array_unshift( $param_set, $sampleUTF );
-
- $this->assertEquals(
- MWFunction::callArray( 'mb_substr', $param_set ),
- MWFunction::callArray( 'Fallback::mb_substr', $param_set ),
- 'Fallback mb_substr with params ' . implode( ', ', $old_param_set )
- );
- }
-
-
- //mb_strlen
- $this->assertEquals(
- mb_strlen( $sampleUTF ),
- Fallback::mb_strlen( $sampleUTF ),
- 'Fallback mb_strlen'
- );
-
-
- //mb_str(r?)pos
- $strpos_params = array(
- //array( 'ter' ),
- //array( 'Ö' ),
- //array( 'Ö', 3 ),
- //array( 'oat_', 100 ),
- //array( 'c', -10 ),
- //Broken for now
- );
-
- foreach( $strpos_params as $param_set ) {
- $old_param_set = $param_set;
- array_unshift( $param_set, $sampleUTF );
-
- $this->assertEquals(
- MWFunction::callArray( 'mb_strpos', $param_set ),
- MWFunction::callArray( 'Fallback::mb_strpos', $param_set ),
- 'Fallback mb_strpos with params ' . implode( ', ', $old_param_set )
- );
-
- $this->assertEquals(
- MWFunction::callArray( 'mb_strrpos', $param_set ),
- MWFunction::callArray( 'Fallback::mb_strrpos', $param_set ),
- 'Fallback mb_strrpos with params ' . implode( ', ', $old_param_set )
- );
- }
-
- }
-
-
- function testDebugFunctionTest() {
-
+
+ /**
+ * @covers ::wfDebug
+ * @covers ::wfDebugMem
+ */
+ public function testDebugFunctionTest() {
+
global $wgDebugLogFile, $wgDebugTimestamps;
-
+
$old_log_file = $wgDebugLogFile;
$wgDebugLogFile = tempnam( wfTempDir(), 'mw-' );
- # @todo FIXME: This setting should be tested
+ # @todo FIXME: $wgDebugTimestamps should be tested
+ $old_wgDebugTimestamps = $wgDebugTimestamps;
$wgDebugTimestamps = false;
-
-
-
+
wfDebug( "This is a normal string" );
$this->assertEquals( "This is a normal string", file_get_contents( $wgDebugLogFile ) );
unlink( $wgDebugLogFile );
-
-
+
wfDebug( "This is nöt an ASCII string" );
$this->assertEquals( "This is nöt an ASCII string", file_get_contents( $wgDebugLogFile ) );
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 ) );
unlink( $wgDebugLogFile );
@@ -337,19 +295,20 @@ class GlobalTest extends MediaWikiTestCase {
wfDebugMem();
$this->assertGreaterThan( 5000, preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) ) );
unlink( $wgDebugLogFile );
-
- wfDebugMem(true);
+
+ wfDebugMem( true );
$this->assertGreaterThan( 5000000, preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) ) );
unlink( $wgDebugLogFile );
-
-
-
+
$wgDebugLogFile = $old_log_file;
-
+ $wgDebugTimestamps = $old_wgDebugTimestamps;
}
-
- function testClientAcceptsGzipTest() {
-
+
+ /**
+ * @covers ::wfClientAcceptsGzip
+ */
+ public function testClientAcceptsGzipTest() {
+
$settings = array(
'gzip' => true,
'bzip' => false,
@@ -362,25 +321,27 @@ class GlobalTest extends MediaWikiTestCase {
'gzip;q=12345678.9' => true,
' gzip' => true,
);
-
- if( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) $old_server_setting = $_SERVER['HTTP_ACCEPT_ENCODING'];
-
+
+ if ( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) {
+ $old_server_setting = $_SERVER['HTTP_ACCEPT_ENCODING'];
+ }
+
foreach ( $settings as $encoding => $expect ) {
$_SERVER['HTTP_ACCEPT_ENCODING'] = $encoding;
-
+
$this->assertEquals( $expect, wfClientAcceptsGzip( true ),
"'$encoding' => " . wfBoolToStr( $expect ) );
}
-
- if( isset( $old_server_setting ) ) $_SERVER['HTTP_ACCEPT_ENCODING'] = $old_server_setting;
+ if ( isset( $old_server_setting ) ) {
+ $_SERVER['HTTP_ACCEPT_ENCODING'] = $old_server_setting;
+ }
}
-
-
-
- function testSwapVarsTest() {
-
+ /**
+ * @covers ::swap
+ */
+ public function testSwapVarsTest() {
$var1 = 1;
$var2 = 2;
@@ -391,89 +352,85 @@ class GlobalTest extends MediaWikiTestCase {
$this->assertEquals( $var1, 2, 'var1 is swapped' );
$this->assertEquals( $var2, 1, 'var2 is swapped' );
-
}
-
- function testWfPercentTest() {
+ /**
+ * @covers ::wfPercent
+ */
+ public function testWfPercentTest() {
$pcts = array(
- array( 6/7, '0.86%', 2, false ),
- array( 3/3, '1%' ),
- array( 22/7, '3.14286%', 5 ),
- array( 3/6, '0.5%' ),
- array( 1/3, '0%', 0 ),
- array( 10/3, '0%', -1 ),
- array( 3/4/5, '0.1%', 1 ),
- array( 6/7*8, '6.8571428571%', 10 ),
+ array( 6 / 7, '0.86%', 2, false ),
+ array( 3 / 3, '1%' ),
+ array( 22 / 7, '3.14286%', 5 ),
+ array( 3 / 6, '0.5%' ),
+ array( 1 / 3, '0%', 0 ),
+ array( 10 / 3, '0%', -1 ),
+ array( 3 / 4 / 5, '0.1%', 1 ),
+ array( 6 / 7 * 8, '6.8571428571%', 10 ),
);
-
- foreach( $pcts as $pct ) {
- if( !isset( $pct[2] ) ) $pct[2] = 2;
- if( !isset( $pct[3] ) ) $pct[3] = true;
-
- $this->assertEquals( wfPercent( $pct[0], $pct[2], $pct[3] ), $pct[1], $pct[1] );
- }
- }
+ foreach ( $pcts as $pct ) {
+ if ( !isset( $pct[2] ) ) {
+ $pct[2] = 2;
+ }
+ if ( !isset( $pct[3] ) ) {
+ $pct[3] = true;
+ }
-
- function testInStringTest() {
-
- $this->assertTrue( in_string( 'foo', 'foobar' ), 'foo is in foobar' );
- $this->assertFalse( in_string( 'Bar', 'foobar' ), 'Case-sensitive by default' );
- $this->assertTrue( in_string( 'Foo', 'foobar', true ), 'Case-insensitive when asked' );
-
+ $this->assertEquals( wfPercent( $pct[0], $pct[2], $pct[3] ), $pct[1], $pct[1] );
+ }
}
/**
* test @see wfShorthandToInteger()
* @dataProvider provideShorthand
+ * @covers ::wfShorthandToInteger
*/
public function testWfShorthandToInteger( $shorthand, $expected ) {
$this->assertEquals( $expected,
wfShorthandToInteger( $shorthand )
- );
+ );
}
/** array( shorthand, expected integer ) */
- public function provideShorthand() {
+ public static function provideShorthand() {
return array(
- # Null, empty ...
- array( '', -1),
- array( ' ', -1),
- array( null, -1),
+ # Null, empty ...
+ array( '', -1 ),
+ array( ' ', -1 ),
+ array( null, -1 ),
# Failures returns 0 :(
array( 'ABCDEFG', 0 ),
- array( 'Ak', 0 ),
+ array( 'Ak', 0 ),
# Int, strings with spaces
- array( 1, 1 ),
- array( ' 1 ', 1 ),
- array( 1023, 1023 ),
+ array( 1, 1 ),
+ array( ' 1 ', 1 ),
+ array( 1023, 1023 ),
array( ' 1023 ', 1023 ),
# kilo, Mega, Giga
- array( '1k', 1024 ),
- array( '1K', 1024 ),
- array( '1m', 1024 * 1024 ),
- array( '1M', 1024 * 1024 ),
- array( '1g', 1024 * 1024 * 1024 ),
- array( '1G', 1024 * 1024 * 1024 ),
+ array( '1k', 1024 ),
+ array( '1K', 1024 ),
+ array( '1m', 1024 * 1024 ),
+ array( '1M', 1024 * 1024 ),
+ array( '1g', 1024 * 1024 * 1024 ),
+ array( '1G', 1024 * 1024 * 1024 ),
# Negatives
- array( -1, -1 ),
- array( -500, -500 ),
- array( '-500', -500 ),
- array( '-1k', -1024 ),
+ array( -1, -1 ),
+ array( -500, -500 ),
+ array( '-500', -500 ),
+ array( '-1k', -1024 ),
# Zeroes
- array( '0', 0 ),
- array( '0k', 0 ),
- array( '0M', 0 ),
- array( '0G', 0 ),
- array( '-0', 0 ),
+ array( '0', 0 ),
+ array( '0k', 0 ),
+ array( '0M', 0 ),
+ array( '0G', 0 ),
+ array( '-0', 0 ),
array( '-0k', 0 ),
array( '-0M', 0 ),
array( '-0G', 0 ),
@@ -481,14 +438,98 @@ class GlobalTest extends MediaWikiTestCase {
}
/**
+ * @param String $old: Text as it was in the database
+ * @param String $mine: Text submitted while user was editing
+ * @param String $yours: Text submitted by the user
+ * @param Boolean $expectedMergeResult Whether the merge should be a success
+ * @param String $expectedText: Text after merge has been completed
+ *
+ * @dataProvider provideMerge()
+ * @group medium
+ * @covers ::wfMerge
+ */
+ public function testMerge( $old, $mine, $yours, $expectedMergeResult, $expectedText ) {
+ $this->checkHasDiff3();
+
+ $mergedText = null;
+ $isMerged = wfMerge( $old, $mine, $yours, $mergedText );
+
+ $msg = 'Merge should be a ';
+ $msg .= $expectedMergeResult ? 'success' : 'failure';
+ $this->assertEquals( $expectedMergeResult, $isMerged, $msg );
+
+ if ( $isMerged ) {
+ // Verify the merged text
+ $this->assertEquals( $expectedText, $mergedText,
+ 'is merged text as expected?' );
+ }
+ }
+
+ public static function provideMerge() {
+ $EXPECT_MERGE_SUCCESS = true;
+ $EXPECT_MERGE_FAILURE = false;
+
+ return array(
+ // #0: clean merge
+ array(
+ // old:
+ "one one one\n" . // trimmed
+ "\n" .
+ "two two two",
+
+ // mine:
+ "one one one ONE ONE\n" .
+ "\n" .
+ "two two two\n", // with tailing whitespace
+
+ // yours:
+ "one one one\n" .
+ "\n" .
+ "two two TWO TWO", // trimmed
+
+ // ok:
+ $EXPECT_MERGE_SUCCESS,
+
+ // result:
+ "one one one ONE ONE\n" .
+ "\n" .
+ "two two TWO TWO\n", // note: will always end in a newline
+ ),
+
+ // #1: conflict, fail
+ array(
+ // old:
+ "one one one", // trimmed
+
+ // mine:
+ "one one one ONE ONE\n" .
+ "\n" .
+ "bla bla\n" .
+ "\n", // with tailing whitespace
+
+ // yours:
+ "one one one\n" .
+ "\n" .
+ "two two", // trimmed
+
+ $EXPECT_MERGE_FAILURE,
+
+ // result:
+ null,
+ ),
+ );
+ }
+
+ /**
* @dataProvider provideMakeUrlIndexes()
+ * @covers ::wfMakeUrlIndexes
*/
- function testMakeUrlIndexes( $url, $expected ) {
+ public function testMakeUrlIndexes( $url, $expected ) {
$index = wfMakeUrlIndexes( $url );
$this->assertEquals( $expected, $index, "wfMakeUrlIndexes(\"$url\")" );
}
- function provideMakeUrlIndexes() {
+ public static function provideMakeUrlIndexes() {
return array(
array(
// just a regular :)
@@ -536,16 +577,17 @@ class GlobalTest extends MediaWikiTestCase {
),
);
}
-
+
/**
* @dataProvider provideWfMatchesDomainList
+ * @covers ::wfMatchesDomainList
*/
- function testWfMatchesDomainList( $url, $domains, $expected, $description ) {
+ public function testWfMatchesDomainList( $url, $domains, $expected, $description ) {
$actual = wfMatchesDomainList( $url, $domains );
$this->assertEquals( $expected, $actual, $description );
}
-
- function provideWfMatchesDomainList() {
+
+ public static function provideWfMatchesDomainList() {
$a = array();
$protocols = array( 'HTTP' => 'http:', 'HTTPS' => 'https:', 'protocol-relative' => '' );
foreach ( $protocols as $pDesc => $p ) {
@@ -556,19 +598,31 @@ class GlobalTest extends MediaWikiTestCase {
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" ),
-
- // FIXME: This is a bug in wfMatchesDomainList(). If and when this is fixed, update this test case
- array( "$p//nds-nl.wikipedia.org", array( 'nl.wikipedia.org' ), true, "Substrings of domains match while they shouldn't, $pDesc URL" ),
+ array( "$p//nds-nl.wikipedia.org", array( 'nl.wikipedia.org' ), false, "Non-matching substring of domain, $pDesc URL" ),
) );
}
+
return $a;
}
/**
+ * @covers ::wfMkdirParents
+ */
+ public function testWfMkdirParents() {
+ // Should not return true if file exists instead of directory
+ $fname = $this->getNewTempFile();
+ wfSuppressWarnings();
+ $ok = wfMkdirParents( $fname );
+ wfRestoreWarnings();
+ $this->assertFalse( $ok );
+ }
+
+ /**
* @dataProvider provideWfShellMaintenanceCmdList
+ * @covers ::wfShellMaintenanceCmd
*/
- function testWfShellMaintenanceCmd( $script, $parameters, $options, $expected, $description ) {
- if( wfIsWindows() ) {
+ public function testWfShellMaintenanceCmd( $script, $parameters, $options, $expected, $description ) {
+ if ( wfIsWindows() ) {
// Approximation that's good enough for our purposes just now
$expected = str_replace( "'", '"', $expected );
}
@@ -576,23 +630,23 @@ class GlobalTest extends MediaWikiTestCase {
$this->assertEquals( $expected, $actual, $description );
}
- function provideWfShellMaintenanceCmdList() {
+ public static function provideWfShellMaintenanceCmdList() {
global $wgPhpCli;
+
return array(
array( 'eval.php', array( '--help', '--test' ), array(),
"'$wgPhpCli' 'eval.php' '--help' '--test'",
"Called eval.php --help --test" ),
- array( 'eval.php', array( '--help', '--test space' ), array('php' => 'php5'),
+ array( 'eval.php', array( '--help', '--test space' ), array( 'php' => 'php5' ),
"'php5' 'eval.php' '--help' '--test space'",
"Called eval.php --help --test with php option" ),
- array( 'eval.php', array( '--help', '--test', 'X' ), array('wrapper' => 'MWScript.php'),
+ 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" ),
);
}
- /* TODO: many more! */
+ /* @TODO many more! */
}
-
diff --git a/tests/phpunit/includes/GlobalFunctions/GlobalWithDBTest.php b/tests/phpunit/includes/GlobalFunctions/GlobalWithDBTest.php
index 4879a38d..cf891e7b 100644
--- a/tests/phpunit/includes/GlobalFunctions/GlobalWithDBTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/GlobalWithDBTest.php
@@ -6,13 +6,15 @@
class GlobalWithDBTest extends MediaWikiTestCase {
/**
* @dataProvider provideWfIsBadImageList
+ * @covers ::wfIsBadImage
*/
- function testWfIsBadImage( $name, $title, $blacklist, $expected, $desc ) {
+ public function testWfIsBadImage( $name, $title, $blacklist, $expected, $desc ) {
$this->assertEquals( $expected, wfIsBadImage( $name, $title, $blacklist ), $desc );
}
- function provideWfIsBadImageList() {
+ public static function provideWfIsBadImageList() {
$blacklist = '* [[File:Bad.jpg]] except [[Nasty page]]';
+
return array(
array( 'Bad.jpg', false, $blacklist, true,
'Called on a bad image' ),
diff --git a/tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php b/tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php
index be6c99e7..9bb74873 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php
@@ -1,10 +1,11 @@
<?php
/**
- * Unit tests for wfAssembleUrl()
+ * @covers ::wfAssembleUrl
*/
-
-class wfAssembleUrl extends MediaWikiTestCase {
- /** @dataProvider provideURLParts */
+class WfAssembleUrlTest extends MediaWikiTestCase {
+ /**
+ * @dataProvider provideURLParts
+ */
public function testWfAssembleUrl( $parts, $output ) {
$partsDump = print_r( $parts, true );
$this->assertEquals(
@@ -19,7 +20,7 @@ class wfAssembleUrl extends MediaWikiTestCase {
*
* @return array
*/
- public function provideURLParts() {
+ public static function provideURLParts() {
$schemes = array(
'' => array(),
'//' => array(
@@ -83,12 +84,11 @@ class wfAssembleUrl extends MediaWikiTestCase {
$parts['query'] = $query;
$url .= '?' . $query;
}
- if( $fragment ) {
+ if ( $fragment ) {
$parts['fragment'] = $fragment;
$url .= '#' . $fragment;
}
-
$cases[] = array(
$parts,
$url,
diff --git a/tests/phpunit/includes/GlobalFunctions/wfBCP47Test.php b/tests/phpunit/includes/GlobalFunctions/wfBCP47Test.php
index f4ec7a5f..a01c0d49 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfBCP47Test.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfBCP47Test.php
@@ -1,26 +1,26 @@
<?php
/**
- * Unit tests for wfBCP47()
+ * @covers ::wfBCP47
*/
-class wfBCP47 extends MediaWikiTestCase {
+class WfBCP47Test extends MediaWikiTestCase {
/**
* test @see wfBCP47().
* Please note the BCP explicitly state that language codes are case
* insensitive, there are some exceptions to the rule :)
- * This test is used to verify our formatting against all lower and
+ * This test is used to verify our formatting against all lower and
* all upper cases language code.
*
* @see http://tools.ietf.org/html/bcp47
* @dataProvider provideLanguageCodes()
*/
- function testBCP47( $code, $expected ) {
+ public function testBCP47( $code, $expected ) {
$code = strtolower( $code );
- $this->assertEquals( $expected, wfBCP47($code),
+ $this->assertEquals( $expected, wfBCP47( $code ),
"Applying BCP47 standard to lower case '$code'"
);
$code = strtoupper( $code );
- $this->assertEquals( $expected, wfBCP47($code),
+ $this->assertEquals( $expected, wfBCP47( $code ),
"Applying BCP47 standard to upper case '$code'"
);
}
@@ -28,19 +28,19 @@ class wfBCP47 extends MediaWikiTestCase {
/**
* Array format is ($code, $expected)
*/
- function provideLanguageCodes() {
+ public static function provideLanguageCodes() {
return array(
// Extracted from BCP47 (list not exhaustive)
# 2.1.1
- array( 'en-ca-x-ca' , 'en-CA-x-ca' ),
- array( 'sgn-be-fr' , 'sgn-BE-FR' ),
+ array( 'en-ca-x-ca', 'en-CA-x-ca' ),
+ array( 'sgn-be-fr', 'sgn-BE-FR' ),
array( 'az-latn-x-latn', 'az-Latn-x-latn' ),
# 2.2
array( 'sr-Latn-RS', 'sr-Latn-RS' ),
array( 'az-arab-ir', 'az-Arab-IR' ),
# 2.2.5
- array( 'sl-nedis' , 'sl-nedis' ),
+ array( 'sl-nedis', 'sl-nedis' ),
array( 'de-ch-1996', 'de-CH-1996' ),
# 2.2.6
@@ -56,40 +56,40 @@ class wfBCP47 extends MediaWikiTestCase {
array( 'ja', 'ja' ),
# Language subtag plus script subtag:
- array( 'zh-hans', 'zh-Hans'),
- array( 'sr-cyrl', 'sr-Cyrl'),
- array( 'sr-latn', 'sr-Latn'),
+ array( 'zh-hans', 'zh-Hans' ),
+ array( 'sr-cyrl', 'sr-Cyrl' ),
+ array( 'sr-latn', 'sr-Latn' ),
# Extended language subtags and their primary language subtag
# counterparts:
array( 'zh-cmn-hans-cn', 'zh-cmn-Hans-CN' ),
- array( 'cmn-hans-cn' , 'cmn-Hans-CN' ),
- array( 'zh-yue-hk' , 'zh-yue-HK' ),
- array( 'yue-hk' , 'yue-HK' ),
+ array( 'cmn-hans-cn', 'cmn-Hans-CN' ),
+ array( 'zh-yue-hk', 'zh-yue-HK' ),
+ array( 'yue-hk', 'yue-HK' ),
# Language-Script-Region:
array( 'zh-hans-cn', 'zh-Hans-CN' ),
array( 'sr-latn-RS', 'sr-Latn-RS' ),
# Language-Variant:
- array( 'sl-rozaj' , 'sl-rozaj' ),
+ array( 'sl-rozaj', 'sl-rozaj' ),
array( 'sl-rozaj-biske', 'sl-rozaj-biske' ),
- array( 'sl-nedis' , 'sl-nedis' ),
+ array( 'sl-nedis', 'sl-nedis' ),
# Language-Region-Variant:
- array( 'de-ch-1901' , 'de-CH-1901' ),
- array( 'sl-it-nedis' , 'sl-IT-nedis' ),
+ array( 'de-ch-1901', 'de-CH-1901' ),
+ array( 'sl-it-nedis', 'sl-IT-nedis' ),
# Language-Script-Region-Variant:
array( 'hy-latn-it-arevela', 'hy-Latn-IT-arevela' ),
# Language-Region:
- array( 'de-de' , 'de-DE' ),
- array( 'en-us' , 'en-US' ),
- array( 'es-419', 'es-419'),
+ array( 'de-de', 'de-DE' ),
+ array( 'en-us', 'en-US' ),
+ array( 'es-419', 'es-419' ),
# Private use subtags:
- array( 'de-ch-x-phonebk' , 'de-CH-x-phonebk' ),
+ array( 'de-ch-x-phonebk', 'de-CH-x-phonebk' ),
array( 'az-arab-x-aze-derbend', 'az-Arab-x-aze-derbend' ),
/**
* Previous test does not reflect the BCP which states:
@@ -102,7 +102,7 @@ class wfBCP47 extends MediaWikiTestCase {
# Private use registry values:
array( 'x-whatever', 'x-whatever' ),
array( 'qaa-qaaa-qm-x-southern', 'qaa-Qaaa-QM-x-southern' ),
- array( 'de-qaaa' , 'de-Qaaa' ),
+ array( 'de-qaaa', 'de-Qaaa' ),
array( 'sr-latn-qm', 'sr-Latn-QM' ),
array( 'sr-qaaa-rs', 'sr-Qaaa-RS' ),
@@ -115,19 +115,6 @@ class wfBCP47 extends MediaWikiTestCase {
// de-419-DE
// a-DE
// ar-a-aaa-b-bbb-a-ccc
-
- /*
- // ISO 15924 :
- array( 'sr-Cyrl', 'sr-Cyrl' ),
- # @todo FIXME: Fix our function?
- array( 'SR-lATN', 'sr-Latn' ),
- array( 'fr-latn', 'fr-Latn' ),
- // Use lowercase for single segment
- // ISO 3166-1-alpha-2 code
- array( 'US', 'us' ), # USA
- array( 'uS', 'us' ), # USA
- array( 'Fr', 'fr' ), # France
- array( 'va', 'va' ), # Holy See (Vatican City State)
- */);
+ );
}
}
diff --git a/tests/phpunit/includes/GlobalFunctions/wfBaseConvertTest.php b/tests/phpunit/includes/GlobalFunctions/wfBaseConvertTest.php
new file mode 100644
index 00000000..7da804e6
--- /dev/null
+++ b/tests/phpunit/includes/GlobalFunctions/wfBaseConvertTest.php
@@ -0,0 +1,182 @@
+<?php
+/**
+ * @covers ::wfBaseConvert
+ */
+class WfBaseConvertTest extends MediaWikiTestCase {
+ public static function provideSingleDigitConversions() {
+ return array(
+ // 2 3 5 8 10 16 36
+ array( '0', '0', '0', '0', '0', '0', '0' ),
+ array( '1', '1', '1', '1', '1', '1', '1' ),
+ array( '10', '2', '2', '2', '2', '2', '2' ),
+ array( '11', '10', '3', '3', '3', '3', '3' ),
+ array( '100', '11', '4', '4', '4', '4', '4' ),
+ array( '101', '12', '10', '5', '5', '5', '5' ),
+ array( '110', '20', '11', '6', '6', '6', '6' ),
+ array( '111', '21', '12', '7', '7', '7', '7' ),
+ array( '1000', '22', '13', '10', '8', '8', '8' ),
+ array( '1001', '100', '14', '11', '9', '9', '9' ),
+ array( '1010', '101', '20', '12', '10', 'a', 'a' ),
+ array( '1011', '102', '21', '13', '11', 'b', 'b' ),
+ array( '1100', '110', '22', '14', '12', 'c', 'c' ),
+ array( '1101', '111', '23', '15', '13', 'd', 'd' ),
+ array( '1110', '112', '24', '16', '14', 'e', 'e' ),
+ array( '1111', '120', '30', '17', '15', 'f', 'f' ),
+ array( '10000', '121', '31', '20', '16', '10', 'g' ),
+ array( '10001', '122', '32', '21', '17', '11', 'h' ),
+ array( '10010', '200', '33', '22', '18', '12', 'i' ),
+ array( '10011', '201', '34', '23', '19', '13', 'j' ),
+ array( '10100', '202', '40', '24', '20', '14', 'k' ),
+ array( '10101', '210', '41', '25', '21', '15', 'l' ),
+ array( '10110', '211', '42', '26', '22', '16', 'm' ),
+ array( '10111', '212', '43', '27', '23', '17', 'n' ),
+ array( '11000', '220', '44', '30', '24', '18', 'o' ),
+ array( '11001', '221', '100', '31', '25', '19', 'p' ),
+ array( '11010', '222', '101', '32', '26', '1a', 'q' ),
+ array( '11011', '1000', '102', '33', '27', '1b', 'r' ),
+ array( '11100', '1001', '103', '34', '28', '1c', 's' ),
+ array( '11101', '1002', '104', '35', '29', '1d', 't' ),
+ array( '11110', '1010', '110', '36', '30', '1e', 'u' ),
+ array( '11111', '1011', '111', '37', '31', '1f', 'v' ),
+ array( '100000', '1012', '112', '40', '32', '20', 'w' ),
+ array( '100001', '1020', '113', '41', '33', '21', 'x' ),
+ array( '100010', '1021', '114', '42', '34', '22', 'y' ),
+ array( '100011', '1022', '120', '43', '35', '23', 'z' )
+ );
+ }
+
+ /**
+ * @dataProvider provideSingleDigitConversions
+ */
+ public function testDigitToBase2( $base2, $base3, $base5, $base8, $base10, $base16, $base36 ) {
+ $this->assertSame( $base2, wfBaseConvert( $base3, '3', '2' ) );
+ $this->assertSame( $base2, wfBaseConvert( $base5, '5', '2' ) );
+ $this->assertSame( $base2, wfBaseConvert( $base8, '8', '2' ) );
+ $this->assertSame( $base2, wfBaseConvert( $base10, '10', '2' ) );
+ $this->assertSame( $base2, wfBaseConvert( $base16, '16', '2' ) );
+ $this->assertSame( $base2, wfBaseConvert( $base36, '36', '2' ) );
+ }
+
+ /**
+ * @dataProvider provideSingleDigitConversions
+ */
+ public function testDigitToBase3( $base2, $base3, $base5, $base8, $base10, $base16, $base36 ) {
+ $this->assertSame( $base3, wfBaseConvert( $base2, '2', '3' ) );
+ $this->assertSame( $base3, wfBaseConvert( $base5, '5', '3' ) );
+ $this->assertSame( $base3, wfBaseConvert( $base8, '8', '3' ) );
+ $this->assertSame( $base3, wfBaseConvert( $base10, '10', '3' ) );
+ $this->assertSame( $base3, wfBaseConvert( $base16, '16', '3' ) );
+ $this->assertSame( $base3, wfBaseConvert( $base36, '36', '3' ) );
+ }
+
+ /**
+ * @dataProvider provideSingleDigitConversions
+ */
+ public function testDigitToBase5( $base2, $base3, $base5, $base8, $base10, $base16, $base36 ) {
+ $this->assertSame( $base5, wfBaseConvert( $base2, '2', '5' ) );
+ $this->assertSame( $base5, wfBaseConvert( $base3, '3', '5' ) );
+ $this->assertSame( $base5, wfBaseConvert( $base8, '8', '5' ) );
+ $this->assertSame( $base5, wfBaseConvert( $base10, '10', '5' ) );
+ $this->assertSame( $base5, wfBaseConvert( $base16, '16', '5' ) );
+ $this->assertSame( $base5, wfBaseConvert( $base36, '36', '5' ) );
+ }
+
+ /**
+ * @dataProvider provideSingleDigitConversions
+ */
+ public function testDigitToBase8( $base2, $base3, $base5, $base8, $base10, $base16, $base36 ) {
+ $this->assertSame( $base8, wfBaseConvert( $base2, '2', '8' ) );
+ $this->assertSame( $base8, wfBaseConvert( $base3, '3', '8' ) );
+ $this->assertSame( $base8, wfBaseConvert( $base5, '5', '8' ) );
+ $this->assertSame( $base8, wfBaseConvert( $base10, '10', '8' ) );
+ $this->assertSame( $base8, wfBaseConvert( $base16, '16', '8' ) );
+ $this->assertSame( $base8, wfBaseConvert( $base36, '36', '8' ) );
+ }
+
+ /**
+ * @dataProvider provideSingleDigitConversions
+ */
+ public function testDigitToBase10( $base2, $base3, $base5, $base8, $base10, $base16, $base36 ) {
+ $this->assertSame( $base10, wfBaseConvert( $base2, '2', '10' ) );
+ $this->assertSame( $base10, wfBaseConvert( $base3, '3', '10' ) );
+ $this->assertSame( $base10, wfBaseConvert( $base5, '5', '10' ) );
+ $this->assertSame( $base10, wfBaseConvert( $base8, '8', '10' ) );
+ $this->assertSame( $base10, wfBaseConvert( $base16, '16', '10' ) );
+ $this->assertSame( $base10, wfBaseConvert( $base36, '36', '10' ) );
+ }
+
+ /**
+ * @dataProvider provideSingleDigitConversions
+ */
+ public function testDigitToBase16( $base2, $base3, $base5, $base8, $base10, $base16, $base36 ) {
+ $this->assertSame( $base16, wfBaseConvert( $base2, '2', '16' ) );
+ $this->assertSame( $base16, wfBaseConvert( $base3, '3', '16' ) );
+ $this->assertSame( $base16, wfBaseConvert( $base5, '5', '16' ) );
+ $this->assertSame( $base16, wfBaseConvert( $base8, '8', '16' ) );
+ $this->assertSame( $base16, wfBaseConvert( $base10, '10', '16' ) );
+ $this->assertSame( $base16, wfBaseConvert( $base36, '36', '16' ) );
+ }
+
+ /**
+ * @dataProvider provideSingleDigitConversions
+ */
+ public function testDigitToBase36( $base2, $base3, $base5, $base8, $base10, $base16, $base36 ) {
+ $this->assertSame( $base36, wfBaseConvert( $base2, '2', '36' ) );
+ $this->assertSame( $base36, wfBaseConvert( $base3, '3', '36' ) );
+ $this->assertSame( $base36, wfBaseConvert( $base5, '5', '36' ) );
+ $this->assertSame( $base36, wfBaseConvert( $base8, '8', '36' ) );
+ $this->assertSame( $base36, wfBaseConvert( $base10, '10', '36' ) );
+ $this->assertSame( $base36, wfBaseConvert( $base16, '16', '36' ) );
+ }
+
+ public function testLargeNumber() {
+ $this->assertSame( '1100110001111010000000101110100', wfBaseConvert( 'sd89ys', 36, 2 ) );
+ $this->assertSame( '11102112120221201101', wfBaseConvert( 'sd89ys', 36, 3 ) );
+ $this->assertSame( '12003102232400', wfBaseConvert( 'sd89ys', 36, 5 ) );
+ $this->assertSame( '14617200564', wfBaseConvert( 'sd89ys', 36, 8 ) );
+ $this->assertSame( '1715274100', wfBaseConvert( 'sd89ys', 36, 10 ) );
+ $this->assertSame( '663d0174', wfBaseConvert( 'sd89ys', 36, 16 ) );
+ }
+
+ public static function provideNumbers() {
+ $x = array();
+ $chars = '0123456789abcdefghijklmnopqrstuvwxyz';
+ for ( $i = 0; $i < 50; $i++ ) {
+ $base = mt_rand( 2, 36 );
+ $len = mt_rand( 10, 100 );
+
+ $str = '';
+ for ( $j = 0; $j < $len; $j++ ) {
+ $str .= $chars[mt_rand( 0, $base - 1 )];
+ }
+
+ $x[] = array( $base, $str );
+ }
+
+ return $x;
+ }
+
+ /**
+ * @dataProvider provideNumbers
+ */
+ public function testIdentity( $base, $number ) {
+ $this->assertSame( $number, wfBaseConvert( $number, $base, $base, strlen( $number ) ) );
+ }
+
+ public function testInvalid() {
+ $this->assertFalse( wfBaseConvert( '101', 1, 15 ) );
+ $this->assertFalse( wfBaseConvert( '101', 15, 1 ) );
+ $this->assertFalse( wfBaseConvert( '101', 37, 15 ) );
+ $this->assertFalse( wfBaseConvert( '101', 15, 37 ) );
+ $this->assertFalse( wfBaseConvert( 'abcde', 10, 11 ) );
+ $this->assertFalse( wfBaseConvert( '12930', 2, 10 ) );
+ $this->assertFalse( wfBaseConvert( '101', 'abc', 15 ) );
+ $this->assertFalse( wfBaseConvert( '101', 15, 'abc' ) );
+ }
+
+ 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 ) ) );
+ }
+}
diff --git a/tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php b/tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php
index 59954b23..8c548040 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php
@@ -1,17 +1,17 @@
<?php
/**
- * Tests for wfBaseName()
+ * @covers ::wfBaseName
*/
-class wfBaseName extends MediaWikiTestCase {
+class WfBaseNameTest extends MediaWikiTestCase {
/**
* @dataProvider providePaths
*/
- function testBaseName( $fullpath, $basename ) {
+ public function testBaseName( $fullpath, $basename ) {
$this->assertEquals( $basename, wfBaseName( $fullpath ),
- "wfBaseName('$fullpath') => '$basename'" );
+ "wfBaseName('$fullpath') => '$basename'" );
}
-
- function providePaths() {
+
+ public static function providePaths() {
return array(
array( '', '' ),
array( '/', '' ),
diff --git a/tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php b/tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php
index 192689f8..41230a1e 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php
@@ -1,17 +1,17 @@
<?php
/**
- * Unit tests for wfExpandUrl()
+ * @covers ::wfExpandUrl
*/
-
-class wfExpandUrl extends MediaWikiTestCase {
- /** @dataProvider provideExpandableUrls */
+class WfExpandUrlTest extends MediaWikiTestCase {
+ /**
+ * @dataProvider provideExpandableUrls
+ */
public function testWfExpandUrl( $fullUrl, $shortUrl, $defaultProto, $server, $canServer, $httpsMode, $message ) {
// Fake $wgServer and $wgCanonicalServer
- global $wgServer, $wgCanonicalServer;
- $oldServer = $wgServer;
- $oldCanServer = $wgCanonicalServer;
- $wgServer = $server;
- $wgCanonicalServer = $canServer;
+ $this->setMwGlobals( array(
+ 'wgServer' => $server,
+ 'wgCanonicalServer' => $canServer,
+ ) );
// Fake $_SERVER['HTTPS'] if needed
if ( $httpsMode ) {
@@ -21,10 +21,6 @@ class wfExpandUrl extends MediaWikiTestCase {
}
$this->assertEquals( $fullUrl, wfExpandUrl( $shortUrl, $defaultProto ), $message );
-
- // Restore $wgServer and $wgCanonicalServer
- $wgServer = $oldServer;
- $wgCanonicalServer = $oldCanServer;
}
/**
@@ -32,25 +28,49 @@ class wfExpandUrl extends MediaWikiTestCase {
*
* @return array
*/
- public function provideExpandableUrls() {
+ public static function provideExpandableUrls() {
$modes = array( 'http', 'https' );
- $servers = array( 'http' => 'http://example.com', 'https' => 'https://example.com', 'protocol-relative' => '//example.com' );
- $defaultProtos = array( 'http' => PROTO_HTTP, 'https' => PROTO_HTTPS, 'protocol-relative' => PROTO_RELATIVE, 'current' => PROTO_CURRENT, 'canonical' => PROTO_CANONICAL );
+ $servers = array(
+ 'http' => 'http://example.com',
+ 'https' => 'https://example.com',
+ 'protocol-relative' => '//example.com'
+ );
+ $defaultProtos = array(
+ 'http' => PROTO_HTTP,
+ 'https' => PROTO_HTTPS,
+ 'protocol-relative' => PROTO_RELATIVE,
+ 'current' => PROTO_CURRENT,
+ 'canonical' => PROTO_CANONICAL
+ );
$retval = array();
foreach ( $modes as $mode ) {
$httpsMode = $mode == 'https';
foreach ( $servers as $serverDesc => $server ) {
- foreach ( $modes as $canServerMode ) {
+ foreach ( $modes as $canServerMode ) {
$canServer = "$canServerMode://example2.com";
foreach ( $defaultProtos as $protoDesc => $defaultProto ) {
- $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 )" );
- $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 )" );
+ $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 )"
+ );
+ $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 )"
+ );
# 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 )" );
+ $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 )"
+ );
// Determine expected protocol
- $p = $protoDesc . ':'; // default case
if ( $protoDesc == 'protocol-relative' ) {
$p = '';
} elseif ( $protoDesc == 'current' ) {
@@ -69,12 +89,23 @@ class wfExpandUrl extends MediaWikiTestCase {
$srv = $server;
}
- $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 )" );
- $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 )" );
+ $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 )"
+ );
+ $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 )"
+ );
}
}
}
}
+
return $retval;
}
}
diff --git a/tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php b/tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php
index 4c4c4c04..62296245 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php
@@ -1,8 +1,11 @@
<?php
-class wfGetCaller extends MediaWikiTestCase {
+/**
+ * @covers ::wfGetCaller
+ */
+class WfGetCallerTest extends MediaWikiTestCase {
- function testZero() {
+ public function testZero() {
$this->assertEquals( __METHOD__, wfGetCaller( 1 ) );
}
@@ -10,26 +13,28 @@ class wfGetCaller extends MediaWikiTestCase {
return wfGetCaller();
}
- function testOne() {
- $this->assertEquals( "wfGetCaller::testOne", self::callerOne() );
+ public function testOne() {
+ $this->assertEquals( 'WfGetCallerTest::testOne', self::callerOne() );
}
function intermediateFunction( $level = 2, $n = 0 ) {
- if ( $n > 0 )
+ if ( $n > 0 ) {
return self::intermediateFunction( $level, $n - 1 );
+ }
+
return wfGetCaller( $level );
}
- function testTwo() {
- $this->assertEquals( "wfGetCaller::testTwo", self::intermediateFunction() );
+ public function testTwo() {
+ $this->assertEquals( 'WfGetCallerTest::testTwo', self::intermediateFunction() );
}
- function testN() {
- $this->assertEquals( "wfGetCaller::testN", self::intermediateFunction( 2, 0 ) );
- $this->assertEquals( "wfGetCaller::intermediateFunction", self::intermediateFunction( 1, 0 ) );
+ public function testN() {
+ $this->assertEquals( 'WfGetCallerTest::testN', self::intermediateFunction( 2, 0 ) );
+ $this->assertEquals( 'WfGetCallerTest::intermediateFunction', self::intermediateFunction( 1, 0 ) );
- for ($i=0; $i < 10; $i++)
- $this->assertEquals( "wfGetCaller::intermediateFunction", self::intermediateFunction( $i + 1, $i ) );
+ for ( $i = 0; $i < 10; $i++ ) {
+ $this->assertEquals( 'WfGetCallerTest::intermediateFunction', self::intermediateFunction( $i + 1, $i ) );
+ }
}
}
-
diff --git a/tests/phpunit/includes/GlobalFunctions/wfParseUrlTest.php b/tests/phpunit/includes/GlobalFunctions/wfParseUrlTest.php
new file mode 100644
index 00000000..5032dc11
--- /dev/null
+++ b/tests/phpunit/includes/GlobalFunctions/wfParseUrlTest.php
@@ -0,0 +1,146 @@
+<?php
+/**
+ * Copyright © 2013 Alexandre Emsenhuber
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+/**
+ * @covers ::wfParseUrl
+ */
+class WfParseUrlTest extends MediaWikiTestCase {
+ protected function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( 'wgUrlProtocols', array(
+ '//', 'http://', 'file://', 'mailto:',
+ ) );
+ }
+
+ /**
+ * @dataProvider provideURLs
+ */
+ public function testWfParseUrl( $url, $parts ) {
+ $partsDump = var_export( $parts, true );
+ $this->assertEquals(
+ $parts,
+ wfParseUrl( $url ),
+ "Testing $url parses to $partsDump"
+ );
+ }
+
+ /**
+ * Provider of URLs for testing wfParseUrl()
+ *
+ * @return array
+ */
+ public static function provideURLs() {
+ return array(
+ array(
+ '//example.org',
+ array(
+ 'scheme' => '',
+ 'delimiter' => '//',
+ 'host' => 'example.org',
+ )
+ ),
+ array(
+ 'http://example.org',
+ array(
+ 'scheme' => 'http',
+ 'delimiter' => '://',
+ 'host' => 'example.org',
+ )
+ ),
+ array(
+ 'http://id:key@example.org:123/path?foo=bar#baz',
+ array(
+ 'scheme' => 'http',
+ 'delimiter' => '://',
+ 'user' => 'id',
+ 'pass' => 'key',
+ 'host' => 'example.org',
+ 'port' => 123,
+ 'path' => '/path',
+ 'query' => 'foo=bar',
+ 'fragment' => 'baz',
+ )
+ ),
+ array(
+ 'file://example.org/etc/php.ini',
+ array(
+ 'scheme' => 'file',
+ 'delimiter' => '://',
+ 'host' => 'example.org',
+ 'path' => '/etc/php.ini',
+ )
+ ),
+ array(
+ 'file:///etc/php.ini',
+ array(
+ 'scheme' => 'file',
+ 'delimiter' => '://',
+ 'host' => '',
+ 'path' => '/etc/php.ini',
+ )
+ ),
+ array(
+ 'file:///c:/',
+ array(
+ 'scheme' => 'file',
+ 'delimiter' => '://',
+ 'host' => '',
+ 'path' => '/c:/',
+ )
+ ),
+ array(
+ 'mailto:id@example.org',
+ array(
+ 'scheme' => 'mailto',
+ 'delimiter' => ':',
+ 'host' => 'id@example.org',
+ 'path' => '',
+ )
+ ),
+ array(
+ 'mailto:id@example.org?subject=Foo',
+ array(
+ 'scheme' => 'mailto',
+ 'delimiter' => ':',
+ 'host' => 'id@example.org',
+ 'path' => '',
+ 'query' => 'subject=Foo',
+ )
+ ),
+ array(
+ 'mailto:?subject=Foo',
+ array(
+ 'scheme' => 'mailto',
+ 'delimiter' => ':',
+ 'host' => '',
+ 'path' => '',
+ 'query' => 'subject=Foo',
+ )
+ ),
+ array(
+ 'invalid://test/',
+ false
+ ),
+ );
+ }
+}
diff --git a/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php b/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php
index 1cf0e0fb..238a2c9c 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php
@@ -1,10 +1,11 @@
<?php
/**
- * Unit tests for wfRemoveDotSegments()
+ *@covers ::wfRemoveDotSegments
*/
-
-class wfRemoveDotSegments extends MediaWikiTestCase {
- /** @dataProvider providePaths */
+class WfRemoveDotSegmentsTest extends MediaWikiTestCase {
+ /**
+ * @dataProvider providePaths
+ */
public function testWfRemoveDotSegments( $inputPath, $outputPath ) {
$this->assertEquals(
$outputPath,
@@ -18,7 +19,7 @@ class wfRemoveDotSegments extends MediaWikiTestCase {
*
* @return array
*/
- public function providePaths() {
+ public static function providePaths() {
return array(
array( '/a/b/c/./../../g', '/a/g' ),
array( 'mid/content=5/../6', 'mid/6' ),
diff --git a/tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php b/tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php
index 1df26d2c..aadec87f 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php
@@ -1,10 +1,13 @@
<?php
-class wfShorthandToIntegerTest extends MediaWikiTestCase {
+/**
+ * @covers ::wfShorthandToInteger
+ */
+class WfShorthandToIntegerTest extends MediaWikiTestCase {
/**
* @dataProvider provideABunchOfShorthands
*/
- function testWfShorthandToInteger( $input, $output, $description ) {
+ public function testWfShorthandToInteger( $input, $output, $description ) {
$this->assertEquals(
wfShorthandToInteger( $input ),
$output,
@@ -12,7 +15,7 @@ class wfShorthandToIntegerTest extends MediaWikiTestCase {
);
}
- function provideABunchOfShorthands() {
+ public static function provideABunchOfShorthands() {
return array(
array( '', -1, 'Empty string' ),
array( ' ', -1, 'String of spaces' ),
@@ -24,5 +27,4 @@ class wfShorthandToIntegerTest extends MediaWikiTestCase {
array( '1k', 1024, 'One kb lowercased' ),
);
}
-
}
diff --git a/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php b/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php
index 505c28c7..5998f186 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php
@@ -1,19 +1,19 @@
<?php
-
/*
- * Tests for wfTimestamp()
+ * @covers ::wfTimestamp
*/
-class wfTimestamp extends MediaWikiTestCase {
+class WfTimestampTest extends MediaWikiTestCase {
/**
* @dataProvider provideNormalTimestamps
*/
- function testNormalTimestamps( $input, $format, $output, $desc ) {
+ public function testNormalTimestamps( $input, $format, $output, $desc ) {
$this->assertEquals( $output, wfTimestamp( $format, $input ), $desc );
}
- function provideNormalTimestamps() {
+ public static function provideNormalTimestamps() {
$t = gmmktime( 12, 34, 56, 1, 15, 2001 );
- return array (
+
+ return array(
// TS_UNIX
array( $t, TS_MW, '20010115123456', 'TS_UNIX to TS_MW' ),
array( -30281104, TS_MW, '19690115123456', 'Negative TS_UNIX to TS_MW' ),
@@ -21,13 +21,13 @@ class wfTimestamp extends MediaWikiTestCase {
array( $t, TS_DB, '2001-01-15 12:34:56', 'TS_UNIX to TS_DB' ),
array( $t, TS_ISO_8601_BASIC, '20010115T123456Z', 'TS_ISO_8601_BASIC to TS_DB' ),
-
+
// TS_MW
array( '20010115123456', TS_MW, '20010115123456', 'TS_MW to TS_MW' ),
array( '20010115123456', TS_UNIX, 979562096, 'TS_MW to TS_UNIX' ),
array( '20010115123456', TS_DB, '2001-01-15 12:34:56', 'TS_MW to TS_DB' ),
array( '20010115123456', TS_ISO_8601_BASIC, '20010115T123456Z', 'TS_MW to TS_ISO_8601_BASIC' ),
-
+
// TS_DB
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' ),
@@ -57,12 +57,12 @@ class wfTimestamp extends MediaWikiTestCase {
* See r74778 and bug 25451
* @dataProvider provideOldTimestamps
*/
- function testOldTimestamps( $input, $format, $output, $desc ) {
+ public function testOldTimestamps( $input, $format, $output, $desc ) {
$this->assertEquals( $output, wfTimestamp( $format, $input ), $desc );
}
- function provideOldTimestamps() {
- return array (
+ 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( '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' ),
@@ -96,11 +96,11 @@ class wfTimestamp extends MediaWikiTestCase {
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
* @dataProvider provideHttpDates
*/
- function testHttpDate( $input, $output, $desc ) {
+ public function testHttpDate( $input, $output, $desc ) {
$this->assertEquals( $output, wfTimestamp( TS_MW, $input ), $desc );
}
- function provideHttpDates() {
+ public static function provideHttpDates() {
return array(
array( 'Sun, 06 Nov 1994 08:49:37 GMT', '19941106084937', 'RFC 822 date' ),
array( 'Sunday, 06-Nov-94 08:49:37 GMT', '19941106084937', 'RFC 850 date' ),
@@ -114,9 +114,9 @@ class wfTimestamp extends MediaWikiTestCase {
* There are a number of assumptions in our codebase where wfTimestamp()
* should give the current date but it is not given a 0 there. See r71751 CR
*/
- function testTimestampParameter() {
+ public function testTimestampParameter() {
$now = wfTimestamp( TS_UNIX );
- // We check that wfTimestamp doesn't return false (error) and use a LessThan assert
+ // We check that wfTimestamp doesn't return false (error) and use a LessThan assert
// for the cases where the test is run in a second boundary.
$zero = wfTimestamp( TS_UNIX, 0 );
diff --git a/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php b/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php
index cd1a8dbd..ce6c82c5 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php
@@ -1,26 +1,27 @@
<?php
/**
- * Tests for includes/GlobalFunctions.php -> wfUrlencode()
- *
* The function only need a string parameter and might react to IIS7.0
+ * @covers ::wfUrlencode
*/
-
-class wfUrlencodeTest extends MediaWikiTestCase {
-
+class WfUrlencodeTest extends MediaWikiTestCase {
#### TESTS ##############################################################
-
- /** @dataProvider provideURLS */
+
+ /**
+ * @dataProvider provideURLS
+ */
public function testEncodingUrlWith( $input, $expected ) {
$this->verifyEncodingFor( 'Apache', $input, $expected );
}
- /** @dataProvider provideURLS */
+ /**
+ * @dataProvider provideURLS
+ */
public function testEncodingUrlWithMicrosoftIis7( $input, $expected ) {
$this->verifyEncodingFor( 'Microsoft-IIS/7', $input, $expected );
}
#### HELPERS #############################################################
-
+
/**
* Internal helper that actually run the test.
* Called by the public methods testEncodingUrlWith...()
@@ -30,10 +31,9 @@ class wfUrlencodeTest extends MediaWikiTestCase {
$expected = $this->extractExpect( $server, $expectations );
// save up global
- $old = isset($_SERVER['SERVER_SOFTWARE'])
+ $old = isset( $_SERVER['SERVER_SOFTWARE'] )
? $_SERVER['SERVER_SOFTWARE']
- : null
- ;
+ : null;
$_SERVER['SERVER_SOFTWARE'] = $server;
wfUrlencode( null );
@@ -45,7 +45,7 @@ class wfUrlencodeTest extends MediaWikiTestCase {
);
// restore global
- if( $old === null ) {
+ if ( $old === null ) {
unset( $_SERVER['SERVER_SOFTWARE'] );
} else {
$_SERVER['SERVER_SOFTWARE'] = $old;
@@ -58,19 +58,18 @@ class wfUrlencodeTest extends MediaWikiTestCase {
* the HTTP server name.
*/
private function extractExpect( $server, $expectations ) {
- if( is_string( $expectations ) ) {
+ if ( is_string( $expectations ) ) {
return $expectations;
- } elseif( is_array( $expectations ) ) {
- if( !array_key_exists( $server, $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" );
} else {
return $expectations[$server];
}
- } else {
+ } else {
throw new MWException( __METHOD__ . " given invalid expectation for '$server'. Should be a string or an array( <http server name> => <string> ).\n" );
- }
- }
-
+ }
+ }
#### PROVIDERS ###########################################################
@@ -83,11 +82,11 @@ class wfUrlencodeTest extends MediaWikiTestCase {
* array( 'Microsoft-IIS/7', 'expected' ),
* ),
* If you want to add other HTTP server name, you will have to add a new
- * testing method much like the testEncodingUrlWith() method above.
+ * testing method much like the testEncodingUrlWith() method above.
*/
- public function provideURLS() {
+ public static function provideURLS() {
return array(
- ### RFC 1738 chars
+ ### RFC 1738 chars
// + is not safe
array( '+', '%2B' ),
// & and = not safe in queries
@@ -95,7 +94,7 @@ class wfUrlencodeTest extends MediaWikiTestCase {
array( '=', '%3D' ),
array( ':', array(
- 'Apache' => ':',
+ 'Apache' => ':',
'Microsoft-IIS/7' => '%3A',
) ),
@@ -105,10 +104,10 @@ class wfUrlencodeTest extends MediaWikiTestCase {
';@$-_.!*',
),
- ### Other tests
+ ### Other tests
// slash remain unchanged. %2F seems to break things
array( '/', '/' ),
-
+
// Other 'funnies' chars
array( '[]', '%5B%5D' ),
array( '<>', '%3C%3E' ),