aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit
diff options
context:
space:
mode:
authordaniel <daniel.kinzler@wikimedia.de>2012-08-29 10:07:10 +0200
committerdaniel <daniel.kinzler@wikimedia.de>2012-08-29 15:20:15 +0200
commit9994968774d44ea5138ba1e324349e048d54f12a (patch)
tree8472cf5465268af69dc3daa658d01c2f4b7d055c /tests/phpunit
parent4736034866f3c1cbda172943348fc396e9a54726 (diff)
downloadmediawikicore-9994968774d44ea5138ba1e324349e048d54f12a.tar.gz
mediawikicore-9994968774d44ea5138ba1e324349e048d54f12a.zip
merged master
Change-Id: Ib2b879c4daa17401eeeb50767c0e5a54254855c3
Diffstat (limited to 'tests/phpunit')
-rw-r--r--tests/phpunit/MediaWikiPHPUnitCommand.php2
-rw-r--r--tests/phpunit/MediaWikiTestCase.php9
-rw-r--r--tests/phpunit/bootstrap.php2
-rw-r--r--tests/phpunit/data/media/exif-gps.jpgbin665 -> 665 bytes
-rw-r--r--tests/phpunit/includes/ExtraParserTest.php2
-rw-r--r--tests/phpunit/includes/GlobalFunctions/GlobalTest.php30
-rw-r--r--tests/phpunit/includes/MockOutputPage.php10
-rw-r--r--tests/phpunit/includes/RevisionStorageTest.php1
-rw-r--r--tests/phpunit/includes/TemplateCategoriesTest.php2
-rw-r--r--tests/phpunit/includes/ZipDirectoryReaderTest.php2
-rw-r--r--tests/phpunit/includes/api/ApiEditPageTest.php77
-rw-r--r--tests/phpunit/includes/api/ApiTestCase.php10
-rw-r--r--tests/phpunit/includes/api/RandomImageGenerator.php2
-rw-r--r--tests/phpunit/includes/api/generateRandomImages.php4
-rw-r--r--tests/phpunit/includes/db/DatabaseSQLTest.php38
-rw-r--r--tests/phpunit/includes/db/TestORMRowTest.php2
-rw-r--r--tests/phpunit/includes/filerepo/FileBackendTest.php46
-rw-r--r--tests/phpunit/includes/libs/GenericArrayObjectTest.php3
-rw-r--r--tests/phpunit/includes/media/BitmapMetadataHandlerTest.php2
-rw-r--r--tests/phpunit/includes/media/ExifRotationTest.php2
-rw-r--r--tests/phpunit/includes/media/ExifTest.php4
-rw-r--r--tests/phpunit/includes/media/FormatMetadataTest.php2
-rw-r--r--tests/phpunit/includes/media/GIFMetadataExtractorTest.php2
-rw-r--r--tests/phpunit/includes/media/GIFTest.php2
-rw-r--r--tests/phpunit/includes/media/JpegMetadataExtractorTest.php2
-rw-r--r--tests/phpunit/includes/media/JpegTest.php2
-rw-r--r--tests/phpunit/includes/media/PNGMetadataExtractorTest.php2
-rw-r--r--tests/phpunit/includes/media/PNGTest.php2
-rw-r--r--tests/phpunit/includes/media/SVGMetadataExtractorTest.php24
-rw-r--r--tests/phpunit/includes/media/TiffTest.php2
-rw-r--r--tests/phpunit/includes/media/XMPTest.php11
-rw-r--r--tests/phpunit/includes/parser/MediaWikiParserTest.php2
-rw-r--r--tests/phpunit/includes/parser/PreprocessorTest.php4
-rw-r--r--tests/phpunit/includes/upload/UploadStashTest.php2
-rw-r--r--tests/phpunit/languages/LanguageHeTest.php14
-rw-r--r--tests/phpunit/languages/LanguageSrTest.php2
-rw-r--r--tests/phpunit/languages/LanguageUzTest.php2
-rw-r--r--tests/phpunit/maintenance/backupPrefetchTest.php2
-rw-r--r--tests/phpunit/maintenance/backupTextPassTest.php2
-rw-r--r--tests/phpunit/maintenance/fetchTextTest.php2
-rw-r--r--tests/phpunit/maintenance/getSlaveServerTest.php2
-rwxr-xr-xtests/phpunit/phpunit.php6
-rw-r--r--tests/phpunit/suites/UploadFromUrlTestSuite.php2
43 files changed, 174 insertions, 169 deletions
diff --git a/tests/phpunit/MediaWikiPHPUnitCommand.php b/tests/phpunit/MediaWikiPHPUnitCommand.php
index ea385ad9b274..fca325154ae3 100644
--- a/tests/phpunit/MediaWikiPHPUnitCommand.php
+++ b/tests/phpunit/MediaWikiPHPUnitCommand.php
@@ -37,7 +37,7 @@ class MediaWikiPHPUnitCommand extends PHPUnit_TextUI_Command {
# PHPUnit uses stream_resolve_include_path() internally
# See bug 32022
set_include_path(
- dirname( __FILE__ )
+ __DIR__
.PATH_SEPARATOR
. get_include_path()
);
diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php
index 2fb2d00cb962..3debb35055bd 100644
--- a/tests/phpunit/MediaWikiTestCase.php
+++ b/tests/phpunit/MediaWikiTestCase.php
@@ -115,7 +115,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
}
protected function tearDown() {
- // Cleaning up temoporary files
+ // Cleaning up temporary files
foreach ( $this->tmpfiles as $fname ) {
if ( is_file( $fname ) || ( is_link( $fname ) ) ) {
unlink( $fname );
@@ -124,6 +124,13 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
}
}
+ // clean up open transactions
+ if( $this->needsDB() && $this->db ) {
+ while( $this->db->trxLevel() > 0 ) {
+ $this->db->rollback();
+ }
+ }
+
parent::tearDown();
}
diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/bootstrap.php
index 08eb50f7eba5..933767e7e9b6 100644
--- a/tests/phpunit/bootstrap.php
+++ b/tests/phpunit/bootstrap.php
@@ -11,7 +11,7 @@ if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
You are running these tests directly from phpunit. You may not have all globals correctly set.
Running phpunit.php instead is recommended.
EOF;
- require_once ( dirname( __FILE__ ) . "/phpunit.php" );
+ require_once ( __DIR__ . "/phpunit.php" );
}
// Output a notice when running with older versions of PHPUnit
diff --git a/tests/phpunit/data/media/exif-gps.jpg b/tests/phpunit/data/media/exif-gps.jpg
index f99b484d5ea8..40137340e5e6 100644
--- a/tests/phpunit/data/media/exif-gps.jpg
+++ b/tests/phpunit/data/media/exif-gps.jpg
Binary files differ
diff --git a/tests/phpunit/includes/ExtraParserTest.php b/tests/phpunit/includes/ExtraParserTest.php
index 11a660499f54..903a6d2593ed 100644
--- a/tests/phpunit/includes/ExtraParserTest.php
+++ b/tests/phpunit/includes/ExtraParserTest.php
@@ -148,7 +148,7 @@ class ExtraParserTest extends MediaWikiTestCase {
*/
function testTrackingCategory() {
$title = Title::newFromText( __FUNCTION__ );
- $catName = wfMsgForContent( 'broken-file-category' );
+ $catName = wfMessage( 'broken-file-category' )->inContentLanguage()->text();
$cat = Title::makeTitleSafe( NS_CATEGORY, $catName );
$expected = array( $cat->getDBkey() );
$parserOutput = $this->parser->parse( "[[file:nonexistent]]" , $title, $this->options );
diff --git a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php
index 746add5b5259..129f271bf06a 100644
--- a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php
@@ -311,7 +311,7 @@ class GlobalTest extends MediaWikiTestCase {
function testDebugFunctionTest() {
- global $wgDebugLogFile, $wgOut, $wgShowDebug, $wgDebugTimestamps;
+ global $wgDebugLogFile, $wgDebugTimestamps;
$old_log_file = $wgDebugLogFile;
$wgDebugLogFile = tempnam( wfTempDir(), 'mw-' );
@@ -333,33 +333,7 @@ class GlobalTest extends MediaWikiTestCase {
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 );
-
-
-
- $old_wgOut = $wgOut;
- $old_wgShowDebug = $wgShowDebug;
-
- $wgOut = new MockOutputPage;
-
- $wgShowDebug = true;
-
- $message = "\00305This has böth UTF and control chars\003";
-
- wfDebug( $message );
-
- if( $wgOut->message == "JAJA is a stupid error message. Anyway, here's your message: $message" ) {
- $this->assertTrue( true, 'MockOutputPage called, set the proper message.' );
- }
- else {
- $this->assertTrue( false, 'MockOutputPage was not called.' );
- }
-
- $wgOut = $old_wgOut;
- $wgShowDebug = $old_wgShowDebug;
- unlink( $wgDebugLogFile );
-
-
-
+
wfDebugMem();
$this->assertGreaterThan( 5000, preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) ) );
unlink( $wgDebugLogFile );
diff --git a/tests/phpunit/includes/MockOutputPage.php b/tests/phpunit/includes/MockOutputPage.php
deleted file mode 100644
index bdee4832bf26..000000000000
--- a/tests/phpunit/includes/MockOutputPage.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-class MockOutputPage {
-
- public $message;
-
- function debug( $message ) {
- $this->message = "JAJA is a stupid error message. Anyway, here's your message: $message";
- }
-}
diff --git a/tests/phpunit/includes/RevisionStorageTest.php b/tests/phpunit/includes/RevisionStorageTest.php
index 576e78175b05..02b13b96a6d3 100644
--- a/tests/phpunit/includes/RevisionStorageTest.php
+++ b/tests/phpunit/includes/RevisionStorageTest.php
@@ -269,7 +269,6 @@ class RevisionStorageTest extends MediaWikiTestCase {
public function testRevText()
{
$this->hideDeprecated( 'Revision::revText' );
-
$orig = $this->makeRevision( array( 'text' => 'hello hello rev.' ) );
$rev = Revision::newFromId( $orig->getId() );
diff --git a/tests/phpunit/includes/TemplateCategoriesTest.php b/tests/phpunit/includes/TemplateCategoriesTest.php
index 38ca85eb0aad..03b94aea7f1d 100644
--- a/tests/phpunit/includes/TemplateCategoriesTest.php
+++ b/tests/phpunit/includes/TemplateCategoriesTest.php
@@ -3,7 +3,7 @@
/**
* @group Database
*/
-require dirname( __FILE__ ) . "/../../../maintenance/runJobs.php";
+require __DIR__ . "/../../../maintenance/runJobs.php";
class TemplateCategoriesTest extends MediaWikiLangTestCase {
diff --git a/tests/phpunit/includes/ZipDirectoryReaderTest.php b/tests/phpunit/includes/ZipDirectoryReaderTest.php
index f7ca59e241cc..d90a69509591 100644
--- a/tests/phpunit/includes/ZipDirectoryReaderTest.php
+++ b/tests/phpunit/includes/ZipDirectoryReaderTest.php
@@ -4,7 +4,7 @@ class ZipDirectoryReaderTest extends MediaWikiTestCase {
var $zipDir, $entries;
function setUp() {
- $this->zipDir = dirname( __FILE__ ) . '/../data/zip';
+ $this->zipDir = __DIR__ . '/../data/zip';
}
function zipCallback( $entry ) {
diff --git a/tests/phpunit/includes/api/ApiEditPageTest.php b/tests/phpunit/includes/api/ApiEditPageTest.php
index 2de8efd45ed5..5297d6daa73b 100644
--- a/tests/phpunit/includes/api/ApiEditPageTest.php
+++ b/tests/phpunit/includes/api/ApiEditPageTest.php
@@ -1,7 +1,10 @@
<?php
/**
- * @group Editing
+ * Tests for MediaWiki api.php?action=edit.
+ *
+ * @author Daniel Kinzler
+ *
* @group API
* @group Database
*/
@@ -12,70 +15,42 @@ class ApiEditPageTest extends ApiTestCase {
$this->doLogin();
}
- function getTokens() {
- return $this->getTokenList( self::$users['sysop'] );
- }
-
- function testEdit() {
+ function testEdit( ) {
$name = 'ApiEditPageTest_testEdit';
- $tokenData = $this->getTokens();
-
- if( !isset( $tokenData[0]['query']['pages'] ) ) {
- $this->markTestIncomplete( "No edit token found" );
- }
-
- $keys = array_keys( $tokenData[0]['query']['pages'] );
- $key = array_pop( $keys );
- $pageinfo = $tokenData[0]['query']['pages'][$key];
- $session = $tokenData[2];
-
- // -----------------------------------------------------------------------
-
- $data = $this->doApiRequest( array(
+ // -- test new page --------------------------------------------
+ $apiResult = $this->doApiRequestWithToken( array(
'action' => 'edit',
'title' => $name,
- 'text' => 'some text',
- 'token' => $pageinfo['edittoken'] ),
- $session,
- false,
- self::$users['sysop']->user );
-
- $this->assertArrayHasKey( 'edit', $data[0] );
- $this->assertArrayHasKey( 'result', $data[0]['edit'] );
- $this->assertEquals( 'Success', $data[0]['edit']['result'] );
+ 'text' => 'some text', ) );
+ $apiResult = $apiResult[0];
- $this->assertArrayHasKey( 'new', $data[0]['edit'] );
- $this->assertArrayNotHasKey( 'nochange', $data[0]['edit'] );
+ # Validate API result data
+ $this->assertArrayHasKey( 'edit', $apiResult );
+ $this->assertArrayHasKey( 'result', $apiResult['edit'] );
+ $this->assertEquals( 'Success', $apiResult['edit']['result'] );
+
+ $this->assertArrayHasKey( 'new', $apiResult['edit'] );
+ $this->assertArrayNotHasKey( 'nochange', $apiResult['edit'] );
- $this->assertArrayHasKey( 'pageid', $data[0]['edit'] );
- $this->assertArrayHasKey( 'contentmodel', $data[0]['edit'] );
- $this->assertEquals( CONTENT_MODEL_WIKITEXT, $data[0]['edit']['contentmodel'] );
+ $this->assertArrayHasKey( 'pageid', $apiResult['edit'] );
- // -----------------------------------------------------------------------
- $data = $this->doApiRequest( array(
+ // -- test existing page, no change ----------------------------
+ $data = $this->doApiRequestWithToken( array(
'action' => 'edit',
'title' => $name,
- 'text' => 'some text',
- 'token' => $pageinfo['edittoken'] ),
- $session,
- false,
- self::$users['sysop']->user );
+ 'text' => 'some text', ) );
$this->assertEquals( 'Success', $data[0]['edit']['result'] );
$this->assertArrayNotHasKey( 'new', $data[0]['edit'] );
$this->assertArrayHasKey( 'nochange', $data[0]['edit'] );
- // -----------------------------------------------------------------------
- $data = $this->doApiRequest( array(
+ // -- test existing page, with change --------------------------
+ $data = $this->doApiRequestWithToken( array(
'action' => 'edit',
'title' => $name,
- 'text' => 'different text',
- 'token' => $pageinfo['edittoken'] ),
- $session,
- false,
- self::$users['sysop']->user );
+ 'text' => 'different text' ) );
$this->assertEquals( 'Success', $data[0]['edit']['result'] );
@@ -84,7 +59,11 @@ class ApiEditPageTest extends ApiTestCase {
$this->assertArrayHasKey( 'oldrevid', $data[0]['edit'] );
$this->assertArrayHasKey( 'newrevid', $data[0]['edit'] );
- $this->assertTrue( $data[0]['edit']['newrevid'] !== $data[0]['edit']['oldrevid'], "revision id should change after edit" );
+ $this->assertNotEquals(
+ $data[0]['edit']['newrevid'],
+ $data[0]['edit']['oldrevid'],
+ "revision id should change after edit"
+ );
}
function testEditAppend() {
diff --git a/tests/phpunit/includes/api/ApiTestCase.php b/tests/phpunit/includes/api/ApiTestCase.php
index 3b044ef94ba3..d6c48cbd7314 100644
--- a/tests/phpunit/includes/api/ApiTestCase.php
+++ b/tests/phpunit/includes/api/ApiTestCase.php
@@ -85,10 +85,16 @@ abstract class ApiTestCase extends MediaWikiLangTestCase {
* This is cheating a bit -- we grab a token in the correct format and then add it to the pseudo-session and to the
* request, without actually requesting a "real" edit token
* @param $params Array: key-value API params
- * @param $session Array: session array
+ * @param $session Array|null: session array
* @param $user User|null A User object for the context
*/
- protected function doApiRequestWithToken( Array $params, Array $session, User $user = null ) {
+ protected function doApiRequestWithToken( Array $params, Array $session = null, User $user = null ) {
+ global $wgRequest;
+
+ if ( $session === null ) {
+ $session = $wgRequest->getSessionArray();
+ }
+
if ( $session['wsToken'] ) {
// add edit token to fake session
$session['wsEditToken'] = $session['wsToken'];
diff --git a/tests/phpunit/includes/api/RandomImageGenerator.php b/tests/phpunit/includes/api/RandomImageGenerator.php
index 86c0a828fd8c..8b6a3849f65a 100644
--- a/tests/phpunit/includes/api/RandomImageGenerator.php
+++ b/tests/phpunit/includes/api/RandomImageGenerator.php
@@ -79,7 +79,7 @@ class RandomImageGenerator {
foreach ( array(
'/usr/share/dict/words',
'/usr/dict/words',
- dirname( __FILE__ ) . '/words.txt' )
+ __DIR__ . '/words.txt' )
as $dictionaryFile ) {
if ( is_file( $dictionaryFile ) and is_readable( $dictionaryFile ) ) {
$this->dictionaryFile = $dictionaryFile;
diff --git a/tests/phpunit/includes/api/generateRandomImages.php b/tests/phpunit/includes/api/generateRandomImages.php
index b22eccd0981f..ee3456232590 100644
--- a/tests/phpunit/includes/api/generateRandomImages.php
+++ b/tests/phpunit/includes/api/generateRandomImages.php
@@ -6,11 +6,11 @@
*/
// Evaluate the include path relative to this file
-$IP = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) );
+$IP = dirname( dirname( dirname( dirname( __DIR__ ) ) ) );
// Start up MediaWiki in command-line mode
require_once( "$IP/maintenance/Maintenance.php" );
-require( dirname( __FILE__ ) . "/RandomImageGenerator.php" );
+require( __DIR__ . "/RandomImageGenerator.php" );
class GenerateRandomImages extends Maintenance {
diff --git a/tests/phpunit/includes/db/DatabaseSQLTest.php b/tests/phpunit/includes/db/DatabaseSQLTest.php
index d56e632c3051..0df5a460804e 100644
--- a/tests/phpunit/includes/db/DatabaseSQLTest.php
+++ b/tests/phpunit/includes/db/DatabaseSQLTest.php
@@ -16,9 +16,9 @@ class DatabaseSQLTest extends MediaWikiTestCase {
}
/**
- * @dataProvider dataSQL
+ * @dataProvider dataSelectSQLText
*/
- function testSQL( $sql, $sqlText ) {
+ function testSelectSQLText( $sql, $sqlText ) {
$this->assertEquals( trim( $this->db->selectSQLText(
isset( $sql['tables'] ) ? $sql['tables'] : array(),
isset( $sql['fields'] ) ? $sql['fields'] : array(),
@@ -29,7 +29,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
) ), $sqlText );
}
- function dataSQL() {
+ function dataSelectSQLText() {
return array(
array(
array(
@@ -72,4 +72,36 @@ class DatabaseSQLTest extends MediaWikiTestCase {
),
);
}
+
+ /**
+ * @dataProvider dataConditional
+ */
+ function testConditional( $sql, $sqlText ) {
+ $this->assertEquals( trim( $this->db->conditional(
+ $sql['conds'],
+ $sql['true'],
+ $sql['false']
+ ) ), $sqlText );
+ }
+
+ function dataConditional() {
+ return array(
+ array(
+ array(
+ 'conds' => array( 'field' => 'text' ),
+ 'true' => 1,
+ 'false' => 'NULL',
+ ),
+ "(CASE WHEN field = 'text' THEN 1 ELSE NULL END)"
+ ),
+ array(
+ array(
+ 'conds' => 'field=1',
+ 'true' => 1,
+ 'false' => 'NULL',
+ ),
+ "(CASE WHEN field=1 THEN 1 ELSE NULL END)"
+ ),
+ );
+ }
} \ No newline at end of file
diff --git a/tests/phpunit/includes/db/TestORMRowTest.php b/tests/phpunit/includes/db/TestORMRowTest.php
index fe5867af091b..afd1cb803fe1 100644
--- a/tests/phpunit/includes/db/TestORMRowTest.php
+++ b/tests/phpunit/includes/db/TestORMRowTest.php
@@ -38,7 +38,7 @@
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
-require_once dirname( __FILE__ ) . "/ORMRowTest.php";
+require_once __DIR__ . "/ORMRowTest.php";
class TestORMRowTest extends ORMRowTest {
diff --git a/tests/phpunit/includes/filerepo/FileBackendTest.php b/tests/phpunit/includes/filerepo/FileBackendTest.php
index be5e79977a0b..0b36bf1afd9a 100644
--- a/tests/phpunit/includes/filerepo/FileBackendTest.php
+++ b/tests/phpunit/includes/filerepo/FileBackendTest.php
@@ -1150,26 +1150,6 @@ class FileBackendTest extends MediaWikiTestCase {
$this->tearDownFiles();
$this->doTestDoOperations();
$this->tearDownFiles();
-
- $this->backend = $this->singleBackend;
- $this->tearDownFiles();
- $this->doTestDoOperations2();
- $this->tearDownFiles();
-
- $this->backend = $this->multiBackend;
- $this->tearDownFiles();
- $this->doTestDoOperations2();
- $this->tearDownFiles();
-
- $this->backend = $this->singleBackend;
- $this->tearDownFiles();
- $this->doTestDoOperationsFailing();
- $this->tearDownFiles();
-
- $this->backend = $this->multiBackend;
- $this->tearDownFiles();
- $this->doTestDoOperationsFailing();
- $this->tearDownFiles();
}
private function doTestDoOperations() {
@@ -1245,8 +1225,20 @@ class FileBackendTest extends MediaWikiTestCase {
"Correct file SHA-1 of $fileC" );
}
+ public function testDoOperationsPipeline() {
+ $this->backend = $this->singleBackend;
+ $this->tearDownFiles();
+ $this->doTestDoOperationsPipeline();
+ $this->tearDownFiles();
+
+ $this->backend = $this->multiBackend;
+ $this->tearDownFiles();
+ $this->doTestDoOperationsPipeline();
+ $this->tearDownFiles();
+ }
+
// concurrency orientated
- private function doTestDoOperations2() {
+ private function doTestDoOperationsPipeline() {
$base = $this->baseStorePath();
$fileAContents = '3tqtmoeatmn4wg4qe-mg3qt3 tq';
@@ -1332,6 +1324,18 @@ class FileBackendTest extends MediaWikiTestCase {
"Correct file SHA-1 of $fileC" );
}
+ public function testDoOperationsFailing() {
+ $this->backend = $this->singleBackend;
+ $this->tearDownFiles();
+ $this->doTestDoOperationsFailing();
+ $this->tearDownFiles();
+
+ $this->backend = $this->multiBackend;
+ $this->tearDownFiles();
+ $this->doTestDoOperationsFailing();
+ $this->tearDownFiles();
+ }
+
private function doTestDoOperationsFailing() {
$base = $this->baseStorePath();
diff --git a/tests/phpunit/includes/libs/GenericArrayObjectTest.php b/tests/phpunit/includes/libs/GenericArrayObjectTest.php
index 5e4cda1eead0..8a2fb559714d 100644
--- a/tests/phpunit/includes/libs/GenericArrayObjectTest.php
+++ b/tests/phpunit/includes/libs/GenericArrayObjectTest.php
@@ -1,6 +1,5 @@
<?php
-
/**
* Tests for the GenericArrayObject and deriving classes.
*
@@ -171,7 +170,7 @@ abstract class GenericArrayObjectTest extends MediaWikiTestCase {
call_user_func( $function, $list, $element );
$valid = true;
}
- catch ( \MWException $exception ) {
+ catch ( InvalidArgumentException $exception ) {
$valid = false;
}
diff --git a/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php b/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php
index f4f52dd87502..d6e25477bd4b 100644
--- a/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php
+++ b/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php
@@ -2,7 +2,7 @@
class BitmapMetadataHandlerTest extends MediaWikiTestCase {
public function setUp() {
- $this->filePath = dirname( __FILE__ ) . '/../../data/media/';
+ $this->filePath = __DIR__ . '/../../data/media/';
}
/**
diff --git a/tests/phpunit/includes/media/ExifRotationTest.php b/tests/phpunit/includes/media/ExifRotationTest.php
index 1e2d1bb7fe01..6af52dd10d81 100644
--- a/tests/phpunit/includes/media/ExifRotationTest.php
+++ b/tests/phpunit/includes/media/ExifRotationTest.php
@@ -8,7 +8,7 @@ class ExifRotationTest extends MediaWikiTestCase {
function setUp() {
parent::setUp();
$this->handler = new BitmapHandler();
- $filePath = dirname( __FILE__ ) . '/../../data/media';
+ $filePath = __DIR__ . '/../../data/media';
$tmpDir = $this->getNewTempDirectory();
diff --git a/tests/phpunit/includes/media/ExifTest.php b/tests/phpunit/includes/media/ExifTest.php
index 80aaac233255..045777d7715b 100644
--- a/tests/phpunit/includes/media/ExifTest.php
+++ b/tests/phpunit/includes/media/ExifTest.php
@@ -2,7 +2,7 @@
class ExifTest extends MediaWikiTestCase {
public function setUp() {
- $this->mediaPath = dirname( __FILE__ ) . '/../../data/media/';
+ $this->mediaPath = __DIR__ . '/../../data/media/';
if ( !wfDl( 'exif' ) ) {
$this->markTestSkipped( "This test needs the exif extension." );
@@ -25,7 +25,7 @@ class ExifTest extends MediaWikiTestCase {
$expected = array(
'GPSLatitude' => 88.5180555556,
'GPSLongitude' => -21.12357,
- 'GPSAltitude' => -200,
+ 'GPSAltitude' => -3.141592653,
'GPSDOP' => '5/1',
'GPSVersionID' => '2.2.0.0',
);
diff --git a/tests/phpunit/includes/media/FormatMetadataTest.php b/tests/phpunit/includes/media/FormatMetadataTest.php
index 8a632f527c6f..6ade67027cd6 100644
--- a/tests/phpunit/includes/media/FormatMetadataTest.php
+++ b/tests/phpunit/includes/media/FormatMetadataTest.php
@@ -4,7 +4,7 @@ class FormatMetadataTest extends MediaWikiTestCase {
if ( !wfDl( 'exif' ) ) {
$this->markTestSkipped( "This test needs the exif extension." );
}
- $filePath = dirname( __FILE__ ) . '/../../data/media';
+ $filePath = __DIR__ . '/../../data/media';
$this->backend = new FSFileBackend( array(
'name' => 'localtesting',
'lockManager' => 'nullLockManager',
diff --git a/tests/phpunit/includes/media/GIFMetadataExtractorTest.php b/tests/phpunit/includes/media/GIFMetadataExtractorTest.php
index 47fc368b27c4..650fdd5c7caf 100644
--- a/tests/phpunit/includes/media/GIFMetadataExtractorTest.php
+++ b/tests/phpunit/includes/media/GIFMetadataExtractorTest.php
@@ -2,7 +2,7 @@
class GIFMetadataExtractorTest extends MediaWikiTestCase {
public function setUp() {
- $this->mediaPath = dirname( __FILE__ ) . '/../../data/media/';
+ $this->mediaPath = __DIR__ . '/../../data/media/';
}
/**
* Put in a file, and see if the metadata coming out is as expected.
diff --git a/tests/phpunit/includes/media/GIFTest.php b/tests/phpunit/includes/media/GIFTest.php
index 3665835804bd..5dcbeee03fd5 100644
--- a/tests/phpunit/includes/media/GIFTest.php
+++ b/tests/phpunit/includes/media/GIFTest.php
@@ -2,7 +2,7 @@
class GIFHandlerTest extends MediaWikiTestCase {
public function setUp() {
- $this->filePath = dirname( __FILE__ ) . '/../../data/media';
+ $this->filePath = __DIR__ . '/../../data/media';
$this->backend = new FSFileBackend( array(
'name' => 'localtesting',
'lockManager' => 'nullLockManager',
diff --git a/tests/phpunit/includes/media/JpegMetadataExtractorTest.php b/tests/phpunit/includes/media/JpegMetadataExtractorTest.php
index f48382a43101..41d811902c20 100644
--- a/tests/phpunit/includes/media/JpegMetadataExtractorTest.php
+++ b/tests/phpunit/includes/media/JpegMetadataExtractorTest.php
@@ -9,7 +9,7 @@
class JpegMetadataExtractorTest extends MediaWikiTestCase {
public function setUp() {
- $this->filePath = dirname( __FILE__ ) . '/../../data/media/';
+ $this->filePath = __DIR__ . '/../../data/media/';
}
/**
diff --git a/tests/phpunit/includes/media/JpegTest.php b/tests/phpunit/includes/media/JpegTest.php
index ddabf5b8cd81..ea007f9031e5 100644
--- a/tests/phpunit/includes/media/JpegTest.php
+++ b/tests/phpunit/includes/media/JpegTest.php
@@ -2,7 +2,7 @@
class JpegTest extends MediaWikiTestCase {
public function setUp() {
- $this->filePath = dirname( __FILE__ ) . '/../../data/media/';
+ $this->filePath = __DIR__ . '/../../data/media/';
if ( !wfDl( 'exif' ) ) {
$this->markTestSkipped( "This test needs the exif extension." );
}
diff --git a/tests/phpunit/includes/media/PNGMetadataExtractorTest.php b/tests/phpunit/includes/media/PNGMetadataExtractorTest.php
index 9f702c504d40..1b1b2ec33af4 100644
--- a/tests/phpunit/includes/media/PNGMetadataExtractorTest.php
+++ b/tests/phpunit/includes/media/PNGMetadataExtractorTest.php
@@ -2,7 +2,7 @@
class PNGMetadataExtractorTest extends MediaWikiTestCase {
function setUp() {
- $this->filePath = dirname( __FILE__ ) . '/../../data/media/';
+ $this->filePath = __DIR__ . '/../../data/media/';
}
/**
* Tests zTXt tag (compressed textual metadata)
diff --git a/tests/phpunit/includes/media/PNGTest.php b/tests/phpunit/includes/media/PNGTest.php
index b6f911fd8a87..fe73c9c71c72 100644
--- a/tests/phpunit/includes/media/PNGTest.php
+++ b/tests/phpunit/includes/media/PNGTest.php
@@ -2,7 +2,7 @@
class PNGHandlerTest extends MediaWikiTestCase {
public function setUp() {
- $this->filePath = dirname( __FILE__ ) . '/../../data/media';
+ $this->filePath = __DIR__ . '/../../data/media';
$this->backend = new FSFileBackend( array(
'name' => 'localtesting',
'lockManager' => 'nullLockManager',
diff --git a/tests/phpunit/includes/media/SVGMetadataExtractorTest.php b/tests/phpunit/includes/media/SVGMetadataExtractorTest.php
index 526beae81bb3..2116554eece8 100644
--- a/tests/phpunit/includes/media/SVGMetadataExtractorTest.php
+++ b/tests/phpunit/includes/media/SVGMetadataExtractorTest.php
@@ -39,27 +39,33 @@ class SVGMetadataExtractorTest extends MediaWikiTestCase {
}
function providerSvgFiles() {
- $base = dirname( __FILE__ ) . '/../../data/media';
+ $base = __DIR__ . '/../../data/media';
return array(
array(
"$base/Wikimedia-logo.svg",
array(
'width' => 1024,
- 'height' => 1024
+ 'height' => 1024,
+ 'originalWidth' => '1024',
+ 'originalHeight' => '1024',
)
),
array(
"$base/QA_icon.svg",
array(
'width' => 60,
- 'height' => 60
+ 'height' => 60,
+ 'originalWidth' => '60',
+ 'originalHeight' => '60',
)
),
array(
"$base/Gtk-media-play-ltr.svg",
array(
'width' => 60,
- 'height' => 60
+ 'height' => 60,
+ 'originalWidth' => '60.0000000',
+ 'originalHeight' => '60.0000000',
)
),
array(
@@ -67,14 +73,16 @@ class SVGMetadataExtractorTest extends MediaWikiTestCase {
// This file triggered bug 31719, needs entity expansion in the xmlns checks
array(
'width' => 385,
- 'height' => 385
+ 'height' => 385,
+ 'originalWidth' => '385',
+ 'originalHeight' => '385.0004883',
)
)
);
}
function providerSvgFilesWithXMLMetadata() {
- $base = dirname( __FILE__ ) . '/../../data/media';
+ $base = __DIR__ . '/../../data/media';
$metadata =
'<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<ns4:Work xmlns:ns4="http://creativecommons.org/ns#" rdf:about="">
@@ -89,7 +97,9 @@ class SVGMetadataExtractorTest extends MediaWikiTestCase {
array(
'height' => 593,
'metadata' => $metadata,
- 'width' => 959
+ 'width' => 959,
+ 'originalWidth' => '958.69',
+ 'originalHeight' => '592.78998',
)
),
);
diff --git a/tests/phpunit/includes/media/TiffTest.php b/tests/phpunit/includes/media/TiffTest.php
index d4cf503b9374..4c79f66c0ed2 100644
--- a/tests/phpunit/includes/media/TiffTest.php
+++ b/tests/phpunit/includes/media/TiffTest.php
@@ -5,7 +5,7 @@ class TiffTest extends MediaWikiTestCase {
global $wgShowEXIF;
$this->showExif = $wgShowEXIF;
$wgShowEXIF = true;
- $this->filePath = dirname( __FILE__ ) . '/../../data/media/';
+ $this->filePath = __DIR__ . '/../../data/media/';
$this->handler = new TiffHandler;
}
diff --git a/tests/phpunit/includes/media/XMPTest.php b/tests/phpunit/includes/media/XMPTest.php
index c952b23c94ca..8198d3b08b37 100644
--- a/tests/phpunit/includes/media/XMPTest.php
+++ b/tests/phpunit/includes/media/XMPTest.php
@@ -22,11 +22,11 @@ class XMPTest extends MediaWikiTestCase {
}
$reader = new XMPReader;
$reader->parse( $xmp );
- $this->assertEquals( $expected, $reader->getResults(), $info );
+ $this->assertEquals( $expected, $reader->getResults(), $info, 0.0000000001 );
}
public function dataXMPParse() {
- $xmpPath = dirname( __FILE__ ) . '/../../data/xmp/' ;
+ $xmpPath = __DIR__ . '/../../data/xmp/' ;
$data = array();
// $xmpFiles format: array of arrays with first arg file base name,
@@ -52,6 +52,7 @@ class XMPTest extends MediaWikiTestCase {
array( 'utf32BE', 'UTF-32BE encoding' ),
array( 'utf32LE', 'UTF-32LE encoding' ),
array( 'xmpExt', 'Extended XMP missing second part' ),
+ array( 'gps', 'Handling of exif GPS parameters in XMP' ),
);
foreach( $xmpFiles as $file ) {
$xmp = file_get_contents( $xmpPath . $file[0] . '.xmp' );
@@ -72,7 +73,7 @@ class XMPTest extends MediaWikiTestCase {
* world example file to double check the support for this is right.
*/
function testExtendedXMP() {
- $xmpPath = dirname( __FILE__ ) . '/../../data/xmp/';
+ $xmpPath = __DIR__ . '/../../data/xmp/';
$standardXMP = file_get_contents( $xmpPath . 'xmpExt.xmp' );
$extendedXMP = file_get_contents( $xmpPath . 'xmpExt2.xmp' );
@@ -102,7 +103,7 @@ class XMPTest extends MediaWikiTestCase {
* and thus should only return the StandardXMP, not the ExtendedXMP.
*/
function testExtendedXMPWithWrongGUID() {
- $xmpPath = dirname( __FILE__ ) . '/../../data/xmp/';
+ $xmpPath = __DIR__ . '/../../data/xmp/';
$standardXMP = file_get_contents( $xmpPath . 'xmpExt.xmp' );
$extendedXMP = file_get_contents( $xmpPath . 'xmpExt2.xmp' );
@@ -130,7 +131,7 @@ class XMPTest extends MediaWikiTestCase {
* which should cause it to ignore the ExtendedXMP packet.
*/
function testExtendedXMPMissingPacket() {
- $xmpPath = dirname( __FILE__ ) . '/../../data/xmp/';
+ $xmpPath = __DIR__ . '/../../data/xmp/';
$standardXMP = file_get_contents( $xmpPath . 'xmpExt.xmp' );
$extendedXMP = file_get_contents( $xmpPath . 'xmpExt2.xmp' );
diff --git a/tests/phpunit/includes/parser/MediaWikiParserTest.php b/tests/phpunit/includes/parser/MediaWikiParserTest.php
index 816c017a9525..6a6fded17a9e 100644
--- a/tests/phpunit/includes/parser/MediaWikiParserTest.php
+++ b/tests/phpunit/includes/parser/MediaWikiParserTest.php
@@ -1,5 +1,5 @@
<?php
-require_once( dirname( __FILE__ ) . '/NewParserTest.php' );
+require_once( __DIR__ . '/NewParserTest.php' );
/**
* The UnitTest must be either a class that inherits from MediaWikiTestCase
diff --git a/tests/phpunit/includes/parser/PreprocessorTest.php b/tests/phpunit/includes/parser/PreprocessorTest.php
index 9d3499a03f30..fee56748055f 100644
--- a/tests/phpunit/includes/parser/PreprocessorTest.php
+++ b/tests/phpunit/includes/parser/PreprocessorTest.php
@@ -103,7 +103,7 @@ class PreprocessorTest extends MediaWikiTestCase {
array( "{{foo|bar=|}", "<root>{{foo|bar=|}</root>"),
array( "{{Foo|} Bar=", "<root>{{Foo|} Bar=</root>"),
array( "{{Foo|} Bar=}}", "<root><template><title>Foo</title><part><name>} Bar</name>=<value></value></part></template></root>"),
- /* array( file_get_contents( dirname( __FILE__ ) . '/QuoteQuran.txt' ), file_get_contents( dirname( __FILE__ ) . '/QuoteQuranExpanded.txt' ) ), */
+ /* array( file_get_contents( __DIR__ . '/QuoteQuran.txt' ), file_get_contents( __DIR__ . '/QuoteQuranExpanded.txt' ) ), */
);
}
@@ -165,7 +165,7 @@ class PreprocessorTest extends MediaWikiTestCase {
* @dataProvider provideFiles
*/
function testPreprocessorOutputFiles( $filename ) {
- $folder = dirname( __FILE__ ) . "/../../../parser/preprocess";
+ $folder = __DIR__ . "/../../../parser/preprocess";
$wikiText = file_get_contents( "$folder/$filename.txt" );
$output = $this->preprocessToXml( $wikiText );
diff --git a/tests/phpunit/includes/upload/UploadStashTest.php b/tests/phpunit/includes/upload/UploadStashTest.php
index c9dbb1388e61..dc1c2ac4fc0b 100644
--- a/tests/phpunit/includes/upload/UploadStashTest.php
+++ b/tests/phpunit/includes/upload/UploadStashTest.php
@@ -12,7 +12,7 @@ class UploadStashTest extends MediaWikiTestCase {
parent::setUp();
// Setup a file for bug 29408
- $this->bug29408File = dirname( __FILE__ ) . '/bug29408';
+ $this->bug29408File = __DIR__ . '/bug29408';
file_put_contents( $this->bug29408File, "\x00" );
self::$users = array(
diff --git a/tests/phpunit/languages/LanguageHeTest.php b/tests/phpunit/languages/LanguageHeTest.php
index 9ac0f952d996..7833da7149e5 100644
--- a/tests/phpunit/languages/LanguageHeTest.php
+++ b/tests/phpunit/languages/LanguageHeTest.php
@@ -18,31 +18,31 @@ class LanguageHeTest extends MediaWikiTestCase {
/** @dataProvider providerPluralDual */
function testPluralDual( $result, $value ) {
- $forms = array( 'one', 'many', 'two' );
+ $forms = array( 'one', 'two', 'other' );
$this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
}
function providerPluralDual() {
return array (
- array( 'many', 0 ), // Zero -> plural
+ array( 'other', 0 ), // Zero -> plural
array( 'one', 1 ), // Singular
array( 'two', 2 ), // Dual
- array( 'many', 3 ), // Plural
+ array( 'other', 3 ), // Plural
);
}
/** @dataProvider providerPlural */
function testPlural( $result, $value ) {
- $forms = array( 'one', 'many' );
+ $forms = array( 'one', 'other' );
$this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
}
function providerPlural() {
return array (
- array( 'many', 0 ), // Zero -> plural
+ array( 'other', 0 ), // Zero -> plural
array( 'one', 1 ), // Singular
- array( 'many', 2 ), // Plural, no dual provided
- array( 'many', 3 ), // Plural
+ array( 'other', 2 ), // Plural, no dual provided
+ array( 'other', 3 ), // Plural
);
}
}
diff --git a/tests/phpunit/languages/LanguageSrTest.php b/tests/phpunit/languages/LanguageSrTest.php
index e7d3ea18161a..d44ecf8e5bfa 100644
--- a/tests/phpunit/languages/LanguageSrTest.php
+++ b/tests/phpunit/languages/LanguageSrTest.php
@@ -12,7 +12,7 @@
* @file
*/
-require_once dirname( dirname( __FILE__ ) ) . '/bootstrap.php';
+require_once dirname( __DIR__ ) . '/bootstrap.php';
/** Tests for MediaWiki languages/LanguageSr.php */
class LanguageSrTest extends MediaWikiTestCase {
diff --git a/tests/phpunit/languages/LanguageUzTest.php b/tests/phpunit/languages/LanguageUzTest.php
index 86f483d0fc37..723872836f69 100644
--- a/tests/phpunit/languages/LanguageUzTest.php
+++ b/tests/phpunit/languages/LanguageUzTest.php
@@ -12,7 +12,7 @@
* @file
*/
-require_once dirname( dirname( __FILE__ ) ) . '/bootstrap.php';
+require_once dirname( __DIR__ ) . '/bootstrap.php';
/** Tests for MediaWiki languages/LanguageUz.php */
class LanguageUzTest extends MediaWikiTestCase {
diff --git a/tests/phpunit/maintenance/backupPrefetchTest.php b/tests/phpunit/maintenance/backupPrefetchTest.php
index 9c82eae30ba7..5178154dbe2c 100644
--- a/tests/phpunit/maintenance/backupPrefetchTest.php
+++ b/tests/phpunit/maintenance/backupPrefetchTest.php
@@ -1,6 +1,6 @@
<?php
-require_once dirname( __FILE__ ) . "/../../../maintenance/backupPrefetch.inc";
+require_once __DIR__ . "/../../../maintenance/backupPrefetch.inc";
/**
* Tests for BaseDump
diff --git a/tests/phpunit/maintenance/backupTextPassTest.php b/tests/phpunit/maintenance/backupTextPassTest.php
index 31bb8b7228e3..db5b877acda8 100644
--- a/tests/phpunit/maintenance/backupTextPassTest.php
+++ b/tests/phpunit/maintenance/backupTextPassTest.php
@@ -1,6 +1,6 @@
<?php
-require_once dirname( __FILE__ ) . "/../../../maintenance/backupTextPass.inc";
+require_once __DIR__ . "/../../../maintenance/backupTextPass.inc";
/**
* Tests for page dumps of BackupDumper
diff --git a/tests/phpunit/maintenance/fetchTextTest.php b/tests/phpunit/maintenance/fetchTextTest.php
index a6e7fbd525a7..fd6db0abd44e 100644
--- a/tests/phpunit/maintenance/fetchTextTest.php
+++ b/tests/phpunit/maintenance/fetchTextTest.php
@@ -1,6 +1,6 @@
<?php
-require_once dirname( __FILE__ ) . "/../../../maintenance/fetchText.php";
+require_once __DIR__ . "/../../../maintenance/fetchText.php";
/**
* Mock for the input/output of FetchText
diff --git a/tests/phpunit/maintenance/getSlaveServerTest.php b/tests/phpunit/maintenance/getSlaveServerTest.php
index 86356144f03e..0b7c758c75ec 100644
--- a/tests/phpunit/maintenance/getSlaveServerTest.php
+++ b/tests/phpunit/maintenance/getSlaveServerTest.php
@@ -1,6 +1,6 @@
<?php
-require_once dirname( __FILE__ ) . "/../../../maintenance/getSlaveServer.php";
+require_once __DIR__ . "/../../../maintenance/getSlaveServer.php";
/**
* Tests for getSlaveServer
diff --git a/tests/phpunit/phpunit.php b/tests/phpunit/phpunit.php
index 61a20f1b1fb3..bcbf4ec121aa 100755
--- a/tests/phpunit/phpunit.php
+++ b/tests/phpunit/phpunit.php
@@ -9,7 +9,7 @@
/* Configuration */
// Evaluate the include path relative to this file
-$IP = dirname( dirname( dirname( __FILE__ ) ) );
+$IP = dirname( dirname( __DIR__ ) );
// Set a flag which can be used to detect when other scripts have been entered through this entry point or not
define( 'MW_PHPUNIT_TEST', true );
@@ -34,6 +34,10 @@ class PHPUnitMaintClass extends Maintenance {
global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType;
global $wgLanguageConverterCacheType, $wgUseDatabaseMessages;
global $wgLocaltimezone, $wgLocalisationCacheConf;
+ global $wgDevelopmentWarnings;
+
+ // wfWarn should cause tests to fail
+ $wgDevelopmentWarnings = true;
$wgMainCacheType = CACHE_NONE;
$wgMessageCacheType = CACHE_NONE;
diff --git a/tests/phpunit/suites/UploadFromUrlTestSuite.php b/tests/phpunit/suites/UploadFromUrlTestSuite.php
index 6779ad478111..f2638111bba6 100644
--- a/tests/phpunit/suites/UploadFromUrlTestSuite.php
+++ b/tests/phpunit/suites/UploadFromUrlTestSuite.php
@@ -1,6 +1,6 @@
<?php
-require_once( dirname( dirname( __FILE__ ) ) . '/includes/upload/UploadFromUrlTest.php' );
+require_once( dirname( __DIR__ ) . '/includes/upload/UploadFromUrlTest.php' );
class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite {
public $savedGlobals = array();