Addshore has uploaded a new change for review.
https://gerrit.wikimedia.org/r/91582
Change subject: @covers for all GlobalFunc tests
......................................................................
@covers for all GlobalFunc tests
Also split 2 tests off into their correct test classes,
this methods are clearly no longer global functions
Change-Id: I482433f3099e72507a766e85d9576ff36e58b9ad
---
A tests/phpunit/includes/FallbackTest.php
M tests/phpunit/includes/GlobalFunctions/GlobalTest.php
M tests/phpunit/includes/GlobalFunctions/GlobalWithDBTest.php
M tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php
M tests/phpunit/includes/GlobalFunctions/wfBCP47Test.php
M tests/phpunit/includes/GlobalFunctions/wfBaseConvertTest.php
M tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php
M tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php
M tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php
M tests/phpunit/includes/GlobalFunctions/wfParseUrlTest.php
M tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php
M tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php
M tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php
M tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php
A tests/phpunit/includes/UserMailerTest.php
15 files changed, 176 insertions(+), 91 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/82/91582/1
diff --git a/tests/phpunit/includes/FallbackTest.php
b/tests/phpunit/includes/FallbackTest.php
new file mode 100644
index 0000000..6900126
--- /dev/null
+++ b/tests/phpunit/includes/FallbackTest.php
@@ -0,0 +1,73 @@
+<?php
+
+/**
+ * @covers Fallback
+ */
+class FallbackTest extends MediaWikiTestCase {
+
+ public 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(
+ call_user_func_array( 'mb_substr', $param_set ),
+ call_user_func_array( '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(
+ call_user_func_array( 'mb_strpos', $param_set ),
+ call_user_func_array( 'Fallback::mb_strpos',
$param_set ),
+ 'Fallback mb_strpos with params ' . implode( ',
', $old_param_set )
+ );
+
+ $this->assertEquals(
+ call_user_func_array( 'mb_strrpos', $param_set
),
+ call_user_func_array( 'Fallback::mb_strrpos',
$param_set ),
+ 'Fallback mb_strrpos with params ' . implode(
', ', $old_param_set )
+ );
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php
b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php
index 9b71999..6154df1 100644
--- a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php
@@ -29,7 +29,10 @@
parent::tearDown();
}
- /** @dataProvider provideForWfArrayDiff2 */
+ /**
+ * @dataProvider provideForWfArrayDiff2
+ * @covers ::wfArrayDiff2
+ */
public function testWfArrayDiff2( $a, $b, $expected ) {
$this->assertEquals(
wfArrayDiff2( $a, $b ), $expected
@@ -53,24 +56,36 @@
);
}
+ /**
+ * @covers ::wfRandom
+ */
public function testRandom() {
# This could hypothetically fail, but it shouldn't ;)
$this->assertFalse(
wfRandom() == wfRandom() );
}
+ /**
+ * @covers ::wfUrlencode
+ */
public function testUrlencode() {
$this->assertEquals(
"%E7%89%B9%E5%88%A5:Contributions/Foobar",
wfUrlencode(
"\xE7\x89\xB9\xE5\x88\xA5:Contributions/Foobar" ) );
}
+ /**
+ * @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"
) );
}
+ /**
+ * @covers ::wfReadOnly
+ */
public function testReadOnlyEmpty() {
global $wgReadOnly;
$wgReadOnly = null;
@@ -79,6 +94,9 @@
$this->assertFalse( wfReadOnly() );
}
+ /**
+ * @covers ::wfReadOnly
+ */
public function testReadOnlySet() {
global $wgReadOnly, $wgReadOnlyFile;
@@ -95,12 +113,6 @@
$this->assertFalse( wfReadOnly() );
$this->assertFalse( wfReadOnly() );
- }
-
- public function testQuotedPrintable() {
- $this->assertEquals(
- "=?UTF-8?Q?=C4=88u=20legebla=3F?=",
- UserMailer::quotedPrintable( "\xc4\x88u legebla?",
"UTF-8" ) );
}
public static function provideArrayToCGI() {
@@ -123,12 +135,16 @@
/**
* @dataProvider provideArrayToCGI
+ * @covers ::wfArrayToCgi
*/
public function testArrayToCGI( $array, $result ) {
$this->assertEquals( $result, wfArrayToCgi( $array ) );
}
+ /**
+ * @covers ::testWfArrayDiff2
+ */
public function testArrayToCGI2() {
$this->assertEquals(
"baz=bar&foo=bar",
@@ -154,6 +170,7 @@
/**
* @dataProvider provideCgiToArray
+ * @covers ::wfCgiToArray
*/
public function testCgiToArray( $cgi, $result ) {
$this->assertEquals( $result, wfCgiToArray( $cgi ) );
@@ -174,11 +191,15 @@
/**
* @dataProvider provideCgiRoundTrip
+ * @covers ::wfArrayToCgi
*/
public function testCgiRoundTrip( $cgi ) {
$this->assertEquals( $cgi, wfArrayToCgi( wfCgiToArray( $cgi ) )
);
}
+ /**
+ * @covers ::mimeTypeMatch
+ */
public function testMimeTypeMatch() {
$this->assertEquals(
'text/html',
@@ -201,6 +222,9 @@
'image/svg+xml' => 0.5 ) ) );
}
+ /**
+ * @covers ::wfNegotiateType
+ */
public function testNegotiateType() {
$this->assertEquals(
'text/html',
@@ -242,72 +266,10 @@
array( 'application/xhtml+xml' => 1.0 ) ) );
}
- public 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(
- call_user_func_array( 'mb_substr', $param_set ),
- call_user_func_array( '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(
- call_user_func_array( 'mb_strpos', $param_set ),
- call_user_func_array( 'Fallback::mb_strpos',
$param_set ),
- 'Fallback mb_strpos with params ' . implode( ',
', $old_param_set )
- );
-
- $this->assertEquals(
- call_user_func_array( 'mb_strrpos', $param_set
),
- call_user_func_array( 'Fallback::mb_strrpos',
$param_set ),
- 'Fallback mb_strrpos with params ' . implode(
', ', $old_param_set )
- );
- }
- }
-
-
+ /**
+ * @covers ::wfDebug
+ * @covers ::wfDebugMem
+ */
public function testDebugFunctionTest() {
global $wgDebugLogFile, $wgDebugTimestamps;
@@ -342,6 +304,9 @@
$wgDebugTimestamps = $old_wgDebugTimestamps;
}
+ /**
+ * @covers ::wfClientAcceptsGzip
+ */
public function testClientAcceptsGzipTest() {
$settings = array(
@@ -373,6 +338,9 @@
}
}
+ /**
+ * @covers ::swap
+ */
public function testSwapVarsTest() {
$var1 = 1;
$var2 = 2;
@@ -386,6 +354,9 @@
$this->assertEquals( $var2, 1, 'var2 is swapped' );
}
+ /**
+ * @covers ::wfPercent
+ */
public function testWfPercentTest() {
$pcts = array(
@@ -414,6 +385,7 @@
/**
* test @see wfShorthandToInteger()
* @dataProvider provideShorthand
+ * @covers ::wfShorthandToInteger
*/
public function testWfShorthandToInteger( $shorthand, $expected ) {
$this->assertEquals( $expected,
@@ -474,6 +446,7 @@
*
* @dataProvider provideMerge()
* @group medium
+ * @covers ::wfMerge
*/
public function testMerge( $old, $mine, $yours, $expectedMergeResult,
$expectedText ) {
$this->checkHasDiff3();
@@ -549,6 +522,7 @@
/**
* @dataProvider provideMakeUrlIndexes()
+ * @covers ::wfMakeUrlIndexes
*/
public function testMakeUrlIndexes( $url, $expected ) {
$index = wfMakeUrlIndexes( $url );
@@ -606,6 +580,7 @@
/**
* @dataProvider provideWfMatchesDomainList
+ * @covers ::wfMatchesDomainList
*/
public function testWfMatchesDomainList( $url, $domains, $expected,
$description ) {
$actual = wfMatchesDomainList( $url, $domains );
@@ -630,6 +605,9 @@
return $a;
}
+ /**
+ * @covers ::wfMkdirParents
+ */
public function testWfMkdirParents() {
// Should not return true if file exists instead of directory
$fname = $this->getNewTempFile();
@@ -641,6 +619,7 @@
/**
* @dataProvider provideWfShellMaintenanceCmdList
+ * @covers ::wfShellMaintenanceCmd
*/
public function testWfShellMaintenanceCmd( $script, $parameters,
$options, $expected, $description ) {
if ( wfIsWindows() ) {
@@ -669,5 +648,5 @@
"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 8d15296..cf891e7 100644
--- a/tests/phpunit/includes/GlobalFunctions/GlobalWithDBTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/GlobalWithDBTest.php
@@ -6,6 +6,7 @@
class GlobalWithDBTest extends MediaWikiTestCase {
/**
* @dataProvider provideWfIsBadImageList
+ * @covers ::wfIsBadImage
*/
public function testWfIsBadImage( $name, $title, $blacklist, $expected,
$desc ) {
$this->assertEquals( $expected, wfIsBadImage( $name, $title,
$blacklist ), $desc );
diff --git a/tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php
b/tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php
index 4184d15..9bb7487 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php
@@ -1,9 +1,11 @@
<?php
/**
- * Tests for wfAssembleUrl()
+ * @covers ::wfAssembleUrl
*/
class WfAssembleUrlTest extends MediaWikiTestCase {
- /** @dataProvider provideURLParts */
+ /**
+ * @dataProvider provideURLParts
+ */
public function testWfAssembleUrl( $parts, $output ) {
$partsDump = print_r( $parts, true );
$this->assertEquals(
diff --git a/tests/phpunit/includes/GlobalFunctions/wfBCP47Test.php
b/tests/phpunit/includes/GlobalFunctions/wfBCP47Test.php
index def443c..a01c0d4 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfBCP47Test.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfBCP47Test.php
@@ -1,6 +1,6 @@
<?php
/**
- * Tests for wfBCP47()
+ * @covers ::wfBCP47
*/
class WfBCP47Test extends MediaWikiTestCase {
/**
diff --git a/tests/phpunit/includes/GlobalFunctions/wfBaseConvertTest.php
b/tests/phpunit/includes/GlobalFunctions/wfBaseConvertTest.php
index c60f223..7da804e 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfBaseConvertTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfBaseConvertTest.php
@@ -1,6 +1,6 @@
<?php
/**
- * Tests for wfBaseConvert()
+ * @covers ::wfBaseConvert
*/
class WfBaseConvertTest extends MediaWikiTestCase {
public static function provideSingleDigitConversions() {
diff --git a/tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php
b/tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php
index be2b222..8c54804 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php
@@ -1,6 +1,6 @@
<?php
/**
- * Tests for wfBaseName()
+ * @covers ::wfBaseName
*/
class WfBaseNameTest extends MediaWikiTestCase {
/**
diff --git a/tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php
b/tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php
index 5b622c1..41230a1 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php
@@ -1,9 +1,11 @@
<?php
/**
- * Tests for wfExpandUrl()
+ * @covers ::wfExpandUrl
*/
class WfExpandUrlTest extends MediaWikiTestCase {
- /** @dataProvider provideExpandableUrls */
+ /**
+ * @dataProvider provideExpandableUrls
+ */
public function testWfExpandUrl( $fullUrl, $shortUrl, $defaultProto,
$server, $canServer, $httpsMode, $message ) {
// Fake $wgServer and $wgCanonicalServer
$this->setMwGlobals( array(
diff --git a/tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php
b/tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php
index a148815..6229624 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php
@@ -1,5 +1,8 @@
<?php
+/**
+ * @covers ::wfGetCaller
+ */
class WfGetCallerTest extends MediaWikiTestCase {
public function testZero() {
diff --git a/tests/phpunit/includes/GlobalFunctions/wfParseUrlTest.php
b/tests/phpunit/includes/GlobalFunctions/wfParseUrlTest.php
index 841a1b1..5032dc1 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfParseUrlTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfParseUrlTest.php
@@ -1,7 +1,5 @@
<?php
/**
- * Tests for wfParseUrl()
- *
* Copyright © 2013 Alexandre Emsenhuber
*
* This program is free software; you can redistribute it and/or modify
@@ -22,6 +20,9 @@
* @file
*/
+/**
+ * @covers ::wfParseUrl
+ */
class WfParseUrlTest extends MediaWikiTestCase {
protected function setUp() {
parent::setUp();
@@ -31,7 +32,9 @@
) );
}
- /** @dataProvider provideURLs */
+ /**
+ * @dataProvider provideURLs
+ */
public function testWfParseUrl( $url, $parts ) {
$partsDump = var_export( $parts, true );
$this->assertEquals(
diff --git a/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php
b/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php
index 67861ee..238a2c9 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php
@@ -1,9 +1,11 @@
<?php
/**
- * Tests for wfRemoveDotSegments()
+ *@covers ::wfRemoveDotSegments
*/
class WfRemoveDotSegmentsTest extends MediaWikiTestCase {
- /** @dataProvider providePaths */
+ /**
+ * @dataProvider providePaths
+ */
public function testWfRemoveDotSegments( $inputPath, $outputPath ) {
$this->assertEquals(
$outputPath,
diff --git
a/tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php
b/tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php
index 485a362..aadec87 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php
@@ -1,5 +1,8 @@
<?php
+/**
+ * @covers ::wfShorthandToInteger
+ */
class WfShorthandToIntegerTest extends MediaWikiTestCase {
/**
* @dataProvider provideABunchOfShorthands
diff --git a/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php
b/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php
index 4198322..5998f18 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php
@@ -1,6 +1,6 @@
<?php
/*
- * Tests for wfTimestamp()
+ * @covers ::wfTimestamp
*/
class WfTimestampTest extends MediaWikiTestCase {
/**
diff --git a/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php
b/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php
index 77685d5..ce6c82c 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php
@@ -1,18 +1,21 @@
<?php
/**
- * Tests for wfUrlencode()
- *
* The function only need a string parameter and might react to IIS7.0
+ * @covers ::wfUrlencode
*/
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
);
}
diff --git a/tests/phpunit/includes/UserMailerTest.php
b/tests/phpunit/includes/UserMailerTest.php
new file mode 100644
index 0000000..8be1d9f
--- /dev/null
+++ b/tests/phpunit/includes/UserMailerTest.php
@@ -0,0 +1,14 @@
+<?php
+
+class TestSample extends MediaWikiLangTestCase {
+
+ /**
+ * @covers UserMailer::quotedPrintable
+ */
+ public function testQuotedPrintable() {
+ $this->assertEquals(
+ "=?UTF-8?Q?=C4=88u=20legebla=3F?=",
+ UserMailer::quotedPrintable( "\xc4\x88u legebla?",
"UTF-8" ) );
+ }
+
+}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/91582
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I482433f3099e72507a766e85d9576ff36e58b9ad
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits