aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes
diff options
context:
space:
mode:
Diffstat (limited to 'tests/phpunit/includes')
-rw-r--r--tests/phpunit/includes/api/ApiWatchTest.php4
-rw-r--r--tests/phpunit/includes/api/RandomImageGenerator.php64
-rw-r--r--tests/phpunit/includes/api/format/ApiFormatTestBase.php4
-rw-r--r--tests/phpunit/includes/api/generateRandomImages.php2
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryBasicTest.php13
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryRevisionsTest.php7
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryTest.php4
-rw-r--r--tests/phpunit/includes/cache/GenderCacheTest.php6
-rw-r--r--tests/phpunit/includes/cache/ProcessCacheLRUTest.php24
-rw-r--r--tests/phpunit/includes/content/ContentHandlerTest.php24
-rw-r--r--tests/phpunit/includes/content/CssContentTest.php2
-rw-r--r--tests/phpunit/includes/content/JavaScriptContentTest.php148
-rw-r--r--tests/phpunit/includes/content/TextContentTest.php68
-rw-r--r--tests/phpunit/includes/content/WikitextContentHandlerTest.php26
-rw-r--r--tests/phpunit/includes/content/WikitextContentTest.php154
-rw-r--r--tests/phpunit/includes/db/DatabaseSQLTest.php42
-rw-r--r--tests/phpunit/includes/db/DatabaseSqliteTest.php36
-rw-r--r--tests/phpunit/includes/db/DatabaseTest.php2
-rw-r--r--tests/phpunit/includes/debug/MWDebugTest.php20
19 files changed, 325 insertions, 325 deletions
diff --git a/tests/phpunit/includes/api/ApiWatchTest.php b/tests/phpunit/includes/api/ApiWatchTest.php
index 4fecec049833..aefd93986203 100644
--- a/tests/phpunit/includes/api/ApiWatchTest.php
+++ b/tests/phpunit/includes/api/ApiWatchTest.php
@@ -147,8 +147,8 @@ class ApiWatchTest extends ApiTestCase {
$this->assertArrayHasKey( 'rollback', $data[0] );
$this->assertArrayHasKey( 'title', $data[0]['rollback'] );
- } catch( UsageException $ue ) {
- if( $ue->getCodeString() == 'onlyauthor' ) {
+ } catch ( UsageException $ue ) {
+ if ( $ue->getCodeString() == 'onlyauthor' ) {
$this->markTestIncomplete( "Only one author to 'Help:UTPage', cannot test rollback" );
} else {
$this->fail( "Received error '" . $ue->getCodeString() . "'" );
diff --git a/tests/phpunit/includes/api/RandomImageGenerator.php b/tests/phpunit/includes/api/RandomImageGenerator.php
index 8b6a3849f65a..30407582c916 100644
--- a/tests/phpunit/includes/api/RandomImageGenerator.php
+++ b/tests/phpunit/includes/api/RandomImageGenerator.php
@@ -27,11 +27,11 @@
class RandomImageGenerator {
private $dictionaryFile;
- private $minWidth = 400 ;
- private $maxWidth = 800 ;
- private $minHeight = 400 ;
- private $maxHeight = 800 ;
- private $shapesToDraw = 5 ;
+ private $minWidth = 400;
+ private $maxWidth = 800;
+ private $minHeight = 400;
+ private $maxHeight = 800;
+ private $shapesToDraw = 5;
/**
* Orientations: 0th row, 0th column, EXIF orientation code, rotation 2x2 matrix that is opposite of orientation
@@ -76,11 +76,13 @@ class RandomImageGenerator {
// find the dictionary file, to generate random names
if ( !isset( $this->dictionaryFile ) ) {
- foreach ( array(
+ foreach (
+ array(
'/usr/share/dict/words',
'/usr/dict/words',
- __DIR__ . '/words.txt' )
- as $dictionaryFile ) {
+ __DIR__ . '/words.txt'
+ ) as $dictionaryFile
+ ) {
if ( is_file( $dictionaryFile ) and is_readable( $dictionaryFile ) ) {
$this->dictionaryFile = $dictionaryFile;
break;
@@ -103,7 +105,7 @@ class RandomImageGenerator {
function writeImages( $number, $format = 'jpg', $dir = null ) {
$filenames = $this->getRandomFilenames( $number, $format, $dir );
$imageWriteMethod = $this->getImageWriteMethod( $format );
- foreach( $filenames as $filename ) {
+ foreach ( $filenames as $filename ) {
$this->{$imageWriteMethod}( $this->getImageSpec(), $format, $filename );
}
return $filenames;
@@ -144,7 +146,7 @@ class RandomImageGenerator {
$dir = getcwd();
}
$filenames = array();
- foreach( $this->getRandomWordPairs( $number ) as $pair ) {
+ foreach ( $this->getRandomWordPairs( $number ) as $pair ) {
$basename = $pair[0] . '_' . $pair[1];
if ( !is_null( $extension ) ) {
$basename .= '.' . $extension;
@@ -181,17 +183,17 @@ class RandomImageGenerator {
}
$originX = mt_rand( -1 * $radius, $spec['width'] + $radius );
$originY = mt_rand( -1 * $radius, $spec['height'] + $radius );
- $angle = mt_rand( 0, ( 3.141592/2 ) * $radius ) / $radius;
+ $angle = mt_rand( 0, ( 3.141592 / 2 ) * $radius ) / $radius;
$legDeltaX = round( $radius * sin( $angle ) );
$legDeltaY = round( $radius * cos( $angle ) );
$draw = array();
$draw['fill'] = $this->getRandomColor();
$draw['shape'] = array(
- array( 'x' => $originX, 'y' => $originY - $radius ),
- array( 'x' => $originX + $legDeltaX, 'y' => $originY + $legDeltaY ),
- array( 'x' => $originX - $legDeltaX, 'y' => $originY + $legDeltaY ),
- array( 'x' => $originX, 'y' => $originY - $radius )
+ array( 'x' => $originX, 'y' => $originY - $radius ),
+ array( 'x' => $originX + $legDeltaX, 'y' => $originY + $legDeltaY ),
+ array( 'x' => $originX - $legDeltaX, 'y' => $originY + $legDeltaY ),
+ array( 'x' => $originX, 'y' => $originY - $radius )
);
$draws[] = $draw;
@@ -235,12 +237,13 @@ class RandomImageGenerator {
$shape = $g->addChild( 'polygon' );
$shape->addAttribute( 'fill', $drawSpec['fill'] );
$shape->addAttribute( 'points', self::shapePointsToString( $drawSpec['shape'] ) );
- };
- if ( ! $fh = fopen( $filename, 'w' ) ) {
+ }
+
+ if ( !$fh = fopen( $filename, 'w' ) ) {
throw new Exception( "couldn't open $filename for writing" );
}
fwrite( $fh, $svg->asXML() );
- if ( !fclose($fh) ) {
+ if ( !fclose( $fh ) ) {
throw new Exception( "couldn't close $filename" );
}
}
@@ -262,7 +265,7 @@ class RandomImageGenerator {
*/
$orientation = self::$orientations[0]; // default is normal orientation
if ( $format == 'jpg' ) {
- $orientation = self::$orientations[ array_rand( self::$orientations ) ];
+ $orientation = self::$orientations[array_rand( self::$orientations )];
$spec = self::rotateImageSpec( $spec, $orientation['counterRotation'] );
}
@@ -321,12 +324,12 @@ class RandomImageGenerator {
$tSpec['height'] = abs( $dims['y'] );
$tSpec['fill'] = $spec['fill'];
$tSpec['draws'] = array();
- foreach( $spec['draws'] as $draw ) {
+ foreach ( $spec['draws'] as $draw ) {
$tDraw = array(
'fill' => $draw['fill'],
'shape' => array()
);
- foreach( $draw['shape'] as $point ) {
+ foreach ( $draw['shape'] as $point ) {
$tPoint = self::matrixMultiply2x2( $matrix, $point['x'], $point['y'] );
$tPoint['x'] += $correctionX;
$tPoint['y'] += $correctionY;
@@ -357,7 +360,7 @@ class RandomImageGenerator {
*
* Sample command line:
* $ convert -size 100x60 xc:rgb(90,87,45) \
- * -draw 'fill rgb(12,34,56) polygon 41,39 44,57 50,57 41,39' \
+ * -draw 'fill rgb(12,34,56) polygon 41,39 44,57 50,57 41,39' \
* -draw 'fill rgb(99,123,231) circle 59,39 56,57' \
* -draw 'fill rgb(240,12,32) circle 50,21 50,3' filename.png
*
@@ -370,7 +373,7 @@ class RandomImageGenerator {
$args = array();
$args[] = "-size " . wfEscapeShellArg( $spec['width'] . 'x' . $spec['height'] );
$args[] = wfEscapeShellArg( "xc:" . $spec['fill'] );
- foreach( $spec['draws'] as $draw ) {
+ foreach ( $spec['draws'] as $draw ) {
$fill = $draw['fill'];
$polygon = self::shapePointsToString( $draw['shape'] );
$drawCommand = "fill $fill polygon $polygon";
@@ -391,10 +394,10 @@ class RandomImageGenerator {
*/
public function getRandomColor() {
$components = array();
- for ($i = 0; $i <= 2; $i++ ) {
+ for ( $i = 0; $i <= 2; $i++ ) {
$components[] = mt_rand( 0, 255 );
}
- return 'rgb(' . join(', ', $components) . ')';
+ return 'rgb(' . join( ', ', $components ) . ')';
}
/**
@@ -408,13 +411,12 @@ class RandomImageGenerator {
// construct pairs of words
$pairs = array();
$count = count( $lines );
- for( $i = 0; $i < $count; $i += 2 ) {
- $pairs[] = array( $lines[$i], $lines[$i+1] );
+ for ( $i = 0; $i < $count; $i += 2 ) {
+ $pairs[] = array( $lines[$i], $lines[$i + 1] );
}
return $pairs;
}
-
/**
* Return N random lines from a file
*
@@ -438,17 +440,17 @@ class RandomImageGenerator {
*/
$fh = fopen( $filepath, "r" );
if ( !$fh ) {
- throw new Exception( "couldn't open $filepath" );
+ throw new Exception( "couldn't open $filepath" );
}
$line_number = 0;
$max_index = $number_desired - 1;
- while( !feof( $fh ) ) {
+ while ( !feof( $fh ) ) {
$line = fgets( $fh );
if ( $line !== false ) {
$line_number++;
$line = trim( $line );
if ( mt_rand( 0, $line_number ) <= $max_index ) {
- $lines[ mt_rand( 0, $max_index ) ] = $line;
+ $lines[mt_rand( 0, $max_index )] = $line;
}
}
}
diff --git a/tests/phpunit/includes/api/format/ApiFormatTestBase.php b/tests/phpunit/includes/api/format/ApiFormatTestBase.php
index a0b7b0206547..153f2cf46d21 100644
--- a/tests/phpunit/includes/api/format/ApiFormatTestBase.php
+++ b/tests/phpunit/includes/api/format/ApiFormatTestBase.php
@@ -5,7 +5,7 @@ abstract class ApiFormatTestBase extends ApiTestCase {
$data = parent::doApiRequest( $params, $data, true );
$module = $data[3];
-
+
$printer = $module->createPrinterByName( $format );
$printer->setUnescapeAmps( false );
@@ -14,7 +14,7 @@ abstract class ApiFormatTestBase extends ApiTestCase {
ob_start();
$printer->execute();
$out = ob_get_clean();
-
+
$printer->closePrinter();
return $out;
diff --git a/tests/phpunit/includes/api/generateRandomImages.php b/tests/phpunit/includes/api/generateRandomImages.php
index a05428388a57..cba8312bf9e5 100644
--- a/tests/phpunit/includes/api/generateRandomImages.php
+++ b/tests/phpunit/includes/api/generateRandomImages.php
@@ -10,7 +10,7 @@ $IP = dirname( dirname( dirname( dirname( __DIR__ ) ) ) );
// Start up MediaWiki in command-line mode
require_once( "$IP/maintenance/Maintenance.php" );
-require( __DIR__ . "/RandomImageGenerator.php" );
+require( __DIR__ . "/RandomImageGenerator.php" );
class GenerateRandomImages extends Maintenance {
diff --git a/tests/phpunit/includes/api/query/ApiQueryBasicTest.php b/tests/phpunit/includes/api/query/ApiQueryBasicTest.php
index b7dac06091ca..a5ca256eadc9 100644
--- a/tests/phpunit/includes/api/query/ApiQueryBasicTest.php
+++ b/tests/phpunit/includes/api/query/ApiQueryBasicTest.php
@@ -30,7 +30,6 @@
* @group medium
*/
class ApiQueryBasicTest extends ApiTestCase {
-
/**
* Create a set of pages. These must not change, otherwise the tests might give wrong results.
* @see MediaWikiTestCase::addDBData()
@@ -304,7 +303,7 @@ class ApiQueryBasicTest extends ApiTestCase {
private function merge( /*...*/ ) {
$request = array();
$expected = array();
- foreach ( func_get_args() as $v ) {
+ foreach ( func_get_args() as $v ) {
$request = array_merge_recursive( $request, $v[0] );
$this->mergeExpected( $expected, $v[1] );
}
@@ -317,7 +316,7 @@ class ApiQueryBasicTest extends ApiTestCase {
private function mergeExpected( &$all, $item ) {
foreach ( $item as $k => $v ) {
if ( array_key_exists( $k, $all ) ) {
- if ( is_array ( $all[$k] ) ) {
+ if ( is_array( $all[$k] ) ) {
$this->mergeExpected( $all[$k], $v );
} else {
$this->assertEquals( $all[$k], $v );
@@ -349,12 +348,12 @@ class ApiQueryBasicTest extends ApiTestCase {
$expected = array( 'query' => $expected );
try {
$this->assertQueryResults( $expected, $result );
- } catch (Exception $e) {
- print("\nRequest:\n");
+ } catch ( Exception $e ) {
+ print( "\nRequest:\n" );
print_r( $request );
- print("\nExpected:\n");
+ print( "\nExpected:\n" );
print_r( $expected );
- print("\nResult:\n");
+ print( "\nResult:\n" );
print_r( $result );
throw $e; // rethrow it
}
diff --git a/tests/phpunit/includes/api/query/ApiQueryRevisionsTest.php b/tests/phpunit/includes/api/query/ApiQueryRevisionsTest.php
index 594dc66b8afb..7f5fe91c3c7a 100644
--- a/tests/phpunit/includes/api/query/ApiQueryRevisionsTest.php
+++ b/tests/phpunit/includes/api/query/ApiQueryRevisionsTest.php
@@ -11,8 +11,7 @@ class ApiQueryRevisionsTest extends ApiTestCase {
* @group medium
*/
function testContentComesWithContentModelAndFormat() {
-
- $pageName = 'Help:' . __METHOD__ ;
+ $pageName = 'Help:' . __METHOD__;
$title = Title::newFromText( $pageName );
$page = WikiPage::factory( $title );
$page->doEdit( 'Some text', 'inserting content' );
@@ -25,9 +24,9 @@ class ApiQueryRevisionsTest extends ApiTestCase {
) );
$this->assertArrayHasKey( 'query', $apiResult[0] );
$this->assertArrayHasKey( 'pages', $apiResult[0]['query'] );
- foreach( $apiResult[0]['query']['pages'] as $page ) {
+ foreach ( $apiResult[0]['query']['pages'] as $page ) {
$this->assertArrayHasKey( 'revisions', $page );
- foreach( $page['revisions'] as $revision ) {
+ foreach ( $page['revisions'] as $revision ) {
$this->assertArrayHasKey( 'contentformat', $revision,
'contentformat should be included when asking content so client knows how to interpret it'
);
diff --git a/tests/phpunit/includes/api/query/ApiQueryTest.php b/tests/phpunit/includes/api/query/ApiQueryTest.php
index 1b1886e17d63..7fb53073dbc2 100644
--- a/tests/phpunit/includes/api/query/ApiQueryTest.php
+++ b/tests/phpunit/includes/api/query/ApiQueryTest.php
@@ -25,7 +25,7 @@ class ApiQueryTest extends ApiTestCase {
$this->assertArrayHasKey( 'normalized', $data[0]['query'] );
// Forge a normalized title
- $to = Title::newFromText( $wgMetaNamespace.':ArticleA' );
+ $to = Title::newFromText( $wgMetaNamespace . ':ArticleA' );
$this->assertEquals(
array(
@@ -47,7 +47,7 @@ class ApiQueryTest extends ApiTestCase {
function testTitlesAreRejectedIfInvalid() {
$title = false;
- while( !$title || Title::newFromText( $title )->exists() ) {
+ while ( !$title || Title::newFromText( $title )->exists() ) {
$title = md5( mt_rand( 0, 10000 ) + rand( 0, 999000 ) );
}
diff --git a/tests/phpunit/includes/cache/GenderCacheTest.php b/tests/phpunit/includes/cache/GenderCacheTest.php
index 52cdc78c5e47..ee3db3e8a6cc 100644
--- a/tests/phpunit/includes/cache/GenderCacheTest.php
+++ b/tests/phpunit/includes/cache/GenderCacheTest.php
@@ -15,7 +15,7 @@ class GenderCacheTest extends MediaWikiLangTestCase {
function addDBData() {
$user = User::newFromName( 'UTMale' );
- if( $user->getID() == 0 ) {
+ if ( $user->getID() == 0 ) {
$user->addToDatabase();
$user->setPassword( 'UTMalePassword' );
}
@@ -24,7 +24,7 @@ class GenderCacheTest extends MediaWikiLangTestCase {
$user->saveSettings();
$user = User::newFromName( 'UTFemale' );
- if( $user->getID() == 0 ) {
+ if ( $user->getID() == 0 ) {
$user->addToDatabase();
$user->setPassword( 'UTFemalePassword' );
}
@@ -33,7 +33,7 @@ class GenderCacheTest extends MediaWikiLangTestCase {
$user->saveSettings();
$user = User::newFromName( 'UTDefaultGender' );
- if( $user->getID() == 0 ) {
+ if ( $user->getID() == 0 ) {
$user->addToDatabase();
$user->setPassword( 'UTDefaultGenderPassword' );
}
diff --git a/tests/phpunit/includes/cache/ProcessCacheLRUTest.php b/tests/phpunit/includes/cache/ProcessCacheLRUTest.php
index 1c081b8e5abe..c7e75d99c10a 100644
--- a/tests/phpunit/includes/cache/ProcessCacheLRUTest.php
+++ b/tests/phpunit/includes/cache/ProcessCacheLRUTest.php
@@ -24,7 +24,7 @@ class ProcessCacheLRUTest extends MediaWikiTestCase {
*/
function fillCache( &$cache, $numEntries ) {
// Fill cache with three values
- for( $i=1; $i<=$numEntries; $i++) {
+ for ( $i = 1; $i <= $numEntries; $i++ ) {
$cache->set( "cache-key-$i", "prop-$i", "value-$i" );
}
}
@@ -36,10 +36,10 @@ class ProcessCacheLRUTest extends MediaWikiTestCase {
function getExpectedCache( $cacheMaxEntries, $entryToFill ) {
$expected = array();
- if( $entryToFill === 0 ) {
+ if ( $entryToFill === 0 ) {
# The cache is empty!
return array();
- } elseif( $entryToFill <= $cacheMaxEntries ) {
+ } elseif ( $entryToFill <= $cacheMaxEntries ) {
# Cache is not fully filled
$firstKey = 1;
} else {
@@ -47,9 +47,9 @@ class ProcessCacheLRUTest extends MediaWikiTestCase {
$firstKey = 1 + $entryToFill - $cacheMaxEntries;
}
- $lastKey = $entryToFill;
+ $lastKey = $entryToFill;
- for( $i=$firstKey; $i<=$lastKey; $i++ ) {
+ for ( $i = $firstKey; $i <= $lastKey; $i++ ) {
$expected["cache-key-$i"] = array( "prop-$i" => "value-$i" );
}
return $expected;
@@ -61,7 +61,7 @@ class ProcessCacheLRUTest extends MediaWikiTestCase {
function testPhpUnitArrayEquality() {
$one = array( 'A' => 1, 'B' => 2 );
$two = array( 'B' => 2, 'A' => 1 );
- $this->assertEquals( $one, $two ); // ==
+ $this->assertEquals( $one, $two ); // ==
$this->assertNotSame( $one, $two ); // ===
}
@@ -118,7 +118,7 @@ class ProcessCacheLRUTest extends MediaWikiTestCase {
*/
function testFillingCache( $cacheMaxEntries, $entryToFill, $msg = '' ) {
$cache = new ProcessCacheLRUTestable( $cacheMaxEntries );
- $this->fillCache( $cache, $entryToFill);
+ $this->fillCache( $cache, $entryToFill );
$this->assertSame(
$this->getExpectedCache( $cacheMaxEntries, $entryToFill ),
@@ -134,12 +134,11 @@ class ProcessCacheLRUTest extends MediaWikiTestCase {
public static function provideCacheFilling() {
// ($cacheMaxEntries, $entryToFill, $msg='')
return array(
- array( 1, 0 ),
- array( 1, 1 ),
- array( 1, 2 ), # overflow
+ array( 1, 0 ),
+ array( 1, 1 ),
+ array( 1, 2 ), # overflow
array( 5, 33 ), # overflow
);
-
}
/**
@@ -167,7 +166,7 @@ class ProcessCacheLRUTest extends MediaWikiTestCase {
function testRecentlyAccessedKeyStickIn() {
$cache = new ProcessCacheLRUTestable( 2 );
- $cache->set( 'first' , 'prop1', 'value1' );
+ $cache->set( 'first', 'prop1', 'value1' );
$cache->set( 'second', 'prop2', 'value2' );
// Get first
@@ -233,6 +232,7 @@ class ProcessCacheLRUTestable extends ProcessCacheLRU {
public function getCache() {
return $this->cache;
}
+
public function getEntriesCount() {
return count( $this->cache );
}
diff --git a/tests/phpunit/includes/content/ContentHandlerTest.php b/tests/phpunit/includes/content/ContentHandlerTest.php
index e12c8c7f6a62..19ceadd5cc30 100644
--- a/tests/phpunit/includes/content/ContentHandlerTest.php
+++ b/tests/phpunit/includes/content/ContentHandlerTest.php
@@ -145,7 +145,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
$this->assertEquals( $expected->getCode(), $lang->getCode() );
}
- public function testGetContentText_Null( ) {
+ public function testGetContentText_Null() {
global $wgContentHandlerTextFallback;
$content = null;
@@ -163,7 +163,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
$this->assertEquals( '', $text );
}
- public function testGetContentText_TextContent( ) {
+ public function testGetContentText_TextContent() {
global $wgContentHandlerTextFallback;
$content = new WikitextContent( "hello world" );
@@ -181,7 +181,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
$this->assertEquals( $content->getNativeData(), $text );
}
- public function testGetContentText_NonTextContent( ) {
+ public function testGetContentText_NonTextContent() {
global $wgContentHandlerTextFallback;
$content = new DummyContentForTesting( "hello world" );
@@ -213,15 +213,15 @@ class ContentHandlerTest extends MediaWikiTestCase {
return array(
array( 'hallo', 'Help:Test', null, null, CONTENT_MODEL_WIKITEXT, 'hallo', false ),
array( 'hallo', 'MediaWiki:Test.js', null, null, CONTENT_MODEL_JAVASCRIPT, 'hallo', false ),
- array( serialize('hallo'), 'Dummy:Test', null, null, "testing", 'hallo', false ),
+ array( serialize( 'hallo' ), 'Dummy:Test', null, null, "testing", 'hallo', false ),
array( 'hallo', 'Help:Test', null, CONTENT_FORMAT_WIKITEXT, CONTENT_MODEL_WIKITEXT, 'hallo', false ),
array( 'hallo', 'MediaWiki:Test.js', null, CONTENT_FORMAT_JAVASCRIPT, CONTENT_MODEL_JAVASCRIPT, 'hallo', false ),
- array( serialize('hallo'), 'Dummy:Test', null, "testing", "testing", 'hallo', false ),
+ array( serialize( 'hallo' ), 'Dummy:Test', null, "testing", "testing", 'hallo', false ),
array( 'hallo', 'Help:Test', CONTENT_MODEL_CSS, null, CONTENT_MODEL_CSS, 'hallo', false ),
array( 'hallo', 'MediaWiki:Test.js', CONTENT_MODEL_CSS, null, CONTENT_MODEL_CSS, 'hallo', false ),
- array( serialize('hallo'), 'Dummy:Test', CONTENT_MODEL_CSS, null, CONTENT_MODEL_CSS, serialize('hallo'), false ),
+ array( serialize( 'hallo' ), 'Dummy:Test', CONTENT_MODEL_CSS, null, CONTENT_MODEL_CSS, serialize( 'hallo' ), false ),
array( 'hallo', 'Help:Test', CONTENT_MODEL_WIKITEXT, "testing", null, null, true ),
array( 'hallo', 'MediaWiki:Test.js', CONTENT_MODEL_CSS, "testing", null, null, true ),
@@ -245,10 +245,14 @@ class ContentHandlerTest extends MediaWikiTestCase {
$this->assertEquals( $expectedModelId, $content->getModel(), 'bad model id' );
$this->assertEquals( $expectedNativeData, $content->getNativeData(), 'bads native data' );
} catch ( MWException $ex ) {
- if ( !$shouldFail ) $this->fail( "ContentHandler::makeContent failed unexpectedly: " . $ex->getMessage() );
- else $this->assertTrue( true ); // dummy, so we don't get the "test did not perform any assertions" message.
+ if ( !$shouldFail ) {
+ $this->fail( "ContentHandler::makeContent failed unexpectedly: " . $ex->getMessage() );
+ }
+ else {
+ // dummy, so we don't get the "test did not perform any assertions" message.
+ $this->assertTrue( true );
+ }
}
-
}
/*
@@ -292,7 +296,7 @@ class DummyContentHandlerForTesting extends ContentHandler {
* @return String serialized form of the content
*/
public function serializeContent( Content $content, $format = null ) {
- return $content->serialize();
+ return $content->serialize();
}
/**
diff --git a/tests/phpunit/includes/content/CssContentTest.php b/tests/phpunit/includes/content/CssContentTest.php
index b08a468b513c..8f53dd3e9a95 100644
--- a/tests/phpunit/includes/content/CssContentTest.php
+++ b/tests/phpunit/includes/content/CssContentTest.php
@@ -62,7 +62,7 @@ class CssContentTest extends MediaWikiTestCase {
$this->assertEquals( CONTENT_MODEL_CSS, $content->getContentHandler()->getModelID() );
}
- public static function dataEquals( ) {
+ public static function dataEquals() {
return array(
array( new CssContent( 'hallo' ), null, false ),
array( new CssContent( 'hallo' ), new CssContent( 'hallo' ), true ),
diff --git a/tests/phpunit/includes/content/JavaScriptContentTest.php b/tests/phpunit/includes/content/JavaScriptContentTest.php
index 18df53fde8cc..2d693feb3db0 100644
--- a/tests/phpunit/includes/content/JavaScriptContentTest.php
+++ b/tests/phpunit/includes/content/JavaScriptContentTest.php
@@ -39,16 +39,16 @@ class JavaScriptContentTest extends TextContentTest {
public static function dataGetSection() {
return array(
array( WikitextContentTest::$sections,
- '0',
- null
+ '0',
+ null
),
array( WikitextContentTest::$sections,
- '2',
- null
+ '2',
+ null
),
array( WikitextContentTest::$sections,
- '8',
- null
+ '8',
+ null
),
);
}
@@ -57,39 +57,39 @@ class JavaScriptContentTest extends TextContentTest {
public static function dataReplaceSection() {
return array(
array( WikitextContentTest::$sections,
- '0',
- 'No more',
- null,
- null
+ '0',
+ 'No more',
+ null,
+ null
),
array( WikitextContentTest::$sections,
- '',
- 'No more',
- null,
- null
+ '',
+ 'No more',
+ null,
+ null
),
array( WikitextContentTest::$sections,
- '2',
- "== TEST ==\nmore fun",
- null,
- null
+ '2',
+ "== TEST ==\nmore fun",
+ null,
+ null
),
array( WikitextContentTest::$sections,
- '8',
- 'No more',
- null,
- null
+ '8',
+ 'No more',
+ null,
+ null
),
array( WikitextContentTest::$sections,
- 'new',
- 'No more',
- 'New',
- null
+ 'new',
+ 'No more',
+ 'New',
+ null
),
);
}
- public function testAddSectionHeader( ) {
+ public function testAddSectionHeader() {
$content = $this->newContent( 'hello world' );
$c = $content->addSectionHeader( 'test' );
@@ -114,10 +114,10 @@ class JavaScriptContentTest extends TextContentTest {
public static function dataPreloadTransform() {
return array(
array( 'hello this is ~~~',
- 'hello this is ~~~',
+ 'hello this is ~~~',
),
array( 'hello \'\'this\'\' is <noinclude>foo</noinclude><includeonly>bar</includeonly>',
- 'hello \'\'this\'\' is <noinclude>foo</noinclude><includeonly>bar</includeonly>',
+ 'hello \'\'this\'\' is <noinclude>foo</noinclude><includeonly>bar</includeonly>',
),
);
}
@@ -125,13 +125,13 @@ class JavaScriptContentTest extends TextContentTest {
public static function dataGetRedirectTarget() {
return array(
array( '#REDIRECT [[Test]]',
- null,
+ null,
),
array( '#REDIRECT Test',
- null,
+ null,
),
array( '* #REDIRECT [[Test]]',
- null,
+ null,
),
);
}
@@ -159,59 +159,59 @@ class JavaScriptContentTest extends TextContentTest {
public static function dataIsCountable() {
return array(
array( '',
- null,
- 'any',
- true
+ null,
+ 'any',
+ true
),
array( 'Foo',
- null,
- 'any',
- true
+ null,
+ 'any',
+ true
),
array( 'Foo',
- null,
- 'comma',
- false
+ null,
+ 'comma',
+ false
),
array( 'Foo, bar',
- null,
- 'comma',
- false
+ null,
+ 'comma',
+ false
),
array( 'Foo',
- null,
- 'link',
- false
+ null,
+ 'link',
+ false
),
array( 'Foo [[bar]]',
- null,
- 'link',
- false
+ null,
+ 'link',
+ false
),
array( 'Foo',
- true,
- 'link',
- false
+ true,
+ 'link',
+ false
),
array( 'Foo [[bar]]',
- false,
- 'link',
- false
+ false,
+ 'link',
+ false
),
array( '#REDIRECT [[bar]]',
- true,
- 'any',
- true
+ true,
+ 'any',
+ true
),
array( '#REDIRECT [[bar]]',
- true,
- 'comma',
- false
+ true,
+ 'comma',
+ false
),
array( '#REDIRECT [[bar]]',
- true,
- 'link',
- false
+ true,
+ 'link',
+ false
),
);
}
@@ -219,28 +219,28 @@ class JavaScriptContentTest extends TextContentTest {
public static function dataGetTextForSummary() {
return array(
array( "hello\nworld.",
- 16,
- 'hello world.',
+ 16,
+ 'hello world.',
),
array( 'hello world.',
- 8,
- 'hello...',
+ 8,
+ 'hello...',
),
array( '[[hello world]].',
- 8,
- '[[hel...',
+ 8,
+ '[[hel...',
),
);
}
- public function testMatchMagicWord( ) {
+ public function testMatchMagicWord() {
$mw = MagicWord::get( "staticredirect" );
$content = $this->newContent( "#REDIRECT [[FOO]]\n__STATICREDIRECT__" );
$this->assertFalse( $content->matchMagicWord( $mw ), "should not have matched magic word, since it's not wikitext" );
}
- public function testUpdateRedirect( ) {
+ public function testUpdateRedirect() {
$target = Title::newFromText( "testUpdateRedirect_target" );
$content = $this->newContent( "#REDIRECT [[Someplace]]" );
@@ -261,7 +261,7 @@ class JavaScriptContentTest extends TextContentTest {
$this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $content->getContentHandler()->getModelID() );
}
- public static function dataEquals( ) {
+ public static function dataEquals() {
return array(
array( new JavaScriptContent( "hallo" ), null, false ),
array( new JavaScriptContent( "hallo" ), new JavaScriptContent( "hallo" ), true ),
diff --git a/tests/phpunit/includes/content/TextContentTest.php b/tests/phpunit/includes/content/TextContentTest.php
index 57b7c1023f6c..382f71a8664e 100644
--- a/tests/phpunit/includes/content/TextContentTest.php
+++ b/tests/phpunit/includes/content/TextContentTest.php
@@ -143,7 +143,7 @@ class TextContentTest extends MediaWikiLangTestCase {
*/
public function testGetRedirectTarget( $text, $expected ) {
$content = $this->newContent( $text );
- $t = $content->getRedirectTarget( );
+ $t = $content->getRedirectTarget();
if ( is_null( $expected ) ) {
$this->assertNull( $t, "text should not have generated a redirect target: $text" );
@@ -158,7 +158,7 @@ class TextContentTest extends MediaWikiLangTestCase {
public function testIsRedirect( $text, $expected ) {
$content = $this->newContent( $text );
- $this->assertEquals( !is_null($expected), $content->isRedirect() );
+ $this->assertEquals( !is_null( $expected ), $content->isRedirect() );
}
/**
@@ -184,29 +184,28 @@ class TextContentTest extends MediaWikiLangTestCase {
public static function dataIsCountable() {
return array(
array( '',
- null,
- 'any',
- true
+ null,
+ 'any',
+ true
),
array( 'Foo',
- null,
- 'any',
- true
+ null,
+ 'any',
+ true
),
array( 'Foo',
- null,
- 'comma',
- false
+ null,
+ 'comma',
+ false
),
array( 'Foo, bar',
- null,
- 'comma',
- false
+ null,
+ 'comma',
+ false
),
);
}
-
/**
* @dataProvider dataIsCountable
* @group Database
@@ -223,22 +222,22 @@ class TextContentTest extends MediaWikiLangTestCase {
$wgArticleCountMethod = $old;
$this->assertEquals( $expected, $v, 'isCountable() returned unexpected value ' . var_export( $v, true )
- . ' instead of ' . var_export( $expected, true ) . " in mode `$mode` for text \"$text\"" );
+ . ' instead of ' . var_export( $expected, true ) . " in mode `$mode` for text \"$text\"" );
}
public static function dataGetTextForSummary() {
return array(
array( "hello\nworld.",
- 16,
- 'hello world.',
+ 16,
+ 'hello world.',
),
array( 'hello world.',
- 8,
- 'hello...',
+ 8,
+ 'hello...',
),
array( '[[hello world]].',
- 8,
- '[[hel...',
+ 8,
+ '[[hel...',
),
);
}
@@ -252,8 +251,7 @@ class TextContentTest extends MediaWikiLangTestCase {
$this->assertEquals( $expected, $content->getTextForSummary( $maxlength ) );
}
-
- public function testGetTextForSearchIndex( ) {
+ public function testGetTextForSearchIndex() {
$content = $this->newContent( 'hello world.' );
$this->assertEquals( 'hello world.', $content->getTextForSearchIndex() );
@@ -267,19 +265,19 @@ class TextContentTest extends MediaWikiLangTestCase {
$this->assertEquals( 'hello world.', $copy->getNativeData() );
}
- public function testGetSize( ) {
+ public function testGetSize() {
$content = $this->newContent( 'hello world.' );
$this->assertEquals( 12, $content->getSize() );
}
- public function testGetNativeData( ) {
+ public function testGetNativeData() {
$content = $this->newContent( 'hello world.' );
$this->assertEquals( 'hello world.', $content->getNativeData() );
}
- public function testGetWikitextForTransclusion( ) {
+ public function testGetWikitextForTransclusion() {
$content = $this->newContent( 'hello world.' );
$this->assertEquals( 'hello world.', $content->getWikitextForTransclusion() );
@@ -297,7 +295,7 @@ class TextContentTest extends MediaWikiLangTestCase {
$this->assertEquals( CONTENT_MODEL_TEXT, $content->getContentHandler()->getModelID() );
}
- public static function dataIsEmpty( ) {
+ public static function dataIsEmpty() {
return array(
array( '', true ),
array( ' ', false ),
@@ -315,7 +313,7 @@ class TextContentTest extends MediaWikiLangTestCase {
$this->assertEquals( $empty, $content->isEmpty() );
}
- public static function dataEquals( ) {
+ public static function dataEquals() {
return array(
array( new TextContent( "hallo" ), null, false ),
array( new TextContent( "hallo" ), new TextContent( "hallo" ), true ),
@@ -334,13 +332,13 @@ class TextContentTest extends MediaWikiLangTestCase {
public static function dataGetDeletionUpdates() {
return array(
- array("TextContentTest_testGetSecondaryDataUpdates_1",
+ array( "TextContentTest_testGetSecondaryDataUpdates_1",
CONTENT_MODEL_TEXT, "hello ''world''\n",
- array( )
+ array()
),
- array("TextContentTest_testGetSecondaryDataUpdates_2",
+ array( "TextContentTest_testGetSecondaryDataUpdates_2",
CONTENT_MODEL_TEXT, "hello [[world test 21344]]\n",
- array( )
+ array()
),
// TODO: more...?
);
@@ -363,7 +361,7 @@ class TextContentTest extends MediaWikiLangTestCase {
// make updates accessible by class name
foreach ( $updates as $update ) {
$class = get_class( $update );
- $updates[ $class ] = $update;
+ $updates[$class] = $update;
}
if ( !$expectedStuff ) {
@@ -374,7 +372,7 @@ class TextContentTest extends MediaWikiLangTestCase {
foreach ( $expectedStuff as $class => $fieldValues ) {
$this->assertArrayHasKey( $class, $updates, "missing an update of type $class" );
- $update = $updates[ $class ];
+ $update = $updates[$class];
foreach ( $fieldValues as $field => $value ) {
$v = $update->$field; #if the field doesn't exist, just crash and burn
diff --git a/tests/phpunit/includes/content/WikitextContentHandlerTest.php b/tests/phpunit/includes/content/WikitextContentHandlerTest.php
index 8121099c97a0..0f6a968b62db 100644
--- a/tests/phpunit/includes/content/WikitextContentHandlerTest.php
+++ b/tests/phpunit/includes/content/WikitextContentHandlerTest.php
@@ -16,7 +16,7 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase {
$this->handler = ContentHandler::getForModelID( CONTENT_MODEL_WIKITEXT );
}
- public function testSerializeContent( ) {
+ public function testSerializeContent() {
$content = new WikitextContent( 'hello world' );
$this->assertEquals( 'hello world', $this->handler->serializeContent( $content ) );
@@ -30,7 +30,7 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase {
}
}
- public function testUnserializeContent( ) {
+ public function testUnserializeContent() {
$content = $this->handler->unserializeContent( 'hello world' );
$this->assertEquals( 'hello world', $content->getNativeData() );
@@ -52,7 +52,7 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase {
$this->assertEquals( '', $content->getNativeData() );
}
- public static function dataIsSupportedFormat( ) {
+ public static function dataIsSupportedFormat() {
return array(
array( null, true ),
array( CONTENT_FORMAT_WIKITEXT, true ),
@@ -67,21 +67,22 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase {
$this->assertEquals( $supported, $this->handler->isSupportedFormat( $format ) );
}
- public static function dataMerge3( ) {
+ public static function dataMerge3() {
return array(
- array( "first paragraph
+ array(
+ "first paragraph
second paragraph\n",
- "FIRST paragraph
+ "FIRST paragraph
second paragraph\n",
- "first paragraph
+ "first paragraph
SECOND paragraph\n",
- "FIRST paragraph
+ "FIRST paragraph
SECOND paragraph\n",
),
@@ -89,13 +90,12 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase {
array( "first paragraph
second paragraph\n",
- "Bla bla\n",
+ "Bla bla\n",
- "Blubberdibla\n",
+ "Blubberdibla\n",
- false,
+ false,
),
-
);
}
@@ -115,7 +115,7 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase {
$this->assertEquals( $expected, $merged ? $merged->getNativeData() : $merged );
}
- public static function dataGetAutosummary( ) {
+ public static function dataGetAutosummary() {
return array(
array(
'Hello there, world!',
diff --git a/tests/phpunit/includes/content/WikitextContentTest.php b/tests/phpunit/includes/content/WikitextContentTest.php
index 7cf473ea7870..c9eecf7f6424 100644
--- a/tests/phpunit/includes/content/WikitextContentTest.php
+++ b/tests/phpunit/includes/content/WikitextContentTest.php
@@ -7,10 +7,7 @@
* ^--- needed, because we do need the database to test link updates
*/
class WikitextContentTest extends TextContentTest {
-
- static $sections =
-
-"Intro
+ static $sections = "Intro
== stuff ==
hello world
@@ -102,17 +99,17 @@ more stuff
public static function dataGetSection() {
return array(
array( WikitextContentTest::$sections,
- "0",
- "Intro"
+ "0",
+ "Intro"
),
array( WikitextContentTest::$sections,
- "2",
-"== test ==
+ "2",
+ "== test ==
just a test"
),
array( WikitextContentTest::$sections,
- "8",
- false
+ "8",
+ false
),
);
}
@@ -136,34 +133,34 @@ just a test"
public static function dataReplaceSection() {
return array(
array( WikitextContentTest::$sections,
- "0",
- "No more",
- null,
- trim( preg_replace( '/^Intro/sm', 'No more', WikitextContentTest::$sections ) )
+ "0",
+ "No more",
+ null,
+ trim( preg_replace( '/^Intro/sm', 'No more', WikitextContentTest::$sections ) )
),
array( WikitextContentTest::$sections,
- "",
- "No more",
- null,
- "No more"
+ "",
+ "No more",
+ null,
+ "No more"
),
array( WikitextContentTest::$sections,
- "2",
- "== TEST ==\nmore fun",
- null,
- trim( preg_replace( '/^== test ==.*== foo ==/sm', "== TEST ==\nmore fun\n\n== foo ==", WikitextContentTest::$sections ) )
+ "2",
+ "== TEST ==\nmore fun",
+ null,
+ trim( preg_replace( '/^== test ==.*== foo ==/sm', "== TEST ==\nmore fun\n\n== foo ==", WikitextContentTest::$sections ) )
),
array( WikitextContentTest::$sections,
- "8",
- "No more",
- null,
- WikitextContentTest::$sections
+ "8",
+ "No more",
+ null,
+ WikitextContentTest::$sections
),
array( WikitextContentTest::$sections,
- "new",
- "No more",
- "New",
- trim( WikitextContentTest::$sections ) . "\n\n\n== New ==\n\nNo more"
+ "new",
+ "No more",
+ "New",
+ trim( WikitextContentTest::$sections ) . "\n\n\n== New ==\n\nNo more"
),
);
}
@@ -178,7 +175,7 @@ just a test"
$this->assertEquals( $expected, is_null( $c ) ? null : $c->getNativeData() );
}
- public function testAddSectionHeader( ) {
+ public function testAddSectionHeader() {
$content = $this->newContent( 'hello world' );
$content = $content->addSectionHeader( 'test' );
@@ -188,10 +185,10 @@ just a test"
public static function dataPreSaveTransform() {
return array(
array( 'hello this is ~~~',
- "hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]",
+ "hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]",
),
array( 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
- 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
+ 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
),
array( // rtrim
" Foo \n ",
@@ -203,10 +200,10 @@ just a test"
public static function dataPreloadTransform() {
return array(
array( 'hello this is ~~~',
- "hello this is ~~~",
+ "hello this is ~~~",
),
array( 'hello \'\'this\'\' is <noinclude>foo</noinclude><includeonly>bar</includeonly>',
- 'hello \'\'this\'\' is bar',
+ 'hello \'\'this\'\' is bar',
),
);
}
@@ -214,13 +211,13 @@ just a test"
public static function dataGetRedirectTarget() {
return array(
array( '#REDIRECT [[Test]]',
- 'Test',
+ 'Test',
),
array( '#REDIRECT Test',
- null,
+ null,
),
array( '* #REDIRECT [[Test]]',
- null,
+ null,
),
);
}
@@ -265,64 +262,64 @@ just a test"
public static function dataIsCountable() {
return array(
array( '',
- null,
- 'any',
- true
+ null,
+ 'any',
+ true
),
array( 'Foo',
- null,
- 'any',
- true
+ null,
+ 'any',
+ true
),
array( 'Foo',
- null,
- 'comma',
- false
+ null,
+ 'comma',
+ false
),
array( 'Foo, bar',
- null,
- 'comma',
- true
+ null,
+ 'comma',
+ true
),
array( 'Foo',
- null,
- 'link',
- false
+ null,
+ 'link',
+ false
),
array( 'Foo [[bar]]',
- null,
- 'link',
- true
+ null,
+ 'link',
+ true
),
array( 'Foo',
- true,
- 'link',
- true
+ true,
+ 'link',
+ true
),
array( 'Foo [[bar]]',
- false,
- 'link',
- false
+ false,
+ 'link',
+ false
),
array( '#REDIRECT [[bar]]',
- true,
- 'any',
- false
+ true,
+ 'any',
+ false
),
array( '#REDIRECT [[bar]]',
- true,
- 'comma',
- false
+ true,
+ 'comma',
+ false
),
array( '#REDIRECT [[bar]]',
- true,
- 'link',
- false
+ true,
+ 'link',
+ false
),
);
}
- public function testMatchMagicWord( ) {
+ public function testMatchMagicWord() {
$mw = MagicWord::get( "staticredirect" );
$content = $this->newContent( "#REDIRECT [[FOO]]\n__STATICREDIRECT__" );
@@ -332,7 +329,7 @@ just a test"
$this->assertFalse( $content->matchMagicWord( $mw ), "should not have matched magic word" );
}
- public function testUpdateRedirect( ) {
+ public function testUpdateRedirect() {
$target = Title::newFromText( "testUpdateRedirect_target" );
// test with non-redirect page
@@ -363,7 +360,7 @@ just a test"
$this->assertEquals( CONTENT_MODEL_WIKITEXT, $content->getContentHandler()->getModelID() );
}
- public static function dataEquals( ) {
+ public static function dataEquals() {
return array(
array( new WikitextContent( "hallo" ), null, false ),
array( new WikitextContent( "hallo" ), new WikitextContent( "hallo" ), true ),
@@ -375,16 +372,15 @@ just a test"
public static function dataGetDeletionUpdates() {
return array(
- array("WikitextContentTest_testGetSecondaryDataUpdates_1",
+ array( "WikitextContentTest_testGetSecondaryDataUpdates_1",
CONTENT_MODEL_WIKITEXT, "hello ''world''\n",
- array( 'LinksDeletionUpdate' => array( ) )
+ array( 'LinksDeletionUpdate' => array() )
),
- array("WikitextContentTest_testGetSecondaryDataUpdates_2",
+ array( "WikitextContentTest_testGetSecondaryDataUpdates_2",
CONTENT_MODEL_WIKITEXT, "hello [[world test 21344]]\n",
- array( 'LinksDeletionUpdate' => array( ) )
+ array( 'LinksDeletionUpdate' => array() )
),
// @todo: more...?
);
}
-
}
diff --git a/tests/phpunit/includes/db/DatabaseSQLTest.php b/tests/phpunit/includes/db/DatabaseSQLTest.php
index 9a62abc92057..097924380e7b 100644
--- a/tests/phpunit/includes/db/DatabaseSQLTest.php
+++ b/tests/phpunit/includes/db/DatabaseSQLTest.php
@@ -39,8 +39,8 @@ class DatabaseSQLTest extends MediaWikiTestCase {
'conds' => array( 'alias' => 'text' ),
),
"SELECT field,field2 AS alias " .
- "FROM `unittest_table` " .
- "WHERE alias = 'text'"
+ "FROM `unittest_table` " .
+ "WHERE alias = 'text'"
),
array(
array(
@@ -50,10 +50,10 @@ class DatabaseSQLTest extends MediaWikiTestCase {
'options' => array( 'LIMIT' => 1, 'ORDER BY' => 'field' ),
),
"SELECT field,field2 AS alias " .
- "FROM `unittest_table` " .
- "WHERE alias = 'text' " .
- "ORDER BY field " .
- "LIMIT 1"
+ "FROM `unittest_table` " .
+ "WHERE alias = 'text' " .
+ "ORDER BY field " .
+ "LIMIT 1"
),
array(
array(
@@ -63,13 +63,13 @@ class DatabaseSQLTest extends MediaWikiTestCase {
'options' => array( 'LIMIT' => 1, 'ORDER BY' => 'field' ),
'join_conds' => array( 't2' => array(
'LEFT JOIN', 'tid = t2.id'
- )),
+ ) ),
),
"SELECT tid,field,field2 AS alias,t2.id " .
- "FROM `unittest_table` LEFT JOIN `unittest_table2` `t2` ON ((tid = t2.id)) " .
- "WHERE alias = 'text' " .
- "ORDER BY field " .
- "LIMIT 1"
+ "FROM `unittest_table` LEFT JOIN `unittest_table2` `t2` ON ((tid = t2.id)) " .
+ "WHERE alias = 'text' " .
+ "ORDER BY field " .
+ "LIMIT 1"
),
array(
array(
@@ -79,13 +79,13 @@ class DatabaseSQLTest extends MediaWikiTestCase {
'options' => array( 'LIMIT' => 1, 'GROUP BY' => 'field', 'HAVING' => 'COUNT(*) > 1' ),
'join_conds' => array( 't2' => array(
'LEFT JOIN', 'tid = t2.id'
- )),
+ ) ),
),
"SELECT tid,field,field2 AS alias,t2.id " .
- "FROM `unittest_table` LEFT JOIN `unittest_table2` `t2` ON ((tid = t2.id)) " .
- "WHERE alias = 'text' " .
- "GROUP BY field HAVING COUNT(*) > 1 " .
- "LIMIT 1"
+ "FROM `unittest_table` LEFT JOIN `unittest_table2` `t2` ON ((tid = t2.id)) " .
+ "WHERE alias = 'text' " .
+ "GROUP BY field HAVING COUNT(*) > 1 " .
+ "LIMIT 1"
),
array(
array(
@@ -95,13 +95,13 @@ class DatabaseSQLTest extends MediaWikiTestCase {
'options' => array( 'LIMIT' => 1, 'GROUP BY' => array( 'field', 'field2' ), 'HAVING' => array( 'COUNT(*) > 1', 'field' => 1 ) ),
'join_conds' => array( 't2' => array(
'LEFT JOIN', 'tid = t2.id'
- )),
+ ) ),
),
"SELECT tid,field,field2 AS alias,t2.id " .
- "FROM `unittest_table` LEFT JOIN `unittest_table2` `t2` ON ((tid = t2.id)) " .
- "WHERE alias = 'text' " .
- "GROUP BY field,field2 HAVING (COUNT(*) > 1) AND field = '1' " .
- "LIMIT 1"
+ "FROM `unittest_table` LEFT JOIN `unittest_table2` `t2` ON ((tid = t2.id)) " .
+ "WHERE alias = 'text' " .
+ "GROUP BY field,field2 HAVING (COUNT(*) > 1) AND field = '1' " .
+ "LIMIT 1"
),
);
}
diff --git a/tests/phpunit/includes/db/DatabaseSqliteTest.php b/tests/phpunit/includes/db/DatabaseSqliteTest.php
index 3e71603f2068..7b84d4712e6c 100644
--- a/tests/phpunit/includes/db/DatabaseSqliteTest.php
+++ b/tests/phpunit/includes/db/DatabaseSqliteTest.php
@@ -3,7 +3,7 @@
class MockDatabaseSqlite extends DatabaseSqliteStandalone {
var $lastQuery;
- function __construct( ) {
+ function __construct() {
parent::__construct( ':memory:' );
}
@@ -48,8 +48,8 @@ class DatabaseSqliteTest extends MediaWikiTestCase {
private function assertResultIs( $expected, $res ) {
$this->assertNotNull( $res );
$i = 0;
- foreach( $res as $row ) {
- foreach( $expected[$i] as $key => $value ) {
+ foreach ( $res as $row ) {
+ foreach ( $expected[$i] as $key => $value ) {
$this->assertTrue( isset( $row->$key ) );
$this->assertEquals( $value, $row->$key );
}
@@ -108,38 +108,38 @@ class DatabaseSqliteTest extends MediaWikiTestCase {
$this->assertEquals( 'foo', $this->replaceVars( 'foo' ), "Don't break anything accidentally" );
$this->assertEquals( "CREATE TABLE /**/foo (foo_key INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "
- . "foo_bar TEXT, foo_name TEXT NOT NULL DEFAULT '', foo_int INTEGER, foo_int2 INTEGER );",
+ . "foo_bar TEXT, foo_name TEXT NOT NULL DEFAULT '', foo_int INTEGER, foo_int2 INTEGER );",
$this->replaceVars( "CREATE TABLE /**/foo (foo_key int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
foo_bar char(13), foo_name varchar(255) binary NOT NULL DEFAULT '', foo_int tinyint ( 8 ), foo_int2 int(16) ) ENGINE=MyISAM;" )
- );
+ );
$this->assertEquals( "CREATE TABLE foo ( foo1 REAL, foo2 REAL, foo3 REAL );",
$this->replaceVars( "CREATE TABLE foo ( foo1 FLOAT, foo2 DOUBLE( 1,10), foo3 DOUBLE PRECISION );" )
- );
+ );
$this->assertEquals( "CREATE TABLE foo ( foo_binary1 BLOB, foo_binary2 BLOB );",
$this->replaceVars( "CREATE TABLE foo ( foo_binary1 binary(16), foo_binary2 varbinary(32) );" )
- );
+ );
$this->assertEquals( "CREATE TABLE text ( text_foo TEXT );",
$this->replaceVars( "CREATE TABLE text ( text_foo tinytext );" ),
'Table name changed'
- );
+ );
$this->assertEquals( "CREATE TABLE foo ( foobar INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL );",
- $this->replaceVars("CREATE TABLE foo ( foobar INT PRIMARY KEY NOT NULL AUTO_INCREMENT );" )
- );
+ $this->replaceVars( "CREATE TABLE foo ( foobar INT PRIMARY KEY NOT NULL AUTO_INCREMENT );" )
+ );
$this->assertEquals( "CREATE TABLE foo ( foobar INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL );",
- $this->replaceVars("CREATE TABLE foo ( foobar INT PRIMARY KEY AUTO_INCREMENT NOT NULL );" )
- );
+ $this->replaceVars( "CREATE TABLE foo ( foobar INT PRIMARY KEY AUTO_INCREMENT NOT NULL );" )
+ );
$this->assertEquals( "CREATE TABLE enums( enum1 TEXT, myenum TEXT)",
$this->replaceVars( "CREATE TABLE enums( enum1 ENUM('A', 'B'), myenum ENUM ('X', 'Y'))" )
- );
+ );
$this->assertEquals( "ALTER TABLE foo ADD COLUMN foo_bar INTEGER DEFAULT 42",
$this->replaceVars( "ALTER TABLE foo\nADD COLUMN foo_bar int(10) unsigned DEFAULT 42" )
- );
+ );
}
public function testTableName() {
@@ -381,9 +381,9 @@ class DatabaseSqliteTest extends MediaWikiTestCase {
function testCaseInsensitiveLike() {
// TODO: Test this for all databases
- $db = new DatabaseSqliteStandalone( ':memory:' );
- $res = $db->query( 'SELECT "a" LIKE "A" AS a' );
- $row = $res->fetchRow();
- $this->assertFalse( (bool)$row['a'] );
+ $db = new DatabaseSqliteStandalone( ':memory:' );
+ $res = $db->query( 'SELECT "a" LIKE "A" AS a' );
+ $row = $res->fetchRow();
+ $this->assertFalse( (bool)$row['a'] );
}
}
diff --git a/tests/phpunit/includes/db/DatabaseTest.php b/tests/phpunit/includes/db/DatabaseTest.php
index 8c992c7c7739..65c80d1df6f1 100644
--- a/tests/phpunit/includes/db/DatabaseTest.php
+++ b/tests/phpunit/includes/db/DatabaseTest.php
@@ -206,7 +206,7 @@ class DatabaseTest extends MediaWikiTestCase {
private function dropFunctions() {
$this->db->query( 'DROP FUNCTION IF EXISTS mw_test_function'
- . ( $this->db->getType() == 'postgres' ? '()' : '' )
+ . ( $this->db->getType() == 'postgres' ? '()' : '' )
);
}
}
diff --git a/tests/phpunit/includes/debug/MWDebugTest.php b/tests/phpunit/includes/debug/MWDebugTest.php
index bd2c38813a57..9026cb90d646 100644
--- a/tests/phpunit/includes/debug/MWDebugTest.php
+++ b/tests/phpunit/includes/debug/MWDebugTest.php
@@ -7,7 +7,7 @@ class MWDebugTest extends MediaWikiTestCase {
parent::setUp();
// Make sure MWDebug class is enabled
static $MWDebugEnabled = false;
- if( !$MWDebugEnabled ) {
+ if ( !$MWDebugEnabled ) {
MWDebug::init();
$MWDebugEnabled = true;
}
@@ -23,10 +23,11 @@ class MWDebugTest extends MediaWikiTestCase {
function testAddLog() {
MWDebug::log( 'logging a string' );
- $this->assertEquals( array( array(
- 'msg' => 'logging a string',
- 'type' => 'log',
- 'caller' => __METHOD__ ,
+ $this->assertEquals(
+ array( array(
+ 'msg' => 'logging a string',
+ 'type' => 'log',
+ 'caller' => __METHOD__,
) ),
MWDebug::getLog()
);
@@ -34,10 +35,11 @@ class MWDebugTest extends MediaWikiTestCase {
function testAddWarning() {
MWDebug::warning( 'Warning message' );
- $this->assertEquals( array( array(
- 'msg' => 'Warning message',
- 'type' => 'warn',
- 'caller' => 'MWDebugTest::testAddWarning',
+ $this->assertEquals(
+ array( array(
+ 'msg' => 'Warning message',
+ 'type' => 'warn',
+ 'caller' => 'MWDebugTest::testAddWarning',
) ),
MWDebug::getLog()
);