4 of n.
Change-Id: I23e2409ce9eff14c3434154d236de83c93a92440
19 files changed:
$this->assertArrayHasKey( 'rollback', $data[0] );
$this->assertArrayHasKey( 'title', $data[0]['rollback'] );
$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() . "'" );
$this->markTestIncomplete( "Only one author to 'Help:UTPage', cannot test rollback" );
} else {
$this->fail( "Received error '" . $ue->getCodeString() . "'" );
class RandomImageGenerator {
private $dictionaryFile;
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
/**
* Orientations: 0th row, 0th column, EXIF orientation code, rotation 2x2 matrix that is opposite of orientation
// find the dictionary file, to generate random names
if ( !isset( $this->dictionaryFile ) ) {
// find the dictionary file, to generate random names
if ( !isset( $this->dictionaryFile ) ) {
'/usr/share/dict/words',
'/usr/dict/words',
'/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;
if ( is_file( $dictionaryFile ) and is_readable( $dictionaryFile ) ) {
$this->dictionaryFile = $dictionaryFile;
break;
function writeImages( $number, $format = 'jpg', $dir = null ) {
$filenames = $this->getRandomFilenames( $number, $format, $dir );
$imageWriteMethod = $this->getImageWriteMethod( $format );
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;
$this->{$imageWriteMethod}( $this->getImageSpec(), $format, $filename );
}
return $filenames;
$dir = getcwd();
}
$filenames = array();
$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;
$basename = $pair[0] . '_' . $pair[1];
if ( !is_null( $extension ) ) {
$basename .= '.' . $extension;
}
$originX = mt_rand( -1 * $radius, $spec['width'] + $radius );
$originY = mt_rand( -1 * $radius, $spec['height'] + $radius );
}
$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(
$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 )
$shape = $g->addChild( 'polygon' );
$shape->addAttribute( 'fill', $drawSpec['fill'] );
$shape->addAttribute( 'points', self::shapePointsToString( $drawSpec['shape'] ) );
$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() );
throw new Exception( "couldn't open $filename for writing" );
}
fwrite( $fh, $svg->asXML() );
+ if ( !fclose( $fh ) ) {
throw new Exception( "couldn't close $filename" );
}
}
throw new Exception( "couldn't close $filename" );
}
}
*/
$orientation = self::$orientations[0]; // default is normal orientation
if ( $format == 'jpg' ) {
*/
$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'] );
}
$spec = self::rotateImageSpec( $spec, $orientation['counterRotation'] );
}
$tSpec['height'] = abs( $dims['y'] );
$tSpec['fill'] = $spec['fill'];
$tSpec['draws'] = array();
$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()
);
$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;
$tPoint = self::matrixMultiply2x2( $matrix, $point['x'], $point['y'] );
$tPoint['x'] += $correctionX;
$tPoint['y'] += $correctionY;
*
* Sample command line:
* $ convert -size 100x60 xc:rgb(90,87,45) \
*
* 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
*
* -draw 'fill rgb(99,123,231) circle 59,39 56,57' \
* -draw 'fill rgb(240,12,32) circle 50,21 50,3' filename.png
*
$args = array();
$args[] = "-size " . wfEscapeShellArg( $spec['width'] . 'x' . $spec['height'] );
$args[] = wfEscapeShellArg( "xc:" . $spec['fill'] );
$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";
$fill = $draw['fill'];
$polygon = self::shapePointsToString( $draw['shape'] );
$drawCommand = "fill $fill polygon $polygon";
*/
public function getRandomColor() {
$components = array();
*/
public function getRandomColor() {
$components = array();
- for ($i = 0; $i <= 2; $i++ ) {
+ for ( $i = 0; $i <= 2; $i++ ) {
$components[] = mt_rand( 0, 255 );
}
$components[] = mt_rand( 0, 255 );
}
- return 'rgb(' . join(', ', $components) . ')';
+ return 'rgb(' . join( ', ', $components ) . ')';
// construct pairs of words
$pairs = array();
$count = count( $lines );
// 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 N random lines from a file
*
/**
* Return N random lines from a file
*
*/
$fh = fopen( $filepath, "r" );
if ( !$fh ) {
*/
$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;
}
$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 ) {
$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;
$data = parent::doApiRequest( $params, $data, true );
$module = $data[3];
$data = parent::doApiRequest( $params, $data, true );
$module = $data[3];
$printer = $module->createPrinterByName( $format );
$printer->setUnescapeAmps( false );
$printer = $module->createPrinterByName( $format );
$printer->setUnescapeAmps( false );
ob_start();
$printer->execute();
$out = ob_get_clean();
ob_start();
$printer->execute();
$out = ob_get_clean();
$printer->closePrinter();
return $out;
$printer->closePrinter();
return $out;
// Start up MediaWiki in command-line mode
require_once( "$IP/maintenance/Maintenance.php" );
// 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 {
class GenerateRandomImages extends Maintenance {
* @group medium
*/
class ApiQueryBasicTest extends ApiTestCase {
* @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()
/**
* Create a set of pages. These must not change, otherwise the tests might give wrong results.
* @see MediaWikiTestCase::addDBData()
private function merge( /*...*/ ) {
$request = array();
$expected = array();
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] );
}
$request = array_merge_recursive( $request, $v[0] );
$this->mergeExpected( $expected, $v[1] );
}
private function mergeExpected( &$all, $item ) {
foreach ( $item as $k => $v ) {
if ( array_key_exists( $k, $all ) ) {
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 );
$this->mergeExpected( $all[$k], $v );
} else {
$this->assertEquals( $all[$k], $v );
$expected = array( 'query' => $expected );
try {
$this->assertQueryResults( $expected, $result );
$expected = array( 'query' => $expected );
try {
$this->assertQueryResults( $expected, $result );
- } catch (Exception $e) {
- print("\nRequest:\n");
+ } catch ( Exception $e ) {
+ print( "\nRequest:\n" );
- print("\nExpected:\n");
+ print( "\nExpected:\n" );
+ print( "\nResult:\n" );
print_r( $result );
throw $e; // rethrow it
}
print_r( $result );
throw $e; // rethrow it
}
* @group medium
*/
function testContentComesWithContentModelAndFormat() {
* @group medium
*/
function testContentComesWithContentModelAndFormat() {
-
- $pageName = 'Help:' . __METHOD__ ;
+ $pageName = 'Help:' . __METHOD__;
$title = Title::newFromText( $pageName );
$page = WikiPage::factory( $title );
$page->doEdit( 'Some text', 'inserting content' );
$title = Title::newFromText( $pageName );
$page = WikiPage::factory( $title );
$page->doEdit( 'Some text', 'inserting content' );
) );
$this->assertArrayHasKey( 'query', $apiResult[0] );
$this->assertArrayHasKey( 'pages', $apiResult[0]['query'] );
) );
$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 );
$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'
);
$this->assertArrayHasKey( 'contentformat', $revision,
'contentformat should be included when asking content so client knows how to interpret it'
);
$this->assertArrayHasKey( 'normalized', $data[0]['query'] );
// Forge a normalized title
$this->assertArrayHasKey( 'normalized', $data[0]['query'] );
// Forge a normalized title
- $to = Title::newFromText( $wgMetaNamespace.':ArticleA' );
+ $to = Title::newFromText( $wgMetaNamespace . ':ArticleA' );
$this->assertEquals(
array(
$this->assertEquals(
array(
function testTitlesAreRejectedIfInvalid() {
$title = false;
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 ) );
}
$title = md5( mt_rand( 0, 10000 ) + rand( 0, 999000 ) );
}
function addDBData() {
$user = User::newFromName( 'UTMale' );
function addDBData() {
$user = User::newFromName( 'UTMale' );
- if( $user->getID() == 0 ) {
+ if ( $user->getID() == 0 ) {
$user->addToDatabase();
$user->setPassword( 'UTMalePassword' );
}
$user->addToDatabase();
$user->setPassword( 'UTMalePassword' );
}
$user->saveSettings();
$user = User::newFromName( 'UTFemale' );
$user->saveSettings();
$user = User::newFromName( 'UTFemale' );
- if( $user->getID() == 0 ) {
+ if ( $user->getID() == 0 ) {
$user->addToDatabase();
$user->setPassword( 'UTFemalePassword' );
}
$user->addToDatabase();
$user->setPassword( 'UTFemalePassword' );
}
$user->saveSettings();
$user = User::newFromName( 'UTDefaultGender' );
$user->saveSettings();
$user = User::newFromName( 'UTDefaultGender' );
- if( $user->getID() == 0 ) {
+ if ( $user->getID() == 0 ) {
$user->addToDatabase();
$user->setPassword( 'UTDefaultGenderPassword' );
}
$user->addToDatabase();
$user->setPassword( 'UTDefaultGenderPassword' );
}
*/
function fillCache( &$cache, $numEntries ) {
// Fill cache with three values
*/
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" );
}
}
$cache->set( "cache-key-$i", "prop-$i", "value-$i" );
}
}
function getExpectedCache( $cacheMaxEntries, $entryToFill ) {
$expected = array();
function getExpectedCache( $cacheMaxEntries, $entryToFill ) {
$expected = array();
- if( $entryToFill === 0 ) {
+ if ( $entryToFill === 0 ) {
# The cache is empty!
return array();
# The cache is empty!
return array();
- } elseif( $entryToFill <= $cacheMaxEntries ) {
+ } elseif ( $entryToFill <= $cacheMaxEntries ) {
# Cache is not fully filled
$firstKey = 1;
} else {
# Cache is not fully filled
$firstKey = 1;
} else {
$firstKey = 1 + $entryToFill - $cacheMaxEntries;
}
$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;
$expected["cache-key-$i"] = array( "prop-$i" => "value-$i" );
}
return $expected;
function testPhpUnitArrayEquality() {
$one = array( 'A' => 1, 'B' => 2 );
$two = array( 'B' => 2, 'A' => 1 );
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 ); // ===
}
$this->assertNotSame( $one, $two ); // ===
}
*/
function testFillingCache( $cacheMaxEntries, $entryToFill, $msg = '' ) {
$cache = new ProcessCacheLRUTestable( $cacheMaxEntries );
*/
function testFillingCache( $cacheMaxEntries, $entryToFill, $msg = '' ) {
$cache = new ProcessCacheLRUTestable( $cacheMaxEntries );
- $this->fillCache( $cache, $entryToFill);
+ $this->fillCache( $cache, $entryToFill );
$this->assertSame(
$this->getExpectedCache( $cacheMaxEntries, $entryToFill ),
$this->assertSame(
$this->getExpectedCache( $cacheMaxEntries, $entryToFill ),
public static function provideCacheFilling() {
// ($cacheMaxEntries, $entryToFill, $msg='')
return array(
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
);
array( 5, 33 ), # overflow
);
function testRecentlyAccessedKeyStickIn() {
$cache = new ProcessCacheLRUTestable( 2 );
function testRecentlyAccessedKeyStickIn() {
$cache = new ProcessCacheLRUTestable( 2 );
- $cache->set( 'first' , 'prop1', 'value1' );
+ $cache->set( 'first', 'prop1', 'value1' );
$cache->set( 'second', 'prop2', 'value2' );
// Get first
$cache->set( 'second', 'prop2', 'value2' );
// Get first
public function getCache() {
return $this->cache;
}
public function getCache() {
return $this->cache;
}
public function getEntriesCount() {
return count( $this->cache );
}
public function getEntriesCount() {
return count( $this->cache );
}
$this->assertEquals( $expected->getCode(), $lang->getCode() );
}
$this->assertEquals( $expected->getCode(), $lang->getCode() );
}
- public function testGetContentText_Null( ) {
+ public function testGetContentText_Null() {
global $wgContentHandlerTextFallback;
$content = null;
global $wgContentHandlerTextFallback;
$content = null;
$this->assertEquals( '', $text );
}
$this->assertEquals( '', $text );
}
- public function testGetContentText_TextContent( ) {
+ public function testGetContentText_TextContent() {
global $wgContentHandlerTextFallback;
$content = new WikitextContent( "hello world" );
global $wgContentHandlerTextFallback;
$content = new WikitextContent( "hello world" );
$this->assertEquals( $content->getNativeData(), $text );
}
$this->assertEquals( $content->getNativeData(), $text );
}
- public function testGetContentText_NonTextContent( ) {
+ public function testGetContentText_NonTextContent() {
global $wgContentHandlerTextFallback;
$content = new DummyContentForTesting( "hello world" );
global $wgContentHandlerTextFallback;
$content = new DummyContentForTesting( "hello world" );
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 ),
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( '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( '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 ),
array( 'hallo', 'Help:Test', CONTENT_MODEL_WIKITEXT, "testing", null, null, true ),
array( 'hallo', 'MediaWiki:Test.js', CONTENT_MODEL_CSS, "testing", null, null, true ),
$this->assertEquals( $expectedModelId, $content->getModel(), 'bad model id' );
$this->assertEquals( $expectedNativeData, $content->getNativeData(), 'bads native data' );
} catch ( MWException $ex ) {
$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 );
+ }
* @return String serialized form of the content
*/
public function serializeContent( Content $content, $format = null ) {
* @return String serialized form of the content
*/
public function serializeContent( Content $content, $format = null ) {
- return $content->serialize();
+ return $content->serialize();
$this->assertEquals( CONTENT_MODEL_CSS, $content->getContentHandler()->getModelID() );
}
$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 ),
return array(
array( new CssContent( 'hallo' ), null, false ),
array( new CssContent( 'hallo' ), new CssContent( 'hallo' ), true ),
public static function dataGetSection() {
return array(
array( WikitextContentTest::$sections,
public static function dataGetSection() {
return array(
array( WikitextContentTest::$sections,
),
array( WikitextContentTest::$sections,
),
array( WikitextContentTest::$sections,
),
array( WikitextContentTest::$sections,
),
array( WikitextContentTest::$sections,
public static function dataReplaceSection() {
return array(
array( WikitextContentTest::$sections,
public static function dataReplaceSection() {
return array(
array( WikitextContentTest::$sections,
- '0',
- 'No more',
- null,
- null
+ '0',
+ 'No more',
+ null,
+ null
),
array( WikitextContentTest::$sections,
),
array( WikitextContentTest::$sections,
- '',
- 'No more',
- null,
- null
+ '',
+ 'No more',
+ null,
+ null
),
array( WikitextContentTest::$sections,
),
array( WikitextContentTest::$sections,
- '2',
- "== TEST ==\nmore fun",
- null,
- null
+ '2',
+ "== TEST ==\nmore fun",
+ null,
+ null
),
array( WikitextContentTest::$sections,
),
array( WikitextContentTest::$sections,
- '8',
- 'No more',
- null,
- null
+ '8',
+ 'No more',
+ null,
+ null
),
array( WikitextContentTest::$sections,
),
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' );
$content = $this->newContent( 'hello world' );
$c = $content->addSectionHeader( 'test' );
public static function dataPreloadTransform() {
return array(
array( 'hello this is ~~~',
public static function dataPreloadTransform() {
return array(
array( 'hello this is ~~~',
),
array( 'hello \'\'this\'\' is <noinclude>foo</noinclude><includeonly>bar</includeonly>',
),
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>',
public static function dataGetRedirectTarget() {
return array(
array( '#REDIRECT [[Test]]',
public static function dataGetRedirectTarget() {
return array(
array( '#REDIRECT [[Test]]',
),
array( '#REDIRECT Test',
),
array( '#REDIRECT Test',
),
array( '* #REDIRECT [[Test]]',
),
array( '* #REDIRECT [[Test]]',
public static function dataIsCountable() {
return array(
array( '',
public static function dataIsCountable() {
return array(
array( '',
- null,
- 'comma',
- false
+ null,
+ 'comma',
+ false
- null,
- 'comma',
- false
+ null,
+ 'comma',
+ false
- null,
- 'link',
- false
+ null,
+ 'link',
+ false
- null,
- 'link',
- false
+ null,
+ 'link',
+ false
- true,
- 'link',
- false
+ true,
+ 'link',
+ false
- false,
- 'link',
- false
+ false,
+ 'link',
+ false
),
array( '#REDIRECT [[bar]]',
),
array( '#REDIRECT [[bar]]',
),
array( '#REDIRECT [[bar]]',
),
array( '#REDIRECT [[bar]]',
- true,
- 'comma',
- false
+ true,
+ 'comma',
+ false
),
array( '#REDIRECT [[bar]]',
),
array( '#REDIRECT [[bar]]',
- true,
- 'link',
- false
+ true,
+ 'link',
+ false
public static function dataGetTextForSummary() {
return array(
array( "hello\nworld.",
public static function dataGetTextForSummary() {
return array(
array( "hello\nworld.",
),
array( 'hello world.',
),
array( 'hello world.',
),
array( '[[hello world]].',
),
array( '[[hello world]].',
- 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" );
}
$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]]" );
$target = Title::newFromText( "testUpdateRedirect_target" );
$content = $this->newContent( "#REDIRECT [[Someplace]]" );
$this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $content->getContentHandler()->getModelID() );
}
$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 ),
return array(
array( new JavaScriptContent( "hallo" ), null, false ),
array( new JavaScriptContent( "hallo" ), new JavaScriptContent( "hallo" ), true ),
*/
public function testGetRedirectTarget( $text, $expected ) {
$content = $this->newContent( $text );
*/
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" );
if ( is_null( $expected ) ) {
$this->assertNull( $t, "text should not have generated a redirect target: $text" );
public function testIsRedirect( $text, $expected ) {
$content = $this->newContent( $text );
public function testIsRedirect( $text, $expected ) {
$content = $this->newContent( $text );
- $this->assertEquals( !is_null($expected), $content->isRedirect() );
+ $this->assertEquals( !is_null( $expected ), $content->isRedirect() );
public static function dataIsCountable() {
return array(
array( '',
public static function dataIsCountable() {
return array(
array( '',
- null,
- 'comma',
- false
+ null,
+ 'comma',
+ false
- null,
- 'comma',
- false
+ null,
+ 'comma',
+ false
/**
* @dataProvider dataIsCountable
* @group Database
/**
* @dataProvider dataIsCountable
* @group Database
$wgArticleCountMethod = $old;
$this->assertEquals( $expected, $v, 'isCountable() returned unexpected value ' . var_export( $v, true )
$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.",
}
public static function dataGetTextForSummary() {
return array(
array( "hello\nworld.",
),
array( 'hello world.',
),
array( 'hello world.',
),
array( '[[hello world]].',
),
array( '[[hello world]].',
$this->assertEquals( $expected, $content->getTextForSummary( $maxlength ) );
}
$this->assertEquals( $expected, $content->getTextForSummary( $maxlength ) );
}
-
- public function testGetTextForSearchIndex( ) {
+ public function testGetTextForSearchIndex() {
$content = $this->newContent( 'hello world.' );
$this->assertEquals( 'hello world.', $content->getTextForSearchIndex() );
$content = $this->newContent( 'hello world.' );
$this->assertEquals( 'hello world.', $content->getTextForSearchIndex() );
$this->assertEquals( 'hello world.', $copy->getNativeData() );
}
$this->assertEquals( 'hello world.', $copy->getNativeData() );
}
- public function testGetSize( ) {
+ public function testGetSize() {
$content = $this->newContent( 'hello world.' );
$this->assertEquals( 12, $content->getSize() );
}
$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() );
}
$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() );
$content = $this->newContent( 'hello world.' );
$this->assertEquals( 'hello world.', $content->getWikitextForTransclusion() );
$this->assertEquals( CONTENT_MODEL_TEXT, $content->getContentHandler()->getModelID() );
}
$this->assertEquals( CONTENT_MODEL_TEXT, $content->getContentHandler()->getModelID() );
}
- public static function dataIsEmpty( ) {
+ public static function dataIsEmpty() {
return array(
array( '', true ),
array( ' ', false ),
return array(
array( '', true ),
array( ' ', false ),
$this->assertEquals( $empty, $content->isEmpty() );
}
$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 ),
return array(
array( new TextContent( "hallo" ), null, false ),
array( new TextContent( "hallo" ), new TextContent( "hallo" ), true ),
public static function dataGetDeletionUpdates() {
return array(
public static function dataGetDeletionUpdates() {
return array(
- array("TextContentTest_testGetSecondaryDataUpdates_1",
+ array( "TextContentTest_testGetSecondaryDataUpdates_1",
CONTENT_MODEL_TEXT, "hello ''world''\n",
CONTENT_MODEL_TEXT, "hello ''world''\n",
- array("TextContentTest_testGetSecondaryDataUpdates_2",
+ array( "TextContentTest_testGetSecondaryDataUpdates_2",
CONTENT_MODEL_TEXT, "hello [[world test 21344]]\n",
CONTENT_MODEL_TEXT, "hello [[world test 21344]]\n",
// make updates accessible by class name
foreach ( $updates as $update ) {
$class = get_class( $update );
// make updates accessible by class name
foreach ( $updates as $update ) {
$class = get_class( $update );
- $updates[ $class ] = $update;
+ $updates[$class] = $update;
}
if ( !$expectedStuff ) {
}
if ( !$expectedStuff ) {
foreach ( $expectedStuff as $class => $fieldValues ) {
$this->assertArrayHasKey( $class, $updates, "missing an update of type $class" );
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
foreach ( $fieldValues as $field => $value ) {
$v = $update->$field; #if the field doesn't exist, just crash and burn
$this->handler = ContentHandler::getForModelID( CONTENT_MODEL_WIKITEXT );
}
$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 ) );
$content = new WikitextContent( 'hello world' );
$this->assertEquals( 'hello world', $this->handler->serializeContent( $content ) );
- public function testUnserializeContent( ) {
+ public function testUnserializeContent() {
$content = $this->handler->unserializeContent( 'hello world' );
$this->assertEquals( 'hello world', $content->getNativeData() );
$content = $this->handler->unserializeContent( 'hello world' );
$this->assertEquals( 'hello world', $content->getNativeData() );
$this->assertEquals( '', $content->getNativeData() );
}
$this->assertEquals( '', $content->getNativeData() );
}
- public static function dataIsSupportedFormat( ) {
+ public static function dataIsSupportedFormat() {
return array(
array( null, true ),
array( CONTENT_FORMAT_WIKITEXT, true ),
return array(
array( null, true ),
array( CONTENT_FORMAT_WIKITEXT, true ),
$this->assertEquals( $supported, $this->handler->isSupportedFormat( $format ) );
}
$this->assertEquals( $supported, $this->handler->isSupportedFormat( $format ) );
}
- public static function dataMerge3( ) {
+ public static function dataMerge3() {
- array( "first paragraph
+ array(
+ "first paragraph
array( "first paragraph
second paragraph\n",
array( "first paragraph
second paragraph\n",
$this->assertEquals( $expected, $merged ? $merged->getNativeData() : $merged );
}
$this->assertEquals( $expected, $merged ? $merged->getNativeData() : $merged );
}
- public static function dataGetAutosummary( ) {
+ public static function dataGetAutosummary() {
return array(
array(
'Hello there, world!',
return array(
array(
'Hello there, world!',
* ^--- needed, because we do need the database to test link updates
*/
class WikitextContentTest extends TextContentTest {
* ^--- needed, because we do need the database to test link updates
*/
class WikitextContentTest extends TextContentTest {
-
- static $sections =
-
-"Intro
+ static $sections = "Intro
public static function dataGetSection() {
return array(
array( WikitextContentTest::$sections,
public static function dataGetSection() {
return array(
array( WikitextContentTest::$sections,
),
array( WikitextContentTest::$sections,
),
array( WikitextContentTest::$sections,
just a test"
),
array( WikitextContentTest::$sections,
just a test"
),
array( WikitextContentTest::$sections,
public static function dataReplaceSection() {
return array(
array( WikitextContentTest::$sections,
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,
),
array( WikitextContentTest::$sections,
- "",
- "No more",
- null,
- "No more"
+ "",
+ "No more",
+ null,
+ "No more"
),
array( WikitextContentTest::$sections,
),
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,
),
array( WikitextContentTest::$sections,
- "8",
- "No more",
- null,
- WikitextContentTest::$sections
+ "8",
+ "No more",
+ null,
+ WikitextContentTest::$sections
),
array( 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"
$this->assertEquals( $expected, is_null( $c ) ? null : $c->getNativeData() );
}
$this->assertEquals( $expected, is_null( $c ) ? null : $c->getNativeData() );
}
- public function testAddSectionHeader( ) {
+ public function testAddSectionHeader() {
$content = $this->newContent( 'hello world' );
$content = $content->addSectionHeader( 'test' );
$content = $this->newContent( 'hello world' );
$content = $content->addSectionHeader( 'test' );
public static function dataPreSaveTransform() {
return array(
array( 'hello this is ~~~',
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>',
),
array( 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
- 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
+ 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
),
array( // rtrim
" Foo \n ",
),
array( // rtrim
" Foo \n ",
public static function dataPreloadTransform() {
return array(
array( 'hello this is ~~~',
public static function dataPreloadTransform() {
return array(
array( 'hello this is ~~~',
),
array( 'hello \'\'this\'\' is <noinclude>foo</noinclude><includeonly>bar</includeonly>',
),
array( 'hello \'\'this\'\' is <noinclude>foo</noinclude><includeonly>bar</includeonly>',
- 'hello \'\'this\'\' is bar',
+ 'hello \'\'this\'\' is bar',
public static function dataGetRedirectTarget() {
return array(
array( '#REDIRECT [[Test]]',
public static function dataGetRedirectTarget() {
return array(
array( '#REDIRECT [[Test]]',
),
array( '#REDIRECT Test',
),
array( '#REDIRECT Test',
),
array( '* #REDIRECT [[Test]]',
),
array( '* #REDIRECT [[Test]]',
public static function dataIsCountable() {
return array(
array( '',
public static function dataIsCountable() {
return array(
array( '',
- null,
- 'comma',
- false
+ null,
+ 'comma',
+ false
- null,
- 'comma',
- true
+ null,
+ 'comma',
+ true
- null,
- 'link',
- false
+ null,
+ 'link',
+ false
- false,
- 'link',
- false
+ false,
+ 'link',
+ false
),
array( '#REDIRECT [[bar]]',
),
array( '#REDIRECT [[bar]]',
),
array( '#REDIRECT [[bar]]',
),
array( '#REDIRECT [[bar]]',
- true,
- 'comma',
- false
+ true,
+ 'comma',
+ false
),
array( '#REDIRECT [[bar]]',
),
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__" );
$mw = MagicWord::get( "staticredirect" );
$content = $this->newContent( "#REDIRECT [[FOO]]\n__STATICREDIRECT__" );
$this->assertFalse( $content->matchMagicWord( $mw ), "should not have matched magic word" );
}
$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
$target = Title::newFromText( "testUpdateRedirect_target" );
// test with non-redirect page
$this->assertEquals( CONTENT_MODEL_WIKITEXT, $content->getContentHandler()->getModelID() );
}
$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 ),
return array(
array( new WikitextContent( "hallo" ), null, false ),
array( new WikitextContent( "hallo" ), new WikitextContent( "hallo" ), true ),
public static function dataGetDeletionUpdates() {
return array(
public static function dataGetDeletionUpdates() {
return array(
- array("WikitextContentTest_testGetSecondaryDataUpdates_1",
+ array( "WikitextContentTest_testGetSecondaryDataUpdates_1",
CONTENT_MODEL_WIKITEXT, "hello ''world''\n",
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",
CONTENT_MODEL_WIKITEXT, "hello [[world test 21344]]\n",
- array( 'LinksDeletionUpdate' => array( ) )
+ array( 'LinksDeletionUpdate' => array() )
),
// @todo: more...?
);
}
),
// @todo: more...?
);
}
'conds' => array( 'alias' => 'text' ),
),
"SELECT field,field2 AS alias " .
'conds' => array( 'alias' => 'text' ),
),
"SELECT field,field2 AS alias " .
- "FROM `unittest_table` " .
- "WHERE alias = 'text'"
+ "FROM `unittest_table` " .
+ "WHERE alias = 'text'"
'options' => array( 'LIMIT' => 1, 'ORDER BY' => 'field' ),
),
"SELECT field,field2 AS alias " .
'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"
'options' => array( 'LIMIT' => 1, 'ORDER BY' => 'field' ),
'join_conds' => array( 't2' => array(
'LEFT JOIN', 'tid = t2.id'
'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 " .
),
"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"
'options' => array( 'LIMIT' => 1, 'GROUP BY' => 'field', 'HAVING' => 'COUNT(*) > 1' ),
'join_conds' => array( 't2' => array(
'LEFT JOIN', 'tid = t2.id'
'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 " .
),
"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"
'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'
'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 " .
),
"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"
class MockDatabaseSqlite extends DatabaseSqliteStandalone {
var $lastQuery;
class MockDatabaseSqlite extends DatabaseSqliteStandalone {
var $lastQuery;
- function __construct( ) {
+ function __construct() {
parent::__construct( ':memory:' );
}
parent::__construct( ':memory:' );
}
private function assertResultIs( $expected, $res ) {
$this->assertNotNull( $res );
$i = 0;
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 );
}
$this->assertTrue( isset( $row->$key ) );
$this->assertEquals( $value, $row->$key );
}
$this->assertEquals( 'foo', $this->replaceVars( 'foo' ), "Don't break anything accidentally" );
$this->assertEquals( "CREATE TABLE /**/foo (foo_key INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "
$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->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 ( 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 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 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->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->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( "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" )
$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() {
}
public function testTableName() {
function testCaseInsensitiveLike() {
// TODO: Test this for all databases
function testCaseInsensitiveLike() {
// TODO: Test this for all databases
- $db = new DatabaseSqliteStandalone( ':memory:' );\r
- $res = $db->query( 'SELECT "a" LIKE "A" AS a' );\r
- $row = $res->fetchRow();\r
- $this->assertFalse( (bool)$row['a'] );\r
+ $db = new DatabaseSqliteStandalone( ':memory:' );
+ $res = $db->query( 'SELECT "a" LIKE "A" AS a' );
+ $row = $res->fetchRow();
+ $this->assertFalse( (bool)$row['a'] );
private function dropFunctions() {
$this->db->query( 'DROP FUNCTION IF EXISTS mw_test_function'
private function dropFunctions() {
$this->db->query( 'DROP FUNCTION IF EXISTS mw_test_function'
- . ( $this->db->getType() == 'postgres' ? '()' : '' )
+ . ( $this->db->getType() == 'postgres' ? '()' : '' )
parent::setUp();
// Make sure MWDebug class is enabled
static $MWDebugEnabled = false;
parent::setUp();
// Make sure MWDebug class is enabled
static $MWDebugEnabled = false;
- if( !$MWDebugEnabled ) {
+ if ( !$MWDebugEnabled ) {
MWDebug::init();
$MWDebugEnabled = true;
}
MWDebug::init();
$MWDebugEnabled = true;
}
function testAddLog() {
MWDebug::log( 'logging a string' );
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()
);
) ),
MWDebug::getLog()
);
function testAddWarning() {
MWDebug::warning( 'Warning message' );
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()
);
) ),
MWDebug::getLog()
);