$this->session = $session;
}
+ /**
+ * @param $method string
+ * @throws MWException
+ */
private function notImplemented( $method ) {
throw new MWException( "{$method}() not implemented" );
}
/**
* @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;
return true;
}
+ /**
+ * @return mixed|null|Title
+ */
public function getRedirectTarget() {
$this->loadFile();
if ( $this->mFile->isLocal() ) {
return $this->mRedirectTarget = Title::makeTitle( NS_FILE, $to );
}
+ /**
+ * @return bool|mixed|Title
+ */
public function followRedirect() {
$this->loadFile();
if ( $this->mFile->isLocal() ) {
return Title::makeTitle( NS_FILE, $to );
}
+ /**
+ * @param bool $text
+ * @return bool
+ */
public function isRedirect( $text = false ) {
$this->loadFile();
if ( $this->mFile->isLocal() ) {
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 ) ) {
// 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 ) {
array( 'lang' => $minor, 'site' => $major ) );
return new WikiReference( $major, $minor, $canonicalServer, $path, $server );
}
-
+
/**
* Convenience to get the wiki's display name
*
*/
public static function getForeignURL( $wikiID, $page ) {
$wiki = WikiMap::getWiki( $wikiID );
-
+
if ( $wiki ) {
return $wiki->getUrl( $page );
}
-
+
return false;
}
}
$this->mServer = $server === null ? $canonicalServer : $server;
}
+ /**
+ * @return string
+ * @throws MWException
+ */
public function getHostname() {
$prefixes = array( 'http://', 'https://' );
foreach ( $prefixes as $prefix ) {
* @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
*/
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
/**@}}*/
* Should the parser cache be used?
*
* @param $user User The relevant user
+ * @param $oldid int
* @return boolean
*/
public function isParserCacheUsed( User $user, $oldid ) {
*
* @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__ );
* 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
* Updates cascading protections
*
* @param $parserOutput ParserOutput object for the current version
- **/
+ */
public function doCascadeProtectionUpdates( ParserOutput $parserOutput ) {
if ( wfReadOnly() || !$this->mTitle->areRestrictionsCascading() ) {
return;
}
}
- /*
- * @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 );
$errno = $errstr = '';
$this->mFP = fsockopen( $this->mHost, $this->mPort, $errno, $errstr, 30 );
wfRestoreWarnings();
- if ( !$this->mFP ) {
- return false;
- }
- return true;
+ return !$this->mFP;
}
/**
$data .= $str;
}
// data should be of length $len. otherwise something is wrong
- if ( strlen( $data ) != $len ) {
- return false;
- }
- return $data;
+ return strlen( $data ) == $len;
}
/**
}
return $ret;
}
+
/**
* Perform word segmentation
*
<?php
/**
- * A class for reading ZIP file directories, for the purposes of upload
- * verification.
+ * A class for reading ZIP file directories, for the purposes of upload
+ * verification.
*
* Only a functional interface is provided: ZipFileReader::read(). No access is
* given to object instances.
/**
* Read a ZIP file and call a function for each file discovered in it.
*
- * Because this class is aimed at verification, an error is raised on
+ * Because this class is aimed at verification, an error is raised on
* suspicious or ambiguous input, instead of emulating some standard
* behaviour.
*
* @param $callback Array The callback function. It will be called for each file
* with a single associative array each time, with members:
*
- * - name: The file name. Directories conventionally have a trailing
+ * - name: The file name. Directories conventionally have a trailing
* slash.
*
* - mtime: The file modification time, in MediaWiki 14-char format
* @param $options Array An associative array of read options, with the option
* name in the key. This may currently contain:
*
- * - zip64: If this is set to true, then we will emulate a
- * library with ZIP64 support, like OpenJDK 7. If it is set to
- * false, then we will emulate a library with no knowledge of
+ * - zip64: If this is set to true, then we will emulate a
+ * library with ZIP64 support, like OpenJDK 7. If it is set to
+ * false, then we will emulate a library with no knowledge of
* ZIP64.
*
- * NOTE: The ZIP64 code is untested and probably doesn't work. It
- * turned out to be easier to just reject ZIP64 archive uploads,
- * since they are likely to be very rare. Confirming safety of a
- * ZIP64 file is fairly complex. What do you do with a file that is
- * ambiguous and broken when read with a non-ZIP64 reader, but valid
- * when read with a ZIP64 reader? This situation is normal for a
- * valid ZIP64 file, and working out what non-ZIP64 readers will make
+ * NOTE: The ZIP64 code is untested and probably doesn't work. It
+ * turned out to be easier to just reject ZIP64 archive uploads,
+ * since they are likely to be very rare. Confirming safety of a
+ * ZIP64 file is fairly complex. What do you do with a file that is
+ * ambiguous and broken when read with a non-ZIP64 reader, but valid
+ * when read with a ZIP64 reader? This situation is normal for a
+ * valid ZIP64 file, and working out what non-ZIP64 readers will make
* of such a file is not trivial.
*
* @return Status object. The following fatal errors are defined:
*
* - zip-wrong-format: The file does not appear to be a ZIP file.
*
- * - zip-bad: There was something wrong or ambiguous about the file
+ * - zip-bad: There was something wrong or ambiguous about the file
* data.
*
- * - zip-unsupported: The ZIP file uses features which
+ * - zip-unsupported: The ZIP file uses features which
* ZipDirectoryReader does not support.
*
- * The default messages for those fatal errors are written in a way that
+ * The default messages for those fatal errors are written in a way that
* makes sense for upload verification.
*
- * If a fatal error is returned, more information about the error will be
+ * If a fatal error is returned, more information about the error will be
* available in the debug log.
*
* Note that the callback function may be called any number of times before
- * a fatal error is returned. If this occurs, the data sent to the callback
+ * a fatal error is returned. If this occurs, the data sent to the callback
* function should be discarded.
*/
public static function read( $fileName, $callback, $options = array() ) {
/** Stored headers */
var $eocdr, $eocdr64, $eocdr64Locator;
+ var $data;
+
/** The "extra field" ID for ZIP64 central directory entries */
const ZIP64_EXTRA_HEADER = 0x0001;
/** The index of the "general field" bit for central directory encryption */
const GENERAL_CD_ENCRYPTED = 13;
-
/**
* Private constructor
*/
}
/**
- * Read the header which is at the end of the central directory,
- * unimaginatively called the "end of central directory record" by the ZIP
+ * Read the header which is at the end of the central directory,
+ * unimaginatively called the "end of central directory record" by the ZIP
* spec.
*/
function readEndOfCentralDirectoryRecord() {
$block = $this->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." );
}
}
/**
- * 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() {
);
$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() {
$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.
// 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 )
{
// 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 );
}
// 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'];
$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 {
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'];
* 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
$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' );
}
}
/**
- * 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 ) {
}
/**
- * 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 );
$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;
}
/**
- * 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
parent::__construct( "ZipDirectoryReader error: $code" );
}
+ /**
+ * @return mixed
+ */
function getErrorCode() {
return $this->code;
}
-<?php require './index.php';
\ No newline at end of file
+<?php require './index.php';
$this->mDescription = "Fetch the revision text from an old_id";
}
- /*
+ /**
* returns a string containing the following in order:
* textid
* \n
/* Public Members */
- /*
+ /**
* Dummy function which in debug mode can be replaced with a function that
* emulates console.log in console-less environments.
*/
*/
this.libs = {};
- /*
+ /**
* Localization system
*/
this.messages = new this.Map();
callback();
return;
}
-
+
addScript( arr[i], function() {
nestedAddScript( arr, callback, i + 1 );
} );
} );
return names;
};
-
+
/**
* For backwards-compatibility with Squid-cached pages. Loads mw.user
*/
}
}
}
-
-
+
// 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) {
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 == ' ' ) {
}
// 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;
}
}
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 )
removeSpinner( 'license' );
this.responseCache[license] = result['parse']['text']['*'];
this.showPreview( this.responseCache[license] );
-
},
'showPreview' : function( preview ) {
return true;
}
- /*
+ /**
* Run the "tidy" command on text if the $wgUseTidy
* global is true
*
$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' ) );
$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' ) );
$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' );
$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' );
$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 "::"' );
}
$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
}
/**
- * 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
*/
*/
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 );
}
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 =
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(
'jUnitLogFile' => null,
'runAgainstGrid' => null
);
- /*
+ /**
* Array of expected testSuites from $testConfig0
*/
private $testSuites0 = array(
);
- /*
+ /**
* Another sample selenium settings file contents
*/
private $testConfig1 =
host = "localhost"
testBrowser = "firefox"
';
- /*
+ /**
* Expected browsers from $testConfig1
*/
private $testBrowsers1 = null;
- /*
+ /**
* Expected selenium settings from $testConfig1
*/
private $testSettings1 = array(
'jUnitLogFile' => null,
'runAgainstGrid' => null
);
- /*
+ /**
* Expected test suites from $testConfig1
*/
private $testSuites1 = null;
}
}
- /*
+ /**
* Clean up the temporary file used to store the selenium settings.
*/
public function tearDown() {
}
- /*
+ /**
* create a temp file and write text to it.
* @param $testToWrite the text to write to the temp file
*/
fclose($tempFile);
}
- /*
+ /**
* Returns an array containing:
* The contents of the selenium cingiguration ini file
* The expected selenium configuration array that getSeleniumSettings should return
}
//Various "cleanup" functions
- /*
+ /**
* Run the "tidy" command on text if the $wgUseTidy
* global is true
*
unset( $this->search );
}
- /*
+ /**
* Checks for database type & version.
* Will skip current test if DB does not support search.
*/
class SeleniumConfig {
- /*
+ /**
* Retreives the Selenium configuration values from an ini file.
* See sample config file in selenium_settings.ini.sample
*
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();
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 );
}
}
<?php
-/*
+/*
* Stub of tests be need as part of the hack-a-ton
*/
class MediawikiCoreSmokeTestCase extends SeleniumTestCase {
public function testUserLogin() {
-
+
}
-
+
public function testChangeUserPreference() {
-
+
}
-
- /*
+
+ /**
* TODO: generalize this test to be reusable for different skins
*/
public function testCreateNewPageVector() {
-
+
}
-
- /*
+
+ /**
* TODO: generalize this test to be reusable for different skins
*/
public function testEditExistingPageVector() {
-
+
}
-
- /*
+
+ /**
* TODO: generalize this test to be reusable for different skins
*/
public function testCreateNewPageMonobook() {
-
+
}
-
- /*
+
+ /**
* TODO: generalize this test to be reusable for different skins
*/
public function testEditExistingPageMonobook() {
-
+
}
-
+
public function testImageUpload() {
$this->login();
$this->open( $this->getUrl() .
$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' );
ucfirst( $this->filename ) . '.*has been deleted.' );
*/
}
-
+
}
<?php
-/*
+/*
* This test case is part of the SimpleSeleniumTestSuite.
* Configuration for these tests are documented as part of SimpleSeleniumTestSuite.php
*/
class SimpleSeleniumTestCase extends SeleniumTestCase {
public function testBasic() {
- $this->open( $this->getUrl() .
+ $this->open( $this->getUrl() .
'/index.php?title=Selenium&action=edit' );
$this->type( "wpTextbox1", "This is a basic test" );
$this->click( "wpPreview" );
$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
*/
$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' );