8 of n.
Change-Id: I55551510e7afde5b6b981697d5c0efd7b9507585
*/
protected function deleteFile( $name ) {
$t = Title::newFromText( $name, NS_FILE );
- $this->assertTrue($t->exists(), "File '$name' exists");
+ $this->assertTrue( $t->exists(), "File '$name' exists" );
if ( $t->exists() ) {
$file = wfFindFile( $name, array( 'ignoreRedirect' => true ) );
}
$t = Title::newFromText( $name, NS_FILE );
- $this->assertFalse($t->exists(), "File '$name' was deleted");
+ $this->assertFalse( $t->exists(), "File '$name' was deleted" );
}
- }
+}
}
public function testValidRequest() {
- $request = new FauxRequest( array( 'wpFileKey' => 'foo') );
- $this->assertFalse( UploadFromStash::isValidRequest($request), 'Check failure on bad wpFileKey' );
+ $request = new FauxRequest( array( 'wpFileKey' => 'foo' ) );
+ $this->assertFalse( UploadFromStash::isValidRequest( $request ), 'Check failure on bad wpFileKey' );
- $request = new FauxRequest( array( 'wpSessionKey' => 'foo') );
- $this->assertFalse( UploadFromStash::isValidRequest($request), 'Check failure on bad wpSessionKey' );
+ $request = new FauxRequest( array( 'wpSessionKey' => 'foo' ) );
+ $this->assertFalse( UploadFromStash::isValidRequest( $request ), 'Check failure on bad wpSessionKey' );
- $request = new FauxRequest( array( 'wpFileKey' => 'testkey-test.test') );
- $this->assertTrue( UploadFromStash::isValidRequest($request), 'Check good wpFileKey' );
+ $request = new FauxRequest( array( 'wpFileKey' => 'testkey-test.test' ) );
+ $this->assertTrue( UploadFromStash::isValidRequest( $request ), 'Check good wpFileKey' );
- $request = new FauxRequest( array( 'wpFileKey' => 'testkey-test.test') );
- $this->assertTrue( UploadFromStash::isValidRequest($request), 'Check good wpSessionKey' );
+ $request = new FauxRequest( array( 'wpFileKey' => 'testkey-test.test' ) );
+ $this->assertTrue( UploadFromStash::isValidRequest( $request ), 'Check good wpSessionKey' );
- $request = new FauxRequest( array( 'wpFileKey' => 'testkey-test.test', 'wpSessionKey' => 'foo') );
- $this->assertTrue( UploadFromStash::isValidRequest($request), 'Check key precedence' );
+ $request = new FauxRequest( array( 'wpFileKey' => 'testkey-test.test', 'wpSessionKey' => 'foo' ) );
+ $this->assertTrue( UploadFromStash::isValidRequest( $request ), 'Check key precedence' );
}
}
array( 1, 'n is 1', 1.1, 'float number and is' ),
array( 1, 'n is 1', 2, 'float number and is' ),
- array( 0, 'n in 1,3,5', 3, '' ),
+ array( 0, 'n in 1,3,5', 3, '' ),
array( 1, 'n not in 1,3,5', 5, '' ),
- array( 1, 'n in 1,3,5', 2, '' ),
+ array( 1, 'n in 1,3,5', 2, '' ),
array( 0, 'n not in 1,3,5', 4, '' ),
- array( 0, 'n in 1..3', 2, '' ),
- array( 0, 'n in 1..3', 3, 'in is inclusive' ),
- array( 1, 'n in 1..3', 0, '' ),
+ array( 0, 'n in 1..3', 2, '' ),
+ array( 0, 'n in 1..3', 3, 'in is inclusive' ),
+ array( 1, 'n in 1..3', 0, '' ),
- array( 1, 'n not in 1..3', 2, '' ),
- array( 1, 'n not in 1..3', 3, 'in is inclusive' ),
- array( 0, 'n not in 1..3', 0, '' ),
+ array( 1, 'n not in 1..3', 2, '' ),
+ array( 1, 'n not in 1..3', 3, 'in is inclusive' ),
+ array( 0, 'n not in 1..3', 0, '' ),
array( 1, 'n is not 1 and n is not 2 and n is not 3', 1, 'and relation' ),
array( 0, 'n is not 1 and n is not 2 and n is not 4', 3, 'and relation' ),
protected function skipToNodeEnd( $name ) {
while ( $this->xml->read() ) {
if ( $this->xml->nodeType == XMLReader::END_ELEMENT &&
- $this->xml->name == $name ) {
+ $this->xml->name == $name
+ ) {
return true;
}
}
protected function skipWhitespace() {
$cont = true;
while ( $cont && ( ( $this->xml->nodeType == XMLReader::WHITESPACE )
- || ( $this->xml->nodeType == XMLReader::SIGNIFICANT_WHITESPACE ) ) ) {
+ || ( $this->xml->nodeType == XMLReader::SIGNIFICANT_WHITESPACE ) ) ) {
$cont = $this->xml->read();
}
}
* @param $parentid int|false: (optional) id of the parent revision
*/
protected function assertRevision( $id, $summary, $text_id, $text_bytes, $text_sha1, $text = false, $parentid = false,
- $model = CONTENT_MODEL_WIKITEXT, $format = CONTENT_FORMAT_WIKITEXT ) {
+ $model = CONTENT_MODEL_WIKITEXT, $format = CONTENT_FORMAT_WIKITEXT ) {
$this->assertNodeStart( "revision" );
$this->skipWhitespace();
$this->assertFalse( $this->xml->hasValue, "Revision has text" );
$this->assertTrue( $this->xml->read(), "Skipping text start tag" );
if ( ( $this->xml->nodeType == XMLReader::END_ELEMENT )
- && ( $this->xml->name == "text" ) ) {
+ && ( $this->xml->name == "text" )
+ ) {
$this->xml->read();
}
foreach ( $requested_pages as $i ) {
$this->assertTrue( array_key_exists( $i, $available_pages ),
"Check for availability of requested page " . $i );
- $content .= $available_pages[ $i ];
+ $content .= $available_pages[$i];
}
$content .= $tail;
$this->assertEquals( strlen( $content ), file_put_contents(
- $fname, $content ), "Length of prepared prefetch" );
+ $fname, $content ), "Length of prepared prefetch" );
return $fname;
}
* @return int id of the added log entry
*/
private function addLogEntry( $type, $subtype, User $user, $ns, $title,
- $comment = null, $parameters = null ) {
-
- $logEntry = new ManualLogEntry( $type, $subtype );
+ $comment = null, $parameters = null
+ ) {
+ $logEntry = new ManualLogEntry( $type, $subtype );
$logEntry->setPerformer( $user );
$logEntry->setTarget( Title::newFromText( $title, $ns ) );
- if ( $comment !== null ) {
+ if ( $comment !== null ) {
$logEntry->setComment( $comment );
}
- if ( $parameters !== null ) {
+ if ( $parameters !== null ) {
$logEntry->setParameters( $parameters );
}
- return $logEntry->insert();
+ return $logEntry->insert();
}
function addDBData() {
$this->logId3 = $this->addLogEntry( 'move', 'delete',
$user2, NS_MAIN, "PageA", "SomeOtherComment",
- array( 'key1' => 1, 3 => 'value3' ) );
+ array( 'key1' => 1, 3 => 'value3' ) );
$this->assertGreaterThan( 0, $this->logId3 );
} catch ( Exception $e ) {
* @param $parameters array: (optional) unserialized data accompanying the log entry
*/
private function assertLogItem( $id, $user_name, $user_id, $comment, $type,
- $subtype, $title, $parameters = array() ) {
+ $subtype, $title, $parameters = array()
+ ) {
$this->assertNodeStart( "logitem" );
$this->skipWhitespace();
$this->skipWhitespace();
}
- function testPlain () {
+ function testPlain() {
global $wgContLang;
// Preparing the dump
$fname = $this->getNewTempFile();
- $dumper = new BackupDumper( array ( "--output=file:" . $fname ) );
+ $dumper = new BackupDumper( array( "--output=file:" . $fname ) );
$dumper->startId = $this->logId1;
$dumper->endId = $this->logId3 + 1;
$dumper->reporting = false;
// Preparing the dump
$fname = $this->getNewTempFile();
- $dumper = new BackupDumper( array ( "--output=gzip:" . $fname,
- "--reporting=2" ) );
+ $dumper = new BackupDumper( array( "--output=gzip:" . $fname,
+ "--reporting=2" ) );
$dumper->startId = $this->logId1;
$dumper->endId = $this->logId3 + 1;
$dumper->setDb( $this->db );
function __construct() {
parent::__construct();
- $this->addOption( 'with-phpunitdir'
- , 'Directory to include PHPUnit from, for example when using a git fetchout from upstream. Path will be prepended to PHP `include_path`.'
- , false # not required
- , true # need arg
+ $this->addOption( 'with-phpunitdir',
+ 'Directory to include PHPUnit from, for example when using a git fetchout from upstream. Path will be prepended to PHP `include_path`.',
+ false, # not required
+ true # need arg
);
}
// Assume UTC for testing purposes
$wgLocaltimezone = 'UTC';
- $wgLocalisationCacheConf['storeClass'] = 'LCStore_Null';
+ $wgLocalisationCacheConf['storeClass'] = 'LCStore_Null';
}
public function execute() {
global $IP;
# Make sure we have --configuration or PHPUnit might complain
- if( !in_array( '--configuration', $_SERVER['argv'] ) ) {
+ if ( !in_array( '--configuration', $_SERVER['argv'] ) ) {
//Hack to eliminate the need to use the Makefile (which sucks ATM)
array_splice( $_SERVER['argv'], 1, 0,
array( '--configuration', $IP . '/tests/phpunit/suite.xml' ) );
}
# --with-phpunitdir let us override the default PHPUnit version
- if( $phpunitDir = $this->getOption( 'with-phpunitdir' ) ) {
+ if ( $phpunitDir = $this->getOption( 'with-phpunitdir' ) ) {
# Sanity checks
- if( !is_dir($phpunitDir) ) {
+ if ( !is_dir( $phpunitDir ) ) {
$this->error( "--with-phpunitdir should be set to an existing directory", 1 );
}
- if( !is_readable( $phpunitDir."/PHPUnit/Runner/Version.php" ) ) {
+ if ( !is_readable( $phpunitDir . "/PHPUnit/Runner/Version.php" ) ) {
$this->error( "No usable PHPUnit installation in $phpunitDir.\nAborting.\n", 1 );
}
# Cleanup $args array so the option and its value do not
# pollute PHPUnit
$key = array_search( '--with-phpunitdir', $_SERVER['argv'] );
- unset( $_SERVER['argv'][$key] ); // the option
- unset( $_SERVER['argv'][$key+1] ); // its value
+ unset( $_SERVER['argv'][$key] ); // the option
+ unset( $_SERVER['argv'][$key + 1] ); // its value
$_SERVER['argv'] = array_values( $_SERVER['argv'] );
}
require_once( 'PHPUnit/Runner/Version.php' );
-if( PHPUnit_Runner_Version::id() !== '@package_version@'
- && version_compare( PHPUnit_Runner_Version::id(), '3.6.7', '<' ) ) {
+if ( PHPUnit_Runner_Version::id() !== '@package_version@'
+ && version_compare( PHPUnit_Runner_Version::id(), '3.6.7', '<' )
+) {
die( 'PHPUnit 3.6.7 or later required, you have ' . PHPUnit_Runner_Version::id() . ".\n" );
}
require_once( 'PHPUnit/Autoload.php' );
foreach ( $rl->getModuleNames() as $moduleName ) {
$module = $rl->getModule( $moduleName );
- if ( ! $module instanceof ResourceLoaderFileModule ) {
+ if ( !$module instanceof ResourceLoaderFileModule ) {
continue;
}
-<?php
+<?php
/**
* This test suite runs unit tests registered by extensions.
* See http://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList for details of how to register your tests.
);
public function __construct() {
- parent::__construct();
- $this->mDescription = 'Create a specification for message parsing ini JSON format';
- // add any other options here
+ parent::__construct();
+ $this->mDescription = 'Create a specification for message parsing ini JSON format';
+ // add any other options here
}
public function execute() {
$tests = array();
foreach ( array( 'en', 'fr', 'ar', 'jp', 'zh' ) as $languageCode ) {
foreach ( self::$keyToTestArgs as $key => $testArgs ) {
- foreach ($testArgs as $args) {
+ foreach ( $testArgs as $args ) {
// Get the raw message, without any transformations.
$template = wfMessage( $key )->inLanguage( $languageCode )->plain();
$output =
"// This file stores the output from the PHP parser for various messages, arguments,\n"
- . "// languages, and parser modes. Intended for use by a unit test framework by looping\n"
- . "// through the object and comparing its parser return value with the 'result' property.\n"
- . '// Last generated with ' . basename( __FILE__ ) . ' at ' . gmdate( 'r' ) . "\n"
- // This file will contain unquoted JSON strings as javascript native object literals,
- // flip the quotemark convention for this file.
- . "/*jshint quotmark: double */\n"
- . "\n"
- . 'mediaWiki.libs.phpParserData = ' . FormatJson::encode( $phpParserData, true ) . ";\n";
+ . "// languages, and parser modes. Intended for use by a unit test framework by looping\n"
+ . "// through the object and comparing its parser return value with the 'result' property.\n"
+ . '// Last generated with ' . basename( __FILE__ ) . ' at ' . gmdate( 'r' ) . "\n"
+ // This file will contain unquoted JSON strings as javascript native object literals,
+ // flip the quotemark convention for this file.
+ . "/*jshint quotmark: double */\n"
+ . "\n"
+ . 'mediaWiki.libs.phpParserData = ' . FormatJson::encode( $phpParserData, true ) . ";\n";
$fp = file_put_contents( $dataSpecFile, $output );
if ( $fp === false ) {
QUnit.start();
-QUnit.assert.ok( true, 'Successfully loaded!');
+QUnit.assert.ok( true, 'Successfully loaded!' );
sleep( $wait );
-$css = "
+$css = "
/**
- * Generated " . gmdate( 'r' ) . ".
+ * Generated " . gmdate( 'r' ) . ".
* Waited {$wait}s.
*/
} else {
assert.gt( $span.width(), $span.parent().width(), 'Fit is maximal (adding two characters makes it not fit any more)' );
}
- });
+ } );
}( jQuery ) );
QUnit.module( 'jquery.byteLength', QUnit.newMwEnvironment() );
QUnit.test( 'Simple text', 5, function ( assert ) {
- var azLc = 'abcdefghijklmnopqrstuvwxyz',
+ var azLc = 'abcdefghijklmnopqrstuvwxyz',
azUc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
num = '0123456789',
x = '*',
assert.deepEqual( $.colorUtil.getRGB( 'lightGreen' ), [144, 238, 144], 'Color names (lightGreen)' );
assert.deepEqual( $.colorUtil.getRGB( 'transparent' ), [255, 255, 255], 'Color names (transparent)' );
assert.strictEqual( $.colorUtil.getRGB( 'mediaWiki' ), undefined, 'Inexisting color name' );
- });
+ } );
QUnit.test( 'rgbToHsl', 1, function ( assert ) {
var hsl, ret;
function dualDecimals( a ) {
return Math.round( a * 100 ) / 100;
}
+
// Re-create the rgbToHsl return array items, limited to two decimals.
hsl = $.colorUtil.rgbToHsl( 144, 238, 144 );
ret = [ dualDecimals( hsl[0] ), dualDecimals( hsl[1] ), dualDecimals( hsl[2] ) ];
assert.deepEqual( ret, [0.33, 0.73, 0.75], 'rgb(144, 238, 144): hsl(0.33, 0.73, 0.75)' );
- });
+ } );
QUnit.test( 'hslToRgb', 1, function ( assert ) {
var rgb, ret;
rgb = $.colorUtil.hslToRgb( 0.3, 0.7, 0.8 );
// Re-create the hslToRgb return array items, rounded to whole numbers.
- ret = [ Math.round(rgb[0]), Math.round(rgb[1]), Math.round(rgb[2]) ];
+ ret = [ Math.round( rgb[0] ), Math.round( rgb[1] ), Math.round( rgb[2] ) ];
- assert.deepEqual( ret ,[183, 240, 168], 'hsl(0.3, 0.7, 0.8): rgb(183, 240, 168)' );
- });
+ assert.deepEqual( ret, [183, 240, 168], 'hsl(0.3, 0.7, 0.8): rgb(183, 240, 168)' );
+ } );
QUnit.test( 'getColorBrightness', 2, function ( assert ) {
var a, b;
b = $.colorUtil.getColorBrightness( 'rgb(200,50,50)', -0.2 );
assert.equal( b, 'rgb(118,29,29)', 'Start with rgb string "rgb(200,50,50)", darken 20%' );
- });
+ } );
}( jQuery ) );
( function ( $ ) {
- QUnit.asyncTest('jquery.delayedBind with data option', 2, function ( assert ) {
- var $fixture = $('<div>').appendTo('#qunit-fixture'),
+ QUnit.asyncTest( 'jquery.delayedBind with data option', 2, function ( assert ) {
+ var $fixture = $( '<div>' ).appendTo( '#qunit-fixture' ),
data = {
magic: 'beeswax'
},
delay = 50;
- $fixture.delayedBind(delay, 'testevent', data, function ( e ) {
- assert.ok( true, 'testevent fired');
- assert.ok( e.data === data, 'data is passed through delayedBind');
+ $fixture.delayedBind( delay, 'testevent', data, function ( e ) {
+ assert.ok( true, 'testevent fired' );
+ assert.ok( e.data === data, 'data is passed through delayedBind' );
QUnit.start();
- });
+ } );
// We'll trigger it thrice, but it should only happen once.
$fixture.trigger( 'testevent', {} );
$fixture.trigger( 'testevent', {} );
$fixture.trigger( 'testevent', {} );
$fixture.trigger( 'testevent', {} );
- });
+ } );
- QUnit.asyncTest('jquery.delayedBind without data option', 1, function ( assert ) {
- var $fixture = $('<div>').appendTo('#qunit-fixture'),
+ QUnit.asyncTest( 'jquery.delayedBind without data option', 1, function ( assert ) {
+ var $fixture = $( '<div>' ).appendTo( '#qunit-fixture' ),
delay = 50;
- $fixture.delayedBind(delay, 'testevent', function () {
- assert.ok(true, 'testevent fired');
+ $fixture.delayedBind( delay, 'testevent', function () {
+ assert.ok( true, 'testevent fired' );
QUnit.start();
- });
+ } );
// We'll trigger it thrice, but it should only happen once.
$fixture.trigger( 'testevent', {} );
$fixture.trigger( 'testevent', {} );
$fixture.trigger( 'testevent', {} );
$fixture.trigger( 'testevent', {} );
- });
+ } );
}( jQuery ) );
QUnit.module( 'jquery.getAttrs', QUnit.newMwEnvironment() );
QUnit.test( 'Check', 1, function ( assert ) {
- var attrs = {
+ var attrs = {
foo: 'bar',
'class': 'lorem'
},
QUnit.test( 'devicePixelRatio', function ( assert ) {
var devicePixelRatio = $.devicePixelRatio();
assert.equal( typeof devicePixelRatio, 'number', '$.devicePixelRatio() returns a number' );
- });
+ } );
QUnit.test( 'matchSrcSet', function ( assert ) {
var srcset = 'onefive.png 1.5x, two.png 2x';
assert.equal( $.matchSrcSet( 1.25, srcset ), null, '1.25 gives no match' );
assert.equal( $.matchSrcSet( 1.75, srcset ), 'onefive.png', '1.75 gives match to 1.5' );
assert.equal( $.matchSrcSet( 2.25, srcset ), 'two.png', '2.25 gives match to 2' );
- });
+ } );
}( jQuery ) );
assert.strictEqual( $lc.length, 1, 'link is created' );
assert.strictEqual( $lc.text(), 'link', 'the link text got added' );
} );
-}( jQuery, mediaWiki ) ) ;
+}( jQuery, mediaWiki ) );
assert.equal( $res.find( 'b' ).text(), 'Hello world', 'Bold tag wraps the entire, same, text' );
QUnit.start();
- });
- });
+ } );
+ } );
}( mediaWiki, jQuery ) );
( function ( mw, $ ) {
- QUnit.module( 'mediawiki.language', QUnit.newMwEnvironment({
+ QUnit.module( 'mediawiki.language', QUnit.newMwEnvironment( {
setup: function () {
this.liveLangData = mw.language.data.values;
mw.language.data.values = $.extend( true, {}, this.liveLangData );
teardown: function () {
mw.language.data.values = this.liveLangData;
}
- }) );
+ } ) );
QUnit.test( 'mw.language getData and setData', 2, function ( assert ) {
mw.language.setData( 'en', 'testkey', 'testvalue' );
- assert.equal( mw.language.getData( 'en', 'testkey' ), 'testvalue', 'Getter setter test for mw.language' );
- assert.equal( mw.language.getData( 'en', 'invalidkey' ), undefined, 'Getter setter test for mw.language with invalid key' );
+ assert.equal( mw.language.getData( 'en', 'testkey' ), 'testvalue', 'Getter setter test for mw.language' );
+ assert.equal( mw.language.getData( 'en', 'invalidkey' ), undefined, 'Getter setter test for mw.language with invalid key' );
} );
function grammarTest( langCode, test ) {
QUnit.test( 'Grammar test for lang=' + langCode, function ( assert ) {
QUnit.expect( test.length );
- for ( var i = 0 ; i < test.length; i++ ) {
+ for ( var i = 0; i < test.length; i++ ) {
assert.equal(
mw.language.convertGrammar( test[i].word, test[i].grammarForm ),
test[i].expected,
test[i].description
);
}
- });
+ } );
}
var grammarTests = {
if ( langCode === mw.config.get( 'wgUserLanguage' ) ) {
grammarTest( langCode, test );
}
- });
+ } );
}( mediaWiki, jQuery ) );
* See sample config file in selenium_settings.ini.sample
*
*/
-
- public static function getSeleniumSettings ( &$seleniumSettings,
- &$seleniumBrowsers,
- &$seleniumTestSuites,
- $seleniumConfigFile = null ) {
+ public static function getSeleniumSettings( &$seleniumSettings,
+ &$seleniumBrowsers,
+ &$seleniumTestSuites,
+ $seleniumConfigFile = null ) {
if ( strlen( $seleniumConfigFile ) == 0 ) {
global $wgSeleniumConfigFile;
- if ( isset( $wgSeleniumConfigFile ) ) $seleniumConfigFile = $wgSeleniumConfigFile ;
+ if ( isset( $wgSeleniumConfigFile ) ) {
+ $seleniumConfigFile = $wgSeleniumConfigFile;
+ }
}
if ( strlen( $seleniumConfigFile ) == 0 || !file_exists( $seleniumConfigFile ) ) {
throw new MWException( "Error parsing " . $seleniumConfigFile . "\n" );
}
- if ( array_key_exists( 'SeleniumSettings', $configArray) ) {
+ if ( array_key_exists( 'SeleniumSettings', $configArray ) ) {
wfSuppressWarnings();
//we may need to change how this is set. But for now leave it in the ini file
$seleniumBrowsers = $configArray['SeleniumSettings']['browsers'];
wfRestoreWarnings();
}
- if ( array_key_exists( 'SeleniumTests', $configArray) ) {
+ if ( array_key_exists( 'SeleniumTests', $configArray ) ) {
wfSuppressWarnings();
$seleniumTestSuites = $configArray['SeleniumTests']['testSuite'];
wfRestoreWarnings();
$this->tests_failed++;
}
- public function addFailure( PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time )
- {
+ public function addFailure( PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time ) {
$this->logger->write( 'Failed: ' . $e->getMessage() );
$this->tests_failed++;
}
- public function addIncompleteTest( PHPUnit_Framework_Test $test, Exception $e, $time )
- {
+ public function addIncompleteTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
$this->logger->write( 'Incomplete.' );
$this->tests_failed++;
}
- public function addSkippedTest( PHPUnit_Framework_Test $test, Exception $e, $time )
- {
+ public function addSkippedTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
$this->logger->write( 'Skipped.' );
$this->tests_failed++;
}
}
public function endTestSuite( PHPUnit_Framework_TestSuite $suite ) {
- $this->logger->write('Testsuite ' . $suite->getName() . ' ended.' );
+ $this->logger->write( 'Testsuite ' . $suite->getName() . ' ended.' );
if ( $this->tests_ok > 0 || $this->tests_failed > 0 ) {
$this->logger->write( ' OK: ' . $this->tests_ok . ' Failed: ' . $this->tests_failed );
}
if ( $this->triggerClientTestResources ) {
$this->selenium->open( $this->selenium->getUrl() . '/index.php?setupTestSuite=' . $this->getName() );
//wait a little longer for the db operation
- $this->selenium->waitForPageToLoad( 6000 );
+ $this->selenium->waitForPageToLoad( 6000 );
}
if ( $this->loginBeforeTests ) {
$this->login();
protected function setLoginBeforeTests( $loginBeforeTests = true ) {
$this->loginBeforeTests = $loginBeforeTests;
}
-
+
protected function setTriggerClientTestResources( $triggerClientTestResources = true ) {
$this->triggerClientTestResources = $triggerClientTestResources;
}
* with current value of the 'DB_NAME_PREFIX'.
* If you wish to run the suite more than one time, you need to change
* the value of the 'DB_NAME_PREFIX'.
-*/
-define('DB_NAME_PREFIX', "database_name" );
-define('DIRECTORY_NAME', "mediawiki" );
+ */
+define( 'DB_NAME_PREFIX', "database_name" );
+define( 'DIRECTORY_NAME', "mediawiki" );
define( 'PORT', "8080" );
define( 'HOST_NAME', "localhost" );
* IE : *iexplore
* Google chrome : *googlechrome
* Opera : *opera
-*/
+ */
define ( 'TEST_BROWSER', "*firefox" );
// 'MySQL' database type help field hint
define( 'MYSQL_DATABASE_HOST_HELP', "If your database server is on different server, enter the host name or IP address here. \nIf you are using shared web hosting, your hosting provider should give you the correct host name in their documentation. \nIf you are installing on a Windows server and using MySQL, using \"localhost\" may not work for the server name. If it does not, try \"127.0.0.1\" for the local IP address." );
define( 'MYSQL_DATABASE_NAME_HELP', "Choose a name that identifies your wiki. It should not contain spaces or hyphens. \nIf you are using shared web hosting, your hosting provider will either give you a specific database name to use or let you create databases via a control panel." );
-define( 'MYSQL_DATABASE_TABLE_PREFIX_HELP', "Choose a name that identifies your wiki. It should not contain spaces or hyphens.");
+define( 'MYSQL_DATABASE_TABLE_PREFIX_HELP', "Choose a name that identifies your wiki. It should not contain spaces or hyphens." );
define( 'MYSQL_DATBASE_USERNAME_HELP', "Enter the username that will be used to connect to the database during the installation process. This is not the username of the MediaWiki account; this is the username for your database." );
define( 'MYSQL_DATABASE_PASSWORD_HELP', "Enter the password that will be used to connect to the database during the installation process. This is not the password for the MediaWiki account; this is the password for your database." );
// 'SQLite' database type help field hint
define( 'SQLITE_DATA_DIRECTORY_HELP', "SQLite stores all data in a single file. \nThe directory you provide must be writable by the webserver during installation. \nIt should not be accessible via the web, this is why we're not putting it where your PHP files are. \nThe installer will write a .htaccess file along with it, but if that fails someone can gain access to your raw database. That includes raw user data (e-mail addresses, hashed passwords) as well as deleted revisions and other restricted data on the wiki. \nConsider putting the database somewhere else altogether, for example in /var/lib/mediawiki/yourwiki." );
-define( 'SQLITE_DATABASE_NAME_HELP', "Choose a name that identifies your wiki. Do not use spaces or hyphens. This will be used for the SQLite data file name.");
+define( 'SQLITE_DATABASE_NAME_HELP', "Choose a name that identifies your wiki. Do not use spaces or hyphens. This will be used for the SQLite data file name." );
// 'Database settings' page hel0p field hint
// 'Name' page help field hint
-define( 'NAME_OF_WIKI_HELP', "This will appear in the title bar of the browser and in various other places.");
+define( 'NAME_OF_WIKI_HELP', "This will appear in the title bar of the browser and in various other places." );
define( 'PROJECT_NAMESPACE_HELP', "Following Wikipedia's example, many wikis keep their policy pages separate from their content pages, in a \"project namespace\". All page titles in this namespace start with a certain prefix, which you can specify here. Traditionally, this prefix is derived from the name of the wiki, but it cannot contain punctuation characters such as \"#\" or \":\"." );
define( 'USER_NAME_HELP', "Enter your preferred username here, for example \"Joe Bloggs\". This is the name you will use to log in to the wiki." );
define( 'EMAIL_ADDRESS_HELP', "Enter an e-mail address here to allow you to receive e-mail from other users on the wiki, reset your password, and be notified of changes to pages on your watchlist." );
// Common variables
-define('PAGE_LOAD_TIME', "80000" );
+define( 'PAGE_LOAD_TIME', "80000" );
// Common links
-define( 'LINK_DIV', "//div[@id='bodyContent']/div/div/");
+define( 'LINK_DIV', "//div[@id='bodyContent']/div/div/" );
define( 'LINK_FORM', "//div[@id='bodyContent']/div/div/div[2]/form/" );
-define( 'LINK_RIGHT_FRAMEWORK', "//div[@id='bodyContent']/div/div/div[1]/ul[1]/");
+define( 'LINK_RIGHT_FRAMEWORK', "//div[@id='bodyContent']/div/div/div[1]/ul[1]/" );
// 'Name' page input values
define( 'NAME_OF_WIKI', "Site Name" );
define( 'VALID_WIKI_NAME', "MyWiki" );
define( 'VALID_YOUR_NAME', "FirstName LastName" );
define( 'VALID_PASSWORD', "12345" );
-define( 'VALID_PASSWORD_AGAIN', "12345" );
+define( 'VALID_PASSWORD_AGAIN', "12345" );
define( 'INVALID_PASSWORD_AGAIN', "123" );
-define( 'VALID_NAMESPACE', "Mynamespace" );
+define( 'VALID_NAMESPACE', "Mynamespace" );
define( 'INVALID_NAMESPACE', "##..##" );
// 'Database settings' page input values
define( 'DB_WEB_USER', "different" );
-define('DB_WEB_USER_PASSWORD', "12345" );
+define( 'DB_WEB_USER_PASSWORD', "12345" );
// 'Connet to database' page input values
-define( 'DATABASE_PREFIX',"databaseprefix" );
+define( 'DATABASE_PREFIX', "databaseprefix" );
// 'Connet to database' page input values for warning messages
define( 'VALID_DB_HOST', "localhost" );
define( 'INVALID_DB_HOST', "local" );
define( 'INVALID_DB_NAME', "my-wiki" );
-define( 'VALID_DB_NAME', "my_wiki1");
+define( 'VALID_DB_NAME', "my_wiki1" );
define( 'INVALID_DB_PREFIX', "database prefix" );
-define( 'VALID_DB_PREFIX', "database_prefix");
+define( 'VALID_DB_PREFIX', "database_prefix" );
define( 'INVALID_DB_USER_NAME', "roots" );
-define( 'VALID_DB_USER_NAME', "root");
+define( 'VALID_DB_USER_NAME', "root" );
define( 'INVALID_DB_PASSWORD', "12345" );
require_once ( __DIR__ . '/MediaWikiDifferentDatabaseAccountTestCase.php' );
require_once ( __DIR__ . '/MediaWikiOnAlreadyInstalledTestCase.php' );
-
-
-
-$suite = new PHPUnit_Framework_TestSuite('ArrayTest');
+$suite = new PHPUnit_Framework_TestSuite( 'ArrayTest' );
$result = new PHPUnit_Framework_TestResult;
-$suite->run($result);
+$suite->run( $result );
* @file
* @ingroup Testing
* Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com>
- * http://www.calcey.com/
+ * http://www.calcey.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*/
class MediaWikiEditorConfig {
-
- public static function getSettings(&$includeFiles, &$globalConfigs) {
- $includes = array(
- //files that needed to be included would go here
- //commenting out because this does not exist
- //'tests/selenium/suites/MediaWikiCommonFunction.php'
- );
- $configs = array(
- 'wgPageLoadTime' => "600000"
- );
- $includeFiles = array_merge( $includeFiles, $includes );
- $globalConfigs = array_merge( $globalConfigs, $configs);
- return true;
- }
+ public static function getSettings( &$includeFiles, &$globalConfigs ) {
+ $includes = array(
+ //files that needed to be included would go here
+ //commenting out because this does not exist
+ //'tests/selenium/suites/MediaWikiCommonFunction.php'
+ );
+ $configs = array(
+ 'wgPageLoadTime' => "600000"
+ );
+ $includeFiles = array_merge( $includeFiles, $includes );
+ $globalConfigs = array_merge( $globalConfigs, $configs );
+ return true;
+ }
}
-
-
$this->setLoginBeforeTests( true );
parent::setUp();
}
+
public function addTests() {
$testFiles = array(
'tests/selenium/suites/MyContributionsTestCase.php',
$this->waitForPageToLoad( 30000 );
$this->assertSeleniumHTMLContains(
- '//h1[@class="firstHeading"]', "Wikipedia-logo-v2-de.png" );
+ '//h1[@class="firstHeading"]', "Wikipedia-logo-v2-de.png"
+ );
/*
$this->open( $this->getUrl() . '/index.php?title=Image:'
/**
* Stubs for now. We're going to start populating this test.
*/
-class MediawikiCoreSmokeTestSuite extends SeleniumTestSuite
-{
+class MediawikiCoreSmokeTestSuite extends SeleniumTestSuite {
public function setUp() {
$this->setLoginBeforeTests( false );
parent::setUp();
- }
+ }
+
public function addTests() {
$testFiles = array(
'tests/selenium/suites/MediawikiCoreSmokeTestCase.php'
<?php
class PageDeleteTestSuite extends SeleniumTestSuite {
- public function setUp() {
- $this->setLoginBeforeTests( true );
- parent::setUp();
- }
- public function addTests() {
- $testFiles = array(
- 'tests/selenium/suites/DeletePageAdminTestCase.php'
- );
- parent::addTestFiles( $testFiles );
- }
-
+ public function setUp() {
+ $this->setLoginBeforeTests( true );
+ parent::setUp();
+ }
+ public function addTests() {
+ $testFiles = array(
+ 'tests/selenium/suites/DeletePageAdminTestCase.php'
+ );
+ parent::addTestFiles( $testFiles );
+ }
}
public function testGlobalVariableForDefaultSkin() {
$this->open( $this->getUrl() . '/index.php' );
$bodyClass = $this->getAttribute( "//body/@class" );
- $this-> assertContains('skin-chick', $bodyClass, 'Chick skin not set');
+ $this->assertContains( 'skin-chick', $bodyClass, 'Chick skin not set' );
}
/**
public function testDatabaseResourceLoadedCorrectly() {
$this->open( $this->getUrl() . '/index.php/TestResources?action=purge' );
$testString = $this->gettext( "//body//*[@id='firstHeading']" );
- $this-> assertEquals('TestResources', $testString, 'Article that should be present in the test db was not found.');
+ $this->assertEquals( 'TestResources', $testString, 'Article that should be present in the test db was not found.' );
}
}
<?php
/**
- * Sample test suite.
+ * Sample test suite.
* Two ways to configure MW for these tests
* 1) If you are running multiple test suites, add the following in LocalSettings.php
* require_once("tests/selenium/SimpleSeleniumConfig.php");
* 2) Add the following to your Localsettings.php
* $wgDefaultSkin = 'chick';
*/
-class SimpleSeleniumTestSuite extends SeleniumTestSuite
-{
+class SimpleSeleniumTestSuite extends SeleniumTestSuite {
public function setUp() {
$this->setLoginBeforeTests( false );
parent::setUp();
- }
+ }
+
public function addTests() {
$testFiles = array(
'selenium/suites/SimpleSeleniumTestCase.php'