namespace MediaWiki\Storage;
-use \IDBAccessObject;
+use IDBAccessObject;
use MediaWiki\Linker\LinkTarget;
use Title;
use ContentHandler;
use DBAccessObjectUtils;
use Hooks;
-use \IDBAccessObject;
+use IDBAccessObject;
use InvalidArgumentException;
use IP;
use LogicException;
* @file
* @ingroup FileBackend
*/
-use \MediaWiki\Logger\LoggerFactory;
+
+use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
/**
protected $mAction = false;
/**
- * Form attribute autocomplete. false does not set the attribute
+ * Form attribute autocomplete. A typical value is "off". null does not set the attribute
* @since 1.27
- * @var bool|string
+ * @var string|null
*/
- protected $mAutocomplete = false;
+ protected $mAutocomplete = null;
protected $mUseMultipart = false;
protected $mHiddenFields = [];
if ( $this->mId ) {
$attribs['id'] = $this->mId;
}
- if ( $this->mAutocomplete ) {
+ if ( is_string( $this->mAutocomplete ) ) {
$attribs['autocomplete'] = $this->mAutocomplete;
}
if ( $this->mName ) {
}
/**
- * Set the value for the autocomplete attribute of the form.
- * When set to false (which is the default state), the attribute get not set.
+ * Set the value for the autocomplete attribute of the form. A typical value is "off".
+ * When set to null (which is the default state), the attribute get not set.
*
* @since 1.27
*
- * @param string|bool $autocomplete
+ * @param string|null $autocomplete
*
* @return HTMLForm $this for chaining calls
*/
<?php
-namespace MediaWiki\Interwiki;
-
/**
* InterwikiLookup implementing the "classic" interwiki storage (hardcoded up to MW 1.26).
*
*
* @file
*/
-use \Cdb\Exception as CdbException;
-use \Cdb\Reader as CdbReader;
-use Wikimedia\Rdbms\Database;
+
+namespace MediaWiki\Interwiki;
+
+use Cdb\Exception as CdbException;
+use Cdb\Reader as CdbReader;
use Hooks;
use Interwiki;
use Language;
use MapCacheLRU;
use WANObjectCache;
+use Wikimedia\Rdbms\Database;
/**
* InterwikiLookup implementing the "classic" interwiki storage (hardcoded up to MW 1.26).
* @file
* @ingroup JobQueue
*/
-use \MediaWiki\MediaWikiServices;
+
+use MediaWiki\MediaWikiServices;
/**
* Job to prune link tables for pages that were deleted
* @ingroup Cache
*/
+use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\IDatabase;
use Wikimedia\Rdbms\DBError;
use Wikimedia\Rdbms\DBQueryError;
use Wikimedia\Rdbms\DBConnectionError;
-use \MediaWiki\MediaWikiServices;
-use \Wikimedia\WaitConditionLoop;
-use \Wikimedia\Rdbms\TransactionProfiler;
use Wikimedia\Rdbms\LoadBalancer;
+use Wikimedia\Rdbms\TransactionProfiler;
+use Wikimedia\WaitConditionLoop;
/**
* Class to store objects in the database
*/
use MediaWiki\Edit\PreparedEdit;
-use \MediaWiki\Logger\LoggerFactory;
-use \MediaWiki\MediaWikiServices;
+use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
use Wikimedia\Assert\Assert;
use Wikimedia\Rdbms\FakeResultWrapper;
use Wikimedia\Rdbms\IDatabase;
* @file
*/
-use \Cdb\Reader as CdbReader;
+use Cdb\Reader as CdbReader;
/**
* Functions to check passwords against a policy requirement
* @since 1.27
* @author C. Scott Ananian, 2016
*/
+
namespace MediaWiki\Tidy;
+use ExplodeIterator;
+use IteratorAggregate;
+use ReverseArrayIterator;
+use Sanitizer;
use Wikimedia\Assert\Assert;
use Wikimedia\Assert\ParameterAssertionException;
-use \ExplodeIterator;
-use \IteratorAggregate;
-use \ReverseArrayIterator;
-use \Sanitizer;
// A note for future librarization[1] -- this file is a good candidate
// for splitting into an independent library, except that it is currently
* @file
* @ingroup Maintenance
*/
+
+use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\IDatabase;
-use \MediaWiki\MediaWikiServices;
class BatchRowWriter {
/**
namespace MediaWiki\Languages\Data;
-use \CrhConverter as Crh;
+use CrhConverter as Crh;
class CrhExceptions {
* @todo document
* @ingroup Maintenance
*/
-use \Cdb\Exception as CdbException;
-use \Cdb\Reader as CdbReader;
+
+use Cdb\Exception as CdbException;
+use Cdb\Reader as CdbReader;
require_once __DIR__ . '/commandLine.inc';
<?php
+/**
+ * @covers Autopromote
+ */
class AutopromoteTest extends MediaWikiTestCase {
/**
* T157718: Verify Autopromote does not perform edit count lookup if requirement is 0 or invalid
/**
* per T28425
+ * @covers Block::__construct
*/
public function testBug26425BlockTimestampDefaultsToTime() {
$user = $this->getUserForBlocking();
$this->assertEquals( $exResult, $block->mReason, 'Correct block type for XFF header ' . $xff );
}
+ /**
+ * @covers Block::__construct
+ */
public function testDeprecatedConstructor() {
$this->hideDeprecated( 'Block::__construct with multiple arguments' );
$username = 'UnthinkablySecretRandomUsername';
);
}
+ /**
+ * @covers Block::getSystemBlockType
+ * @covers Block::insert
+ * @covers Block::doAutoblock
+ */
public function testSystemBlocks() {
$user = $this->getUserForBlocking();
$this->addBlockForUser( $user );
* @param array $paramSettings
* @param mixed $expected
* @param string[] $warnings
+ * @covers ApiBase::getParameterFromSettings
*/
public function testGetParameterFromSettings( $input, $paramSettings, $expected, $warnings ) {
$mock = new MockApi();
];
}
+ /**
+ * @covers ApiBase::errorArrayToStatus
+ */
public function testErrorArrayToStatus() {
$mock = new MockApi();
<?php
+/**
+ * @covers ApiOpenSearch
+ */
class ApiOpenSearchTest extends MediaWikiTestCase {
public function testGetAllowedParams() {
$config = $this->replaceSearchEngineConfig();
* @group API
* @group medium
* @group Database
+ * @covers ApiPageSet
*/
class ApiPageSetTest extends ApiTestCase {
public static function provideRedirectMergePolicy() {
* @group API
* @group Database
* @group medium
+ *
+ * @covers ApiQueryAllPages
*/
class ApiQueryAllPagesTest extends ApiTestCase {
);
}
+ /**
+ * @coversNothing
+ */
public function testApiTestGroup() {
$groups = PHPUnit_Util_Test::getGroups( static::class );
$constraint = PHPUnit_Framework_Assert::logicalOr(
* @group Database
* @group medium
* @group Broken
+ *
+ * @covers ApiUpload
*/
class ApiUploadTest extends ApiTestCaseUpload {
/**
<?php
+/**
+ * @covers ApiUsageException
+ */
class ApiUsageExceptionTest extends MediaWikiTestCase {
public function testCreateWithStatusValue_CanGetAMessageObject() {
* @group Database
* @group medium
* @todo This test suite is severly broken and need a full review
+ *
+ * @covers ApiWatch
*/
class ApiWatchTest extends ApiTestCase {
protected function setUp() {
);
}
+ /**
+ * @coversNothing
+ */
public function testEntireSchema() {
global $IP;
/**
* Runs upgrades of older databases and compares results with current schema
* @todo Currently only checks list of tables
+ * @coversNothing
*/
public function testUpgrades() {
global $IP, $wgVersion, $wgProfiler;
$this->assertTrue( $db->close(), "closing database" );
}
+ /**
+ * @covers \Wikimedia\Rdbms\DatabaseSqlite::__toString
+ */
public function testToString() {
$db = DatabaseSqlite::newStandaloneInstance( ':memory:' );
<?php
-
-use Wikimedia\Rdbms\LBFactorySimple;
-use Wikimedia\Rdbms\LBFactoryMulti;
-use Wikimedia\Rdbms\ChronologyProtector;
-use Wikimedia\Rdbms\MySQLMasterPos;
-
/**
* Holds tests for LBFactory abstract MediaWiki class.
*
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
- * @group Database
* @file
* @author Antoine Musso
* @copyright © 2013 Antoine Musso
* @copyright © 2013 Wikimedia Foundation Inc.
*/
+
+use Wikimedia\Rdbms\LBFactorySimple;
+use Wikimedia\Rdbms\LBFactoryMulti;
+use Wikimedia\Rdbms\ChronologyProtector;
+use Wikimedia\Rdbms\MySQLMasterPos;
+
+/**
+ * @group Database
+ * @covers \Wikimedia\Rdbms\LBFactorySimple
+ * @covers \Wikimedia\Rdbms\LBFactoryMulti
+ */
class LBFactoryTest extends MediaWikiTestCase {
/**
+ * @covers MWLBFactory::getLBFactoryClass
* @dataProvider getLBFactoryClassProvider
*/
public function testGetLBFactoryClass( $expected, $deprecated ) {
$lb->closeAll();
}
+ /**
+ * @covers \Wikimedia\Rdbms\ChronologyProtector
+ */
public function testChronologyProtector() {
// (a) First HTTP request
$mPos = new MySQLMasterPos( 'db1034-bin.000976', '843431247' );
*
* @group Database
* @file
+ *
+ * @covers \Wikimedia\Rdbms\LoadBalancer
*/
class LoadBalancerTest extends MediaWikiTestCase {
public function testWithoutReplica() {
/**
* @expectedException MWException
+ * @covers MWException
*/
public function testMwexceptionThrowing() {
throw new MWException();
/**
* @covers HTMLForm
+ *
+ * @licence GNU GPL v2+
+ * @author Gergő Tisza
+ * @author Thiemo Mättig
*/
class HTMLFormTest extends MediaWikiTestCase {
- public function testGetHTML_empty() {
+
+ private function newInstance() {
$form = new HTMLForm( [] );
$form->setTitle( Title::newFromText( 'Foo' ) );
+ return $form;
+ }
+
+ public function testGetHTML_empty() {
+ $form = $this->newInstance();
$form->prepareForm();
$html = $form->getHTML( false );
- $this->assertRegExp( '/<form\b/', $html );
+ $this->assertStringStartsWith( '<form ', $html );
}
/**
* @expectedException LogicException
*/
public function testGetHTML_noPrepare() {
- $form = new HTMLForm( [] );
- $form->setTitle( Title::newFromText( 'Foo' ) );
+ $form = $this->newInstance();
$form->getHTML( false );
}
+
+ public function testAutocompleteDefaultsToNull() {
+ $form = $this->newInstance();
+ $this->assertNotContains( 'autocomplete', $form->wrapForm( '' ) );
+ }
+
+ public function testAutocompleteWhenSetToNull() {
+ $form = $this->newInstance();
+ $form->setAutocomplete( null );
+ $this->assertNotContains( 'autocomplete', $form->wrapForm( '' ) );
+ }
+
+ public function testAutocompleteWhenSetToFalse() {
+ $form = $this->newInstance();
+ // Previously false was used instead of null to indicate the attribute should not be set
+ $form->setAutocomplete( false );
+ $this->assertNotContains( 'autocomplete', $form->wrapForm( '' ) );
+ }
+
+ public function testAutocompleteWhenSetToOff() {
+ $form = $this->newInstance();
+ $form->setAutocomplete( 'off' );
+ $this->assertContains( ' autocomplete="off"', $form->wrapForm( '' ) );
+ }
+
}
* where it did not define a cURL constant. T72570
*
* @dataProvider provideCurlConstants
+ * @coversNothing
*/
public function testCurlConstants( $value ) {
$this->checkPHPExtension( 'curl' );
*/
class HtmlArmorTest extends PHPUnit_Framework_TestCase {
- public static function provideHtmlArmor() {
+ public static function provideConstructor() {
+ return [
+ [ 'test' ],
+ [ null ],
+ [ '<em>some html!</em>' ]
+ ];
+ }
+
+ /**
+ * @dataProvider provideConstructor
+ */
+ public function testConstructor( $value ) {
+ $this->assertInstanceOf( HtmlArmor::class, new HtmlArmor( $value ) );
+ }
+
+ public static function provideGetHtml() {
return [
[
'foobar',
new HtmlArmor( '<script>alert("evil!");</script>' ),
'<script>alert("evil!");</script>',
],
+ [
+ new HtmlArmor( null ),
+ null,
+ ]
];
}
/**
- * @dataProvider provideHtmlArmor
+ * @dataProvider provideGetHtml
*/
- public function testHtmlArmor( $input, $expected ) {
+ public function testGetHtml( $input, $expected ) {
$this->assertEquals(
$expected,
HtmlArmor::getHtml( $input )
* @group Media
* @group medium
*
- * @todo covers tags
+ * @covers BitmapHandler
*/
class ExifRotationTest extends MediaWikiMediaTestCase {
+ /** @var BitmapHandler */
+ private $handler;
+
protected function setUp() {
parent::setUp();
$this->checkPHPExtension( 'exif' );
* @author Antoine Musso
* @copyright Copyright © 2011, Antoine Musso
* @file
- * @todo covers tags
*
* @group Database
*/
+/**
+ * @covers Parser::getVariableValue
+ */
class MagicVariableTest extends MediaWikiTestCase {
/**
* @var Parser
$this->assertSame( [ 'ext.baz.fizzbuzz' ], $info['attributes']['FizzBuzzMorePlugins'] );
}
+ /**
+ * Verify that extension.schema.json is in sync with ExtensionProcessor
+ *
+ * @coversNothing
+ */
public function testGlobalSettingsDocumentedInSchema() {
global $IP;
$globalSettings = TestingAccessWrapper::newFromClass(
* Test, if for all rights a right- message exist,
* which is used on Special:ListGroupRights as help text
* Extensions and core
+ *
+ * @coversNothing
*/
public function testAllRightsWithMessage() {
// Getting all user rights, for core: User::$mCoreRights, for extensions: $wgAvailableRights
/**
* Test exhausting pcre.backtrack_limit
+ *
+ * @covers LanguageConverter::autoConvert
*/
public function testAutoConvertT124404() {
$testString = '';
}
/**
- * @dataProvider testFormatNumProvider
+ * @dataProvider provideFormatNum
* @covers Language::formatNum
*/
public function testFormatNum(
$this->assertEquals( $expected, $formattedNum );
}
- public function testFormatNumProvider() {
+ public function provideFormatNum() {
return [
[ true, 'en', 100, false, '100' ],
[ true, 'en', 101, true, '101' ],
}
/**
+ * @covers Language::parseFormattedNumber
* @dataProvider parseFormattedNumberProvider
*/
public function testParseFormattedNumber( $langCode, $number ) {
];
}
+ /**
+ * @covers Language::equals
+ */
public function testEquals() {
$en1 = new Language();
$en1->setCode( 'en' );
* @file
*/
-/** Tests for MediaWiki languages/LanguageAr.php */
+/**
+ * @covers LanguageAr
+ */
class LanguageArTest extends LanguageClassesTestCase {
/**
* @covers Language::formatNum
<?php
// @codingStandardsIgnoreStart Ignore Squiz.Classes.ValidClassName.NotCamelCaps
+/**
+ * @covers LanguageBe_tarask
+ */
class LanguageBe_taraskTest extends LanguageClassesTestCase {
// @codingStandardsIgnoreEnd
/**
* @file
*/
-/** Tests for Croatian (hrvatski) */
+/**
+ * Tests for Croatian (hrvatski)
+ *
+ * @covers LanguageBs
+ */
class LanguageBsTest extends LanguageClassesTestCase {
/**
* @dataProvider providePlural
<?php
+/**
+ * @covers LanguageCrh
+ * @covers CrhConverter
+ */
class LanguageCrhTest extends LanguageClassesTestCase {
/**
* @dataProvider provideAutoConvertToAllVariants
* @file
*/
-/** Tests for MediaWiki languages/LanguageCu.php */
+/**
+ * @covers LanguageCu
+ */
class LanguageCuTest extends LanguageClassesTestCase {
/**
* @dataProvider providePlural
* @file
*/
-/** Tests for MediaWiki languages/classes/LanguageDsb.php */
+/**
+ * @covers LanguageDsb
+ */
class LanguageDsbTest extends LanguageClassesTestCase {
/**
* @dataProvider providePlural
<?php
+/**
+ * @covers LanguageGan
+ * @covers GanConverter
+ */
class LanguageGanTest extends LanguageClassesTestCase {
/**
* @dataProvider provideAutoConvertToAllVariants
* @file
*/
-/** Tests for MediaWiki languages/classes/LanguageHsb.php */
+/**
+ * @covers LanguageHsb
+ */
class LanguageHsbTest extends LanguageClassesTestCase {
/**
* @dataProvider providePlural
* @file
*/
-/** Tests for MediaWiki languages/LanguageHu.php */
+/**
+ * @covers LanguageHu
+ */
class LanguageHuTest extends LanguageClassesTestCase {
/**
* @dataProvider providePlural
* @file
*/
-/** Tests for Armenian (Հայերեն) */
+/**
+ * Tests for Armenian (Հայերեն)
+ *
+ * @covers LanguageHy
+ */
class LanguageHyTest extends LanguageClassesTestCase {
/**
* @dataProvider providePlural
<?php
+/**
+ * @covers LanguageIu
+ * @covers IuConverter
+ */
class LanguageIuTest extends LanguageClassesTestCase {
/**
* @dataProvider provideAutoConvertToAllVariants
<?php
+/**
+ * @covers LanguageKk
+ * @covers LanguageKk_cyrl
+ * @covers KkConverter
+ */
class LanguageKkTest extends LanguageClassesTestCase {
/**
* @dataProvider provideAutoConvertToAllVariants
* @file
*/
-/** Tests for MediaWiki languages/classes/LanguageKsh.php */
+/**
+ * @covers LanguageKsh
+ */
class LanguageKshTest extends LanguageClassesTestCase {
/**
* @dataProvider providePlural
<?php
+/**
+ * @covers LanguageKu
+ * @covers KuConverter
+ */
class LanguageKuTest extends LanguageClassesTestCase {
/**
* @dataProvider provideAutoConvertToAllVariants
* @file
*/
-/** Tests for MediaWiki languages/LanguageMl.php */
+/**
+ * @covers LanguageMl
+ */
class LanguageMlTest extends LanguageClassesTestCase {
/**
* @file
*/
-/** Tests for MediaWiki languages/classes/LanguageRu.php */
+/**
+ * @covers LanguageRu
+ */
class LanguageRuTest extends LanguageClassesTestCase {
/**
* @dataProvider providePlural
<?php
+/**
+ * @covers LanguageShi
+ * @covers ShiConverter
+ */
class LanguageShiTest extends LanguageClassesTestCase {
/**
* @dataProvider provideAutoConvertToAllVariants
* @file
*/
-/** Tests for MediaWiki languages/classes/LanguageSl.php */
+/**
+ * @covers LanguageSl
+ */
class LanguageSlTest extends LanguageClassesTestCase {
/**
* @dataProvider providerPlural
* - Tests for LanguageConverter and Language should probably be separate..
*/
-/** Tests for MediaWiki languages/LanguageSr.php */
+/**
+ * @covers LanguageSr
+ * @covers SrConverter
+ */
class LanguageSrTest extends LanguageClassesTestCase {
/**
* @covers LanguageConverter::convertTo
<?php
+/**
+ * @covers LanguageTg
+ * @covers TgConverter
+ */
class LanguageTgTest extends LanguageClassesTestCase {
/**
* @dataProvider provideAutoConvertToAllVariants
* @file
*/
-/** Tests for MediaWiki languages/LanguageTr.php */
+/**
+ * @covers LanguageTr
+ */
class LanguageTrTest extends LanguageClassesTestCase {
/**
* @file
*/
-/** Tests for Ukrainian */
+/**
+ * @covers LanguageUk
+ */
class LanguageUkTest extends LanguageClassesTestCase {
/**
* @dataProvider providePlural
* - Tests for LanguageConverter and Language should probably be separate..
*/
-/** Tests for MediaWiki languages/LanguageUz.php */
+/**
+ * @covers LanguageUz
+ * @covers UzConverter
+ */
class LanguageUzTest extends LanguageClassesTestCase {
/**
* @file
*/
-/** Tests for MediaWiki languages/classes/LanguageWa.php */
+/**
+ * @covers LanguageWa
+ */
class LanguageWaTest extends LanguageClassesTestCase {
/**
* @dataProvider providePlural
<?php
+/**
+ * @covers LanguageZh
+ * @covers LanguageZh_hans
+ * @covers ZhConverter
+ */
class LanguageZhTest extends LanguageClassesTestCase {
/**
* @dataProvider provideAutoConvertToAllVariants
/**
* Test $wgNoFollowLinks in sidebar
+ * @covers Skin::addToSidebarPlain
*/
public function testRespectWgnofollowlinks() {
$this->setMwGlobals( 'wgNoFollowLinks', false );
/**
* Test $wgExternaLinkTarget in sidebar
* @dataProvider dataRespectExternallinktarget
+ * @covers Skin::addToSidebarPlain
*/
public function testRespectExternallinktarget( $externalLinkTarget ) {
$this->setMwGlobals( 'wgExternalLinkTarget', $externalLinkTarget );