From 6906724935ecd1b6cde62f242de2878f5cb1a7de Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Wed, 26 Oct 2011 03:45:13 +0000 Subject: [PATCH] Add, update, tweak documentation Fix document comment blocks Tweak some returns --- includes/WebRequest.php | 4 + includes/WikiFilePage.php | 27 +++- includes/WikiMap.php | 21 +-- includes/WikiPage.php | 37 ++++-- includes/ZhClient.php | 11 +- includes/ZipDirectoryReader.php | 124 +++++++++--------- index.php5 | 2 +- maintenance/fetchText.php | 2 +- resources/mediawiki/mediawiki.js | 8 +- skins/common/upload.js | 34 +++-- tests/parser/parserTest.inc | 2 +- tests/phpunit/includes/IPTest.php | 28 ++-- .../includes/SeleniumConfigurationTest.php | 24 ++-- .../phpunit/includes/parser/NewParserTest.php | 2 +- .../includes/search/SearchEngineTest.php | 2 +- tests/selenium/SeleniumConfig.php | 16 +-- .../suites/MediawikiCoreSmokeTestCase.php | 40 +++--- .../suites/SimpleSeleniumTestCase.php | 14 +- 18 files changed, 218 insertions(+), 180 deletions(-) diff --git a/includes/WebRequest.php b/includes/WebRequest.php index daab86f1bd..8f2bafd317 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -1192,6 +1192,10 @@ class FauxRequest extends WebRequest { $this->session = $session; } + /** + * @param $method string + * @throws MWException + */ private function notImplemented( $method ) { throw new MWException( "{$method}() not implemented" ); } diff --git a/includes/WikiFilePage.php b/includes/WikiFilePage.php index 4997145638..87b5487531 100644 --- a/includes/WikiFilePage.php +++ b/includes/WikiFilePage.php @@ -25,13 +25,15 @@ class WikiFilePage extends WikiPage { /** * @param $file File: - * @return void */ public function setFile( $file ) { $this->mFile = $file; $this->mFileLoaded = true; } + /** + * @return bool + */ protected function loadFile() { if ( $this->mFileLoaded ) { return true; @@ -49,6 +51,9 @@ class WikiFilePage extends WikiPage { return true; } + /** + * @return mixed|null|Title + */ public function getRedirectTarget() { $this->loadFile(); if ( $this->mFile->isLocal() ) { @@ -63,6 +68,9 @@ class WikiFilePage extends WikiPage { return $this->mRedirectTarget = Title::makeTitle( NS_FILE, $to ); } + /** + * @return bool|mixed|Title + */ public function followRedirect() { $this->loadFile(); if ( $this->mFile->isLocal() ) { @@ -76,6 +84,10 @@ class WikiFilePage extends WikiPage { return Title::makeTitle( NS_FILE, $to ); } + /** + * @param bool $text + * @return bool + */ public function isRedirect( $text = false ) { $this->loadFile(); if ( $this->mFile->isLocal() ) { @@ -85,16 +97,25 @@ class WikiFilePage extends WikiPage { return (bool)$this->mFile->getRedirected(); } + /** + * @return bool + */ public function isLocal() { $this->loadFile(); return $this->mFile->isLocal(); } + /** + * @return bool|File + */ public function getFile() { $this->loadFile(); return $this->mFile; } + /** + * @return array|null + */ public function getDuplicates() { $this->loadFile(); if ( !is_null( $this->mDupes ) ) { @@ -108,6 +129,10 @@ class WikiFilePage extends WikiPage { // Remove duplicates with self and non matching file sizes $self = $this->mFile->getRepoName() . ':' . $this->mFile->getName(); $size = $this->mFile->getSize(); + + /** + * @var $file File + */ foreach ( $dupes as $index => $file ) { $key = $file->getRepoName() . ':' . $file->getName(); if ( $key == $self ) { diff --git a/includes/WikiMap.php b/includes/WikiMap.php index 94907add2c..6c7f23b52f 100644 --- a/includes/WikiMap.php +++ b/includes/WikiMap.php @@ -28,7 +28,7 @@ class WikiMap { array( 'lang' => $minor, 'site' => $major ) ); return new WikiReference( $major, $minor, $canonicalServer, $path, $server ); } - + /** * Convenience to get the wiki's display name * @@ -87,11 +87,11 @@ class WikiMap { */ public static function getForeignURL( $wikiID, $page ) { $wiki = WikiMap::getWiki( $wikiID ); - + if ( $wiki ) { return $wiki->getUrl( $page ); } - + return false; } } @@ -114,6 +114,10 @@ class WikiReference { $this->mServer = $server === null ? $canonicalServer : $server; } + /** + * @return string + * @throws MWException + */ public function getHostname() { $prefixes = array( 'http://', 'https://' ); foreach ( $prefixes as $prefix ) { @@ -159,22 +163,21 @@ class WikiReference { * @return String: Url */ public function getCanonicalUrl( $page ) { - return - $this->mCanonicalServer . - $this->getLocalUrl( $page ); + return $this->mCanonicalServer . $this->getLocalUrl( $page ); } - + /** * Alias for getCanonicalUrl(), for backwards compatibility. + * @return String */ public function getUrl( $page ) { return $this->getCanonicalUrl( $page ); } - + /** * Get a URL based on $wgServer, like Title::getFullUrl() would produce * when called locally on the wiki. - * + * * @param $page String: page name (must be normalized before calling this function!) * @return String: URL */ diff --git a/includes/WikiPage.php b/includes/WikiPage.php index e1ec64dee6..3462427bbd 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -26,8 +26,17 @@ class WikiPage extends Page { public $mIsRedirect = false; // !< Boolean public $mLatest = false; // !< Boolean public $mPreparedEdit = false; // !< Array - public $mRedirectTarget = null; // !< Title object - public $mLastRevision = null; // !< Revision object + + /** + * @var Title + */ + public $mRedirectTarget = null; + + /** + * @var Revision + */ + public $mLastRevision = null; + public $mTimestamp = ''; // !< String public $mTouched = '19700101000000'; // !< String /**@}}*/ @@ -700,6 +709,7 @@ class WikiPage extends Page { * Should the parser cache be used? * * @param $user User The relevant user + * @param $oldid int * @return boolean */ public function isParserCacheUsed( User $user, $oldid ) { @@ -756,7 +766,6 @@ class WikiPage extends Page { * * @param $dbw DatabaseBase * @return int The newly created page_id key, or false if the title already existed - * @private */ public function insertOn( $dbw ) { wfProfileIn( __METHOD__ ); @@ -1585,7 +1594,7 @@ class WikiPage extends Page { * Deletes the article with database consistency, writes logs, purges caches * * @param $reason string delete reason for deletion log - * @param suppress bitfield + * @param $suppress bitfield * Revision::DELETED_TEXT * Revision::DELETED_COMMENT * Revision::DELETED_USER @@ -2585,7 +2594,7 @@ class WikiPage extends Page { * Updates cascading protections * * @param $parserOutput ParserOutput object for the current version - **/ + */ public function doCascadeProtectionUpdates( ParserOutput $parserOutput ) { if ( wfReadOnly() || !$this->mTitle->areRestrictionsCascading() ) { return; @@ -2632,25 +2641,25 @@ class WikiPage extends Page { } } - /* - * @deprecated since 1.18 - */ + /** + * @deprecated since 1.18 + */ public function quickEdit( $text, $comment = '', $minor = 0 ) { global $wgUser; return $this->doQuickEdit( $text, $wgUser, $comment, $minor ); } - /* - * @deprecated since 1.18 - */ + /** + * @deprecated since 1.18 + */ public function viewUpdates() { global $wgUser; return $this->doViewUpdates( $wgUser ); } - /* - * @deprecated since 1.18 - */ + /** + * @deprecated since 1.18 + */ public function useParserCache( $oldid ) { global $wgUser; return $this->isParserCacheUsed( $wgUser, $oldid ); diff --git a/includes/ZhClient.php b/includes/ZhClient.php index 8bb36b231a..d3d7916539 100644 --- a/includes/ZhClient.php +++ b/includes/ZhClient.php @@ -41,10 +41,7 @@ class ZhClient { $errno = $errstr = ''; $this->mFP = fsockopen( $this->mHost, $this->mPort, $errno, $errstr, 30 ); wfRestoreWarnings(); - if ( !$this->mFP ) { - return false; - } - return true; + return !$this->mFP; } /** @@ -77,10 +74,7 @@ class ZhClient { $data .= $str; } // data should be of length $len. otherwise something is wrong - if ( strlen( $data ) != $len ) { - return false; - } - return $data; + return strlen( $data ) == $len; } /** @@ -124,6 +118,7 @@ class ZhClient { } return $ret; } + /** * Perform word segmentation * diff --git a/includes/ZipDirectoryReader.php b/includes/ZipDirectoryReader.php index d21cf3b052..37934aeaef 100644 --- a/includes/ZipDirectoryReader.php +++ b/includes/ZipDirectoryReader.php @@ -1,8 +1,8 @@ getBlock( $startPos ); $sigPos = strrpos( $block, "PK\x05\x06" ); if ( $sigPos === false ) { - $this->error( 'zip-wrong-format', + $this->error( 'zip-wrong-format', "zip file lacks EOCDR signature. It probably isn't a zip file." ); } @@ -212,7 +213,7 @@ class ZipDirectoryReader { } /** - * Read the header called the "ZIP64 end of central directory locator". An + * Read the header called the "ZIP64 end of central directory locator". An * error will be raised if it does not exist. */ function readZip64EndOfCentralDirectoryLocator() { @@ -224,20 +225,20 @@ class ZipDirectoryReader { ); $structSize = $this->getStructSize( $info ); - $block = $this->getBlock( $this->getFileLength() - $this->eocdr['EOCDR size'] + $block = $this->getBlock( $this->getFileLength() - $this->eocdr['EOCDR size'] - $structSize, $structSize ); $this->eocdr64Locator = $data = $this->unpack( $block, $info ); if ( $data['signature'] !== "PK\x06\x07" ) { - // Note: Java will allow this and continue to read the - // EOCDR64, so we have to reject the upload, we can't + // Note: Java will allow this and continue to read the + // EOCDR64, so we have to reject the upload, we can't // just use the EOCDR header instead. $this->error( 'zip-bad', 'wrong signature on Zip64 end of central directory locator' ); } } /** - * Read the header called the "ZIP64 end of central directory record". It + * Read the header called the "ZIP64 end of central directory record". It * may replace the regular "end of central directory record" in ZIP64 files. */ function readZip64EndOfCentralDirectoryRecord() { @@ -266,14 +267,14 @@ class ZipDirectoryReader { $this->error( 'zip-bad', 'wrong signature on Zip64 end of central directory record' ); } if ( $data['disk'] !== 0 - || $data['CD start disk'] !== 0 ) + || $data['CD start disk'] !== 0 ) { $this->error( 'zip-unsupported', 'more than one disk (in EOCDR64)' ); } } /** - * Find the location of the central directory, as would be seen by a + * Find the location of the central directory, as would be seen by a * non-ZIP64 reader. * * @return List containing offset, size and end position. @@ -286,27 +287,27 @@ class ZipDirectoryReader { // Some readers use the EOCDR position instead of the offset field // to find the directory, so to be safe, we check if they both agree. if ( $offset + $size != $endPos ) { - $this->error( 'zip-bad', 'the central directory does not immediately precede the end ' . + $this->error( 'zip-bad', 'the central directory does not immediately precede the end ' . 'of central directory record' ); } return array( $offset, $size ); } /** - * Find the location of the central directory, as would be seen by a + * Find the location of the central directory, as would be seen by a * ZIP64-compliant reader. * * @return List containing offset, size and end position. */ function findZip64CentralDirectory() { - // The spec is ambiguous about the exact rules of precedence between the - // ZIP64 headers and the original headers. Here we follow zip_util.c + // The spec is ambiguous about the exact rules of precedence between the + // ZIP64 headers and the original headers. Here we follow zip_util.c // from OpenJDK 7. $size = $this->eocdr['CD size']; $offset = $this->eocdr['CD offset']; $numEntries = $this->eocdr['CD entries total']; $endPos = $this->eocdr['position']; - if ( $size == 0xffffffff + if ( $size == 0xffffffff || $offset == 0xffffffff || $numEntries == 0xffff ) { @@ -324,7 +325,7 @@ class ZipDirectoryReader { // Some readers use the EOCDR position instead of the offset field // to find the directory, so to be safe, we check if they both agree. if ( $offset + $size != $endPos ) { - $this->error( 'zip-bad', 'the central directory does not immediately precede the end ' . + $this->error( 'zip-bad', 'the central directory does not immediately precede the end ' . 'of central directory record' ); } return array( $offset, $size ); @@ -390,7 +391,7 @@ class ZipDirectoryReader { } // Convert the timestamp into MediaWiki format - // For the format, please see the MS-DOS 2.0 Programmer's Reference, + // For the format, please see the MS-DOS 2.0 Programmer's Reference, // pages 3-5 and 3-6. $time = $data['mod time']; $date = $data['mod date']; @@ -405,8 +406,8 @@ class ZipDirectoryReader { $year, $month, $day, $hour, $minute, $second ); // Convert the character set in the file name - if ( !function_exists( 'iconv' ) - || $this->testBit( $data['general bits'], self::GENERAL_UTF8 ) ) + if ( !function_exists( 'iconv' ) + || $this->testBit( $data['general bits'], self::GENERAL_UTF8 ) ) { $name = $data['name']; } else { @@ -444,7 +445,7 @@ class ZipDirectoryReader { while ( $extraPos < strlen( $extraField ) ) { $extra = $this->unpack( $extraField, $extraHeaderInfo, $extraPos ); $extraPos += $extraHeaderSize; - $extra += $this->unpack( $extraField, + $extra += $this->unpack( $extraField, array( 'data' => array( 'string', $extra['size'] ) ), $extraPos ); $extraPos += $extra['size']; @@ -473,7 +474,7 @@ class ZipDirectoryReader { * in the file to satisfy the request, an exception will be thrown. * * @param $start The byte offset of the start of the block. - * @param $length The number of bytes to return. If omitted, the remainder + * @param $length The number of bytes to return. If omitted, the remainder * of the file will be returned. * * @return string @@ -500,10 +501,10 @@ class ZipDirectoryReader { $block .= $this->getSegment( $segIndex ); } - $block = substr( $block, + $block = substr( $block, $start - $startSeg * self::SEGSIZE, $length ); - + if ( strlen( $block ) < $length ) { $this->error( 'zip-bad', 'getBlock() returned an unexpectedly small amount of data' ); } @@ -512,12 +513,12 @@ class ZipDirectoryReader { } /** - * Get a section of the file starting at position $segIndex * self::SEGSIZE, - * of length self::SEGSIZE. The result is cached. This is a helper function + * Get a section of the file starting at position $segIndex * self::SEGSIZE, + * of length self::SEGSIZE. The result is cached. This is a helper function * for getBlock(). * - * If there are not enough bytes in the file to satsify the request, the - * return value will be truncated. If a request is made for a segment beyond + * If there are not enough bytes in the file to satsify the request, the + * return value will be truncated. If a request is made for a segment beyond * the end of the file, an empty string will be returned. */ function getSegment( $segIndex ) { @@ -556,25 +557,25 @@ class ZipDirectoryReader { } /** - * Unpack a binary structure. This is like the built-in unpack() function + * Unpack a binary structure. This is like the built-in unpack() function * except nicer. * * @param $string The binary data input * - * @param $struct An associative array giving structure members and their - * types. In the key is the field name. The value may be either an - * integer, in which case the field is a little-endian unsigned integer - * encoded in the given number of bytes, or an array, in which case the - * first element of the array is the type name, and the subsequent + * @param $struct An associative array giving structure members and their + * types. In the key is the field name. The value may be either an + * integer, in which case the field is a little-endian unsigned integer + * encoded in the given number of bytes, or an array, in which case the + * first element of the array is the type name, and the subsequent * elements are type-dependent parameters. Only one such type is defined: - * - "string": The second array element gives the length of string. + * - "string": The second array element gives the length of string. * Not null terminated. * * @param $offset The offset into the string at which to start unpacking. * - * @return Unpacked associative array. Note that large integers in the input - * may be represented as floating point numbers in the return value, so - * the use of weak comparison is advised. + * @return Unpacked associative array. Note that large integers in the input + * may be represented as floating point numbers in the return value, so + * the use of weak comparison is advised. */ function unpack( $string, $struct, $offset = 0 ) { $size = $this->getStructSize( $struct ); @@ -600,8 +601,8 @@ class ZipDirectoryReader { $length = intval( $type ); $bytes = substr( $string, $pos, $length ); - // Calculate the value. Use an algorithm which automatically - // upgrades the value to floating point if necessary. + // Calculate the value. Use an algorithm which automatically + // upgrades the value to floating point if necessary. $value = 0; for ( $i = $length - 1; $i >= 0; $i-- ) { $value *= 256; @@ -623,7 +624,7 @@ class ZipDirectoryReader { } /** - * Returns a bit from a given position in an integer value, converted to + * Returns a bit from a given position in an integer value, converted to * boolean. * * @param $value integer @@ -678,6 +679,9 @@ class ZipDirectoryReaderError extends Exception { parent::__construct( "ZipDirectoryReader error: $code" ); } + /** + * @return mixed + */ function getErrorCode() { return $this->code; } diff --git a/index.php5 b/index.php5 index 58f3233707..a738b066a9 100644 --- a/index.php5 +++ b/index.php5 @@ -1 +1 @@ -mDescription = "Fetch the revision text from an old_id"; } - /* + /** * returns a string containing the following in order: * textid * \n diff --git a/resources/mediawiki/mediawiki.js b/resources/mediawiki/mediawiki.js index 5770fc8735..2073378d9b 100644 --- a/resources/mediawiki/mediawiki.js +++ b/resources/mediawiki/mediawiki.js @@ -222,7 +222,7 @@ window.mw = window.mediaWiki = new ( function( $ ) { /* Public Members */ - /* + /** * Dummy function which in debug mode can be replaced with a function that * emulates console.log in console-less environments. */ @@ -249,7 +249,7 @@ window.mw = window.mediaWiki = new ( function( $ ) { */ this.libs = {}; - /* + /** * Localization system */ this.messages = new this.Map(); @@ -556,7 +556,7 @@ window.mw = window.mediaWiki = new ( function( $ ) { callback(); return; } - + addScript( arr[i], function() { nestedAddScript( arr, callback, i + 1 ); } ); @@ -1175,7 +1175,7 @@ window.mw = window.mediaWiki = new ( function( $ ) { } ); return names; }; - + /** * For backwards-compatibility with Squid-cached pages. Loads mw.user */ diff --git a/skins/common/upload.js b/skins/common/upload.js index 99917c75bd..2e8f54e89a 100644 --- a/skins/common/upload.js +++ b/skins/common/upload.js @@ -34,46 +34,45 @@ window.wgUploadSetup = function() { } } } - - + // AJAX wpDestFile warnings if ( wgAjaxUploadDestCheck ) { // Insert an event handler that fetches upload warnings when wpDestFile // has been changed - document.getElementById( 'wpDestFile' ).onchange = function ( e ) { + document.getElementById( 'wpDestFile' ).onchange = function ( e ) { wgUploadWarningObj.checkNow(this.value); }; - // Insert a row where the warnings will be displayed just below the + // Insert a row where the warnings will be displayed just below the // wpDestFile row var optionsTable = document.getElementById( 'mw-htmlform-description' ).tBodies[0]; var row = optionsTable.insertRow( 1 ); var td = document.createElement( 'td' ); td.id = 'wpDestFile-warning'; td.colSpan = 2; - + row.appendChild( td ); } - + var wpLicense = document.getElementById( 'wpLicense' ); if ( wgAjaxLicensePreview && wpLicense ) { // License selector check wpLicense.onchange = licenseSelectorCheck; - + // License selector table row var wpLicenseRow = wpLicense.parentNode.parentNode; var wpLicenseTbody = wpLicenseRow.parentNode; - + var row = document.createElement( 'tr' ); var td = document.createElement( 'td' ); row.appendChild( td ); td = document.createElement( 'td' ); td.id = 'mw-license-preview'; row.appendChild( td ); - + wpLicenseTbody.insertBefore( row, wpLicenseRow.nextSibling ); } - - + + // fillDestFile setup for ( var i = 0; i < wgUploadSourceIds.length; i++ ) document.getElementById( wgUploadSourceIds[i] ).onchange = function (e) { @@ -150,7 +149,7 @@ window.wgUploadWarningObj = { var ackElt = document.getElementsByName( 'wpDestFileWarningAck' ); this.setInnerHTML(warningElt, warning); - + // Set a value in the form indicating that the warning is acknowledged and // doesn't need to be redisplayed post-upload if ( warning == '' || warning == ' ' ) { @@ -196,7 +195,7 @@ window.fillDestFilename = function(id) { } // Clear the filename if it does not have a valid extension. - // URLs are less likely to have a useful extension, so don't include them in the + // URLs are less likely to have a useful extension, so don't include them in the // extension check. if( wgStrictFileExtensions && wgFileExtensions && id != 'wpUploadFileURL' ) { var found = false; @@ -262,15 +261,15 @@ window.wgUploadLicenseObj = { } } injectSpinner( document.getElementById( 'wpLicense' ), 'license' ); - + var title = document.getElementById('wpDestFile').value; if ( !title ) title = 'File:Sample.jpg'; - + var url = wgScriptPath + '/api' + wgScriptExtension + '?action=parse&text={{' + encodeURIComponent( license ) + '}}' - + '&title=' + encodeURIComponent( title ) + + '&title=' + encodeURIComponent( title ) + '&prop=text&pst&format=json'; - + var req = sajax_init_object(); req.onreadystatechange = function() { if ( req.readyState == 4 && req.status == 200 ) @@ -284,7 +283,6 @@ window.wgUploadLicenseObj = { removeSpinner( 'license' ); this.responseCache[license] = result['parse']['text']['*']; this.showPreview( this.responseCache[license] ); - }, 'showPreview' : function( preview ) { diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index 8af2846c23..dae512f95d 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -1199,7 +1199,7 @@ class ParserTest { return true; } - /* + /** * Run the "tidy" command on text if the $wgUseTidy * global is true * diff --git a/tests/phpunit/includes/IPTest.php b/tests/phpunit/includes/IPTest.php index d0d28f6c9d..4397b87971 100644 --- a/tests/phpunit/includes/IPTest.php +++ b/tests/phpunit/includes/IPTest.php @@ -43,20 +43,20 @@ class IPTest extends MediaWikiTestCase { $this->assertFalse( IP::isIPv6( 'fc:100:::' ), 'IPv6 ending with a ":::"' ); $this->assertFalse( IP::isIPv6( 'fc:300' ), 'IPv6 with only 2 words' ); $this->assertFalse( IP::isIPv6( 'fc:100:300' ), 'IPv6 with only 3 words' ); - + $this->assertTrue( IP::isIPv6( 'fc:100::' ) ); $this->assertTrue( IP::isIPv6( 'fc:100:a::' ) ); $this->assertTrue( IP::isIPv6( 'fc:100:a:d::' ) ); $this->assertTrue( IP::isIPv6( 'fc:100:a:d:1::' ) ); $this->assertTrue( IP::isIPv6( 'fc:100:a:d:1:e::' ) ); $this->assertTrue( IP::isIPv6( 'fc:100:a:d:1:e:ac::' ) ); - + $this->assertFalse( IP::isIPv6( 'fc:100:a:d:1:e:ac:0::' ), 'IPv6 with 8 words ending with "::"' ); $this->assertFalse( IP::isIPv6( 'fc:100:a:d:1:e:ac:0:1::' ), 'IPv6 with 9 words ending with "::"' ); $this->assertFalse( IP::isIPv6( ':::' ) ); $this->assertFalse( IP::isIPv6( '::0:' ), 'IPv6 ending in a lone ":"' ); - + $this->assertTrue( IP::isIPv6( '::' ), 'IPv6 zero address' ); $this->assertTrue( IP::isIPv6( '::0' ) ); $this->assertTrue( IP::isIPv6( '::fc' ) ); @@ -66,14 +66,14 @@ class IPTest extends MediaWikiTestCase { $this->assertTrue( IP::isIPv6( '::fc:100:a:d:1' ) ); $this->assertTrue( IP::isIPv6( '::fc:100:a:d:1:e' ) ); $this->assertTrue( IP::isIPv6( '::fc:100:a:d:1:e:ac' ) ); - + $this->assertFalse( IP::isIPv6( '::fc:100:a:d:1:e:ac:0' ), 'IPv6 with "::" and 8 words' ); $this->assertFalse( IP::isIPv6( '::fc:100:a:d:1:e:ac:0:1' ), 'IPv6 with 9 words' ); $this->assertFalse( IP::isIPv6( ':fc::100' ), 'IPv6 starting with lone ":"' ); $this->assertFalse( IP::isIPv6( 'fc::100:' ), 'IPv6 ending with lone ":"' ); $this->assertFalse( IP::isIPv6( 'fc:::100' ), 'IPv6 with ":::" in the middle' ); - + $this->assertTrue( IP::isIPv6( 'fc::100' ), 'IPv6 with "::" and 2 words' ); $this->assertTrue( IP::isIPv6( 'fc::100:a' ), 'IPv6 with "::" and 3 words' ); $this->assertTrue( IP::isIPv6( 'fc::100:a:d', 'IPv6 with "::" and 4 words' ) ); @@ -83,7 +83,7 @@ class IPTest extends MediaWikiTestCase { $this->assertTrue( IP::isIPv6( '2001::df'), 'IPv6 with "::" and 2 words' ); $this->assertTrue( IP::isIPv6( '2001:5c0:1400:a::df'), 'IPv6 with "::" and 5 words' ); $this->assertTrue( IP::isIPv6( '2001:5c0:1400:a::df:2'), 'IPv6 with "::" and 6 words' ); - + $this->assertFalse( IP::isIPv6( 'fc::100:a:d:1:e:ac:0' ), 'IPv6 with "::" and 8 words' ); $this->assertFalse( IP::isIPv6( 'fc::100:a:d:1:e:ac:0:1' ), 'IPv6 with 9 words' ); @@ -135,11 +135,11 @@ class IPTest extends MediaWikiTestCase { $this->assertFalse( IP::isValid( 'fc:100:::' ), 'IPv6 ending with a ":::"' ); $this->assertFalse( IP::isValid( 'fc:300' ), 'IPv6 with only 2 words' ); $this->assertFalse( IP::isValid( 'fc:100:300' ), 'IPv6 with only 3 words' ); - + $this->assertTrue( IP::isValid( 'fc:100::' ) ); $this->assertTrue( IP::isValid( 'fc:100:a:d:1:e::' ) ); $this->assertTrue( IP::isValid( 'fc:100:a:d:1:e:ac::' ) ); - + $this->assertTrue( IP::isValid( 'fc::100' ), 'IPv6 with "::" and 2 words' ); $this->assertTrue( IP::isValid( 'fc::100:a' ), 'IPv6 with "::" and 3 words' ); $this->assertTrue( IP::isValid( '2001::df'), 'IPv6 with "::" and 2 words' ); @@ -147,7 +147,7 @@ class IPTest extends MediaWikiTestCase { $this->assertTrue( IP::isValid( '2001:5c0:1400:a::df:2'), 'IPv6 with "::" and 6 words' ); $this->assertTrue( IP::isValid( 'fc::100:a:d:1' ), 'IPv6 with "::" and 5 words' ); $this->assertTrue( IP::isValid( 'fc::100:a:d:1:e:ac' ), 'IPv6 with "::" and 7 words' ); - + $this->assertFalse( IP::isValid( 'fc:100:a:d:1:e:ac:0::' ), 'IPv6 with 8 words ending with "::"' ); $this->assertFalse( IP::isValid( 'fc:100:a:d:1:e:ac:0:1::' ), 'IPv6 with 9 words ending with "::"' ); } @@ -332,7 +332,7 @@ class IPTest extends MediaWikiTestCase { $this->assertEquals( '0:0:0:0:0:0:FCCF:FAFF', IP::hexToOctet( 'FCCFFAFF' ) ); } - /* + /** * IP::parseCIDR() returns an array containing a signed IP address * representing the network mask and the bit mask. * @covers IP::parseCIDR @@ -391,7 +391,7 @@ class IPTest extends MediaWikiTestCase { } /** - * Issues there are most probably from IP::toHex() or IP::parseRange() + * Issues there are most probably from IP::toHex() or IP::parseRange() * @covers IP::isInRange * @dataProvider provideIPsAndRanges */ @@ -464,9 +464,9 @@ class IPTest extends MediaWikiTestCase { */ function testCombineHostAndPort( $expected, $input, $description ) { list( $host, $port, $defaultPort ) = $input; - $this->assertEquals( - $expected, - IP::combineHostAndPort( $host, $port, $defaultPort ), + $this->assertEquals( + $expected, + IP::combineHostAndPort( $host, $port, $defaultPort ), $description ); } diff --git a/tests/phpunit/includes/SeleniumConfigurationTest.php b/tests/phpunit/includes/SeleniumConfigurationTest.php index 750524ebb6..8589c188a4 100644 --- a/tests/phpunit/includes/SeleniumConfigurationTest.php +++ b/tests/phpunit/includes/SeleniumConfigurationTest.php @@ -2,13 +2,13 @@ class SeleniumConfigurationTest extends MediaWikiTestCase { - /* + /** * The file where the test temporarity stores the selenium config. * This should be cleaned up as part of teardown. */ private $tempFileName; - /* + /** * String containing the a sample selenium settings */ private $testConfig0 = @@ -32,14 +32,14 @@ runAgainstGrid = false testSuite[SimpleSeleniumTestSuite] = "tests/selenium/SimpleSeleniumTestSuite.php" testSuite[TestSuiteName] = "testSuitePath" '; - /* + /** * Array of expected browsers from $testConfig0 */ private $testBrowsers0 = array( 'firefox' => '*firefox', 'iexplorer' => '*iexploreproxy', 'chrome' => '*chrome' ); - /* + /** * Array of expected selenium settings from $testConfig0 */ private $testSettings0 = array( @@ -55,7 +55,7 @@ testSuite[TestSuiteName] = "testSuitePath" 'jUnitLogFile' => null, 'runAgainstGrid' => null ); - /* + /** * Array of expected testSuites from $testConfig0 */ private $testSuites0 = array( @@ -64,7 +64,7 @@ testSuite[TestSuiteName] = "testSuitePath" ); - /* + /** * Another sample selenium settings file contents */ private $testConfig1 = @@ -73,11 +73,11 @@ testSuite[TestSuiteName] = "testSuitePath" host = "localhost" testBrowser = "firefox" '; - /* + /** * Expected browsers from $testConfig1 */ private $testBrowsers1 = null; - /* + /** * Expected selenium settings from $testConfig1 */ private $testSettings1 = array( @@ -93,7 +93,7 @@ testBrowser = "firefox" 'jUnitLogFile' => null, 'runAgainstGrid' => null ); - /* + /** * Expected test suites from $testConfig1 */ private $testSuites1 = null; @@ -105,7 +105,7 @@ testBrowser = "firefox" } } - /* + /** * Clean up the temporary file used to store the selenium settings. */ public function tearDown() { @@ -199,7 +199,7 @@ testBrowser = "firefox" } - /* + /** * create a temp file and write text to it. * @param $testToWrite the text to write to the temp file */ @@ -210,7 +210,7 @@ testBrowser = "firefox" fclose($tempFile); } - /* + /** * Returns an array containing: * The contents of the selenium cingiguration ini file * The expected selenium configuration array that getSeleniumSettings should return diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index 050071151f..e23bad7b2f 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -729,7 +729,7 @@ class NewParserTest extends MediaWikiTestCase { } //Various "cleanup" functions - /* + /** * Run the "tidy" command on text if the $wgUseTidy * global is true * diff --git a/tests/phpunit/includes/search/SearchEngineTest.php b/tests/phpunit/includes/search/SearchEngineTest.php index 2cbb900789..e3684c9753 100644 --- a/tests/phpunit/includes/search/SearchEngineTest.php +++ b/tests/phpunit/includes/search/SearchEngineTest.php @@ -12,7 +12,7 @@ class SearchEngineTest extends MediaWikiTestCase { unset( $this->search ); } - /* + /** * Checks for database type & version. * Will skip current test if DB does not support search. */ diff --git a/tests/selenium/SeleniumConfig.php b/tests/selenium/SeleniumConfig.php index b8cdf1c54a..b148715454 100644 --- a/tests/selenium/SeleniumConfig.php +++ b/tests/selenium/SeleniumConfig.php @@ -5,7 +5,7 @@ if ( !defined( 'SELENIUMTEST' ) ) { class SeleniumConfig { - /* + /** * Retreives the Selenium configuration values from an ini file. * See sample config file in selenium_settings.ini.sample * @@ -72,14 +72,14 @@ class SeleniumConfig { return false; } $header = ''; - + $configArray = array(); - + while ( ( $line = fgets( $file ) ) !== false ) { $line = strtok( $line, "\r\n" ); - + if ( !$line || $line[0] == ';' ) continue; - + if ( $line[0] == '[' && substr( $line, -1 ) == ']' ) { $header = substr( $line, 1, -1 ); $configArray[$header] = array(); @@ -95,19 +95,19 @@ class SeleniumConfig { list( $key, $value ) = explode( '=', $iniLine, 2 ); $key = trim( $key ); $value = trim( $value ); - + if ( isset( $specialValues[$value] ) ) { $value = $specialValues[$value]; } else { $value = trim( $value, '"' ); } - + /* Support one-level arrays */ if ( preg_match( '/^([A-Za-z]+)\[([A-Za-z]+)\]/', $key, $m ) ) { $key = $m[1]; $value = array( $m[2] => $value ); } - + return array( $key => $value ); } } diff --git a/tests/selenium/suites/MediawikiCoreSmokeTestCase.php b/tests/selenium/suites/MediawikiCoreSmokeTestCase.php index 7b9525afb2..5fc1a5a6de 100644 --- a/tests/selenium/suites/MediawikiCoreSmokeTestCase.php +++ b/tests/selenium/suites/MediawikiCoreSmokeTestCase.php @@ -1,44 +1,44 @@ login(); $this->open( $this->getUrl() . @@ -48,10 +48,10 @@ class MediawikiCoreSmokeTestCase extends SeleniumTestCase { $this->check( 'wpIgnoreWarning' ); $this->click( 'wpUpload' ); $this->waitForPageToLoad( 30000 ); - + $this->assertSeleniumHTMLContains( '//h1[@class="firstHeading"]', "Wikipedia-logo-v2-de.png" ); - + /* $this->open( $this->getUrl() . '/index.php?title=Image:' . ucfirst( $this->filename ) . '&action=delete' ); @@ -64,6 +64,6 @@ class MediawikiCoreSmokeTestCase extends SeleniumTestCase { ucfirst( $this->filename ) . '.*has been deleted.' ); */ } - + } diff --git a/tests/selenium/suites/SimpleSeleniumTestCase.php b/tests/selenium/suites/SimpleSeleniumTestCase.php index 99a75c12c8..b87172e6ed 100644 --- a/tests/selenium/suites/SimpleSeleniumTestCase.php +++ b/tests/selenium/suites/SimpleSeleniumTestCase.php @@ -1,11 +1,11 @@ open( $this->getUrl() . + $this->open( $this->getUrl() . '/index.php?title=Selenium&action=edit' ); $this->type( "wpTextbox1", "This is a basic test" ); $this->click( "wpPreview" ); @@ -16,8 +16,8 @@ class SimpleSeleniumTestCase extends SeleniumTestCase { $correct = strstr( $source, "This is a basic test" ); $this->assertEquals( $correct, true ); } - - /* + + /** * All this test really does is verify that a global var was set. * It depends on $wgDefaultSkin = 'chick'; being set */ @@ -26,9 +26,9 @@ class SimpleSeleniumTestCase extends SeleniumTestCase { $bodyClass = $this->getAttribute( "//body/@class" ); $this-> assertContains('skin-chick', $bodyClass, 'Chick skin not set'); } - - /* - * Just verify that the test db was loaded correctly + + /** + * Just verify that the test db was loaded correctly */ public function testDatabaseResourceLoadedCorrectly() { $this->open( $this->getUrl() . '/index.php/TestResources?action=purge' ); -- 2.20.1