Revert "Separate MediaWiki unit and integration tests"
This reverts commit 0a2b996278.
Reason for revert: Broke postgres tests.
Change-Id: I27d8e0c807ad5f0748b9611a4f3df84cc213fbe1
This commit is contained in:
parent
0a2b996278
commit
4e35134f7a
219 changed files with 242 additions and 551 deletions
|
|
@ -179,7 +179,6 @@
|
|||
<exclude-pattern>*/maintenance/storage/trackBlobs\.php</exclude-pattern>
|
||||
<!-- Skip violations in some tests for now -->
|
||||
<exclude-pattern>*/tests/phpunit/includes/GlobalFunctions/*\.php</exclude-pattern>
|
||||
<exclude-pattern>*/tests/phpunit/unit/includes/GlobalFunctions/*\.php</exclude-pattern>
|
||||
<exclude-pattern>*/tests/phpunit/maintenance/*\.php</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,6 @@ class TestSetup {
|
|||
global $wgSessionProviders, $wgSessionPbkdf2Iterations;
|
||||
global $wgJobTypeConf;
|
||||
global $wgAuthManagerConfig;
|
||||
global $wgSecretKey;
|
||||
|
||||
$wgSecretKey = 'secretsecretsecretsecretsecretsecretsecretsecretsecretsecretsecretsecretsecret';
|
||||
|
||||
// wfWarn should cause tests to fail
|
||||
$wgDevelopmentWarnings = true;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ $wgAutoloadClasses += [
|
|||
'MediaWikiPHPUnitResultPrinter' => "$testDir/phpunit/MediaWikiPHPUnitResultPrinter.php",
|
||||
'MediaWikiPHPUnitTestListener' => "$testDir/phpunit/MediaWikiPHPUnitTestListener.php",
|
||||
'MediaWikiTestCase' => "$testDir/phpunit/MediaWikiTestCase.php",
|
||||
'MediaWikiUnitTestCase' => "$testDir/phpunit/MediaWikiUnitTestCase.php",
|
||||
'MediaWikiTestResult' => "$testDir/phpunit/MediaWikiTestResult.php",
|
||||
'MediaWikiTestRunner' => "$testDir/phpunit/MediaWikiTestRunner.php",
|
||||
'PHPUnit4And6Compat' => "$testDir/phpunit/PHPUnit4And6Compat.php",
|
||||
|
|
@ -178,7 +177,7 @@ $wgAutoloadClasses += [
|
|||
'LanguageClassesTestCase' => "$testDir/phpunit/languages/LanguageClassesTestCase.php",
|
||||
|
||||
# tests/phpunit/includes/libs
|
||||
'GenericArrayObjectTest' => "$testDir/phpunit/unit/includes/libs/GenericArrayObjectTest.php",
|
||||
'GenericArrayObjectTest' => "$testDir/phpunit/includes/libs/GenericArrayObjectTest.php",
|
||||
|
||||
# tests/phpunit/maintenance
|
||||
'MediaWiki\Tests\Maintenance\DumpAsserter' => "$testDir/phpunit/maintenance/DumpAsserter.php",
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class MediaWikiUnitTestCase extends TestCase {
|
||||
use MediaWikiCoversValidator;
|
||||
use PHPUnit4And6Compat;
|
||||
|
||||
/** @var MediaWikiServices $mwServicesBackup */
|
||||
private $mwServicesBackup;
|
||||
|
||||
/**
|
||||
* Replace global MediaWiki service locator with a clone that has the given overrides applied
|
||||
* @param callable[] $overrides map of service names to instantiators
|
||||
* @throws MWException
|
||||
*/
|
||||
protected function overrideMwServices( array $overrides ) {
|
||||
$services = clone MediaWikiServices::getInstance();
|
||||
|
||||
foreach ( $overrides as $serviceName => $factory ) {
|
||||
$services->disableService( $serviceName );
|
||||
$services->redefineService( $serviceName, $factory );
|
||||
}
|
||||
|
||||
$this->mwServicesBackup = MediaWikiServices::forceGlobalInstance( $services );
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
if ( $this->mwServicesBackup ) {
|
||||
MediaWikiServices::forceGlobalInstance( $this->mwServicesBackup );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* James doesn't like having to manually fix these things.
|
||||
*/
|
||||
class ReleaseNotesTest extends \MediaWikiUnitTestCase {
|
||||
class ReleaseNotesTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* Verify that at least one Release Notes file exists, have content, and
|
||||
* aren't overly long.
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
* @file
|
||||
*/
|
||||
|
||||
class FauxResponseTest extends \MediaWikiUnitTestCase {
|
||||
class FauxResponseTest extends MediaWikiTestCase {
|
||||
/** @var FauxResponse */
|
||||
protected $response;
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ use Wikimedia\TestingAccessWrapper;
|
|||
*
|
||||
* @author Antoine Musso
|
||||
*/
|
||||
class FormOptionsInitializationTest extends \MediaWikiUnitTestCase {
|
||||
class FormOptionsInitializationTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* @var FormOptions
|
||||
*/
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* @author Antoine Musso
|
||||
*/
|
||||
class FormOptionsTest extends \MediaWikiUnitTestCase {
|
||||
class FormOptionsTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* @var FormOptions
|
||||
*/
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* @group GlobalFunctions
|
||||
* @covers ::wfAppendQuery
|
||||
*/
|
||||
class WfAppendQueryTest extends \MediaWikiUnitTestCase {
|
||||
class WfAppendQueryTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* @dataProvider provideAppendQuery
|
||||
*/
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* @group GlobalFunctions
|
||||
* @covers ::wfArrayPlus2d
|
||||
*/
|
||||
class WfArrayPlus2dTest extends \MediaWikiUnitTestCase {
|
||||
class WfArrayPlus2dTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* @dataProvider provideArrays
|
||||
*/
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* @group GlobalFunctions
|
||||
* @covers ::wfAssembleUrl
|
||||
*/
|
||||
class WfAssembleUrlTest extends \MediaWikiUnitTestCase {
|
||||
class WfAssembleUrlTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* @dataProvider provideURLParts
|
||||
*/
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* @group GlobalFunctions
|
||||
* @covers ::wfBaseName
|
||||
*/
|
||||
class WfBaseNameTest extends \MediaWikiUnitTestCase {
|
||||
class WfBaseNameTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* @dataProvider providePaths
|
||||
*/
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* @group GlobalFunctions
|
||||
* @covers ::wfEscapeShellArg
|
||||
*/
|
||||
class WfEscapeShellArgTest extends \MediaWikiUnitTestCase {
|
||||
class WfEscapeShellArgTest extends MediaWikiTestCase {
|
||||
public function testSingleInput() {
|
||||
if ( wfIsWindows() ) {
|
||||
$expected = '"blah"';
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* @group GlobalFunctions
|
||||
* @covers ::wfGetCaller
|
||||
*/
|
||||
class WfGetCallerTest extends \MediaWikiUnitTestCase {
|
||||
class WfGetCallerTest extends MediaWikiTestCase {
|
||||
public function testZero() {
|
||||
$this->assertEquals( 'WfGetCallerTest->testZero', wfGetCaller( 1 ) );
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* @group GlobalFunctions
|
||||
* @covers ::wfRemoveDotSegments
|
||||
*/
|
||||
class WfRemoveDotSegmentsTest extends \MediaWikiUnitTestCase {
|
||||
class WfRemoveDotSegmentsTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* @dataProvider providePaths
|
||||
*/
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* @group GlobalFunctions
|
||||
* @covers ::wfShellExec
|
||||
*/
|
||||
class WfShellExecTest extends \MediaWikiUnitTestCase {
|
||||
class WfShellExecTest extends MediaWikiTestCase {
|
||||
public function testT69870() {
|
||||
$command = wfIsWindows()
|
||||
// 333 = 331 + CRLF
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* @group GlobalFunctions
|
||||
* @covers ::wfShorthandToInteger
|
||||
*/
|
||||
class WfShorthandToIntegerTest extends \MediaWikiUnitTestCase {
|
||||
class WfShorthandToIntegerTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* @dataProvider provideABunchOfShorthands
|
||||
*/
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* @group GlobalFunctions
|
||||
* @covers ::wfStringToBool
|
||||
*/
|
||||
class WfStringToBoolTest extends \MediaWikiUnitTestCase {
|
||||
class WfStringToBoolTest extends MediaWikiTestCase {
|
||||
|
||||
public function getTestCases() {
|
||||
return [
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* @group GlobalFunctions
|
||||
* @covers ::wfTimestamp
|
||||
*/
|
||||
class WfTimestampTest extends \MediaWikiUnitTestCase {
|
||||
class WfTimestampTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* @dataProvider provideNormalTimestamps
|
||||
*/
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
* @group GlobalFunctions
|
||||
* @covers ::wfUrlencode
|
||||
*/
|
||||
class WfUrlencodeTest extends \MediaWikiUnitTestCase {
|
||||
class WfUrlencodeTest extends MediaWikiTestCase {
|
||||
# ### TESTS ##############################################################
|
||||
|
||||
/**
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class HooksTest extends \MediaWikiUnitTestCase {
|
||||
class HooksTest extends MediaWikiTestCase {
|
||||
|
||||
function setUp() {
|
||||
global $wgHooks;
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* @covers Licenses
|
||||
*/
|
||||
class LicensesTest extends \MediaWikiUnitTestCase {
|
||||
class LicensesTest extends MediaWikiTestCase {
|
||||
|
||||
public function testLicenses() {
|
||||
$str = "
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* @covers ListToggle
|
||||
*/
|
||||
class ListToggleTest extends \MediaWikiUnitTestCase {
|
||||
class ListToggleTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @covers ListToggle::__construct
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* @author Derick N. Alangi
|
||||
*/
|
||||
class MagicWordFactoryTest extends \MediaWikiUnitTestCase {
|
||||
class MagicWordFactoryTest extends MediaWikiTestCase {
|
||||
private function makeMagicWordFactory( Language $contLang = null ) {
|
||||
return new MagicWordFactory( $contLang ?: Language::factory( 'en' ) );
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ use Wikimedia\Services\ServiceDisabledException;
|
|||
*
|
||||
* @group MediaWiki
|
||||
*/
|
||||
class MediaWikiServicesTest extends \MediaWikiUnitTestCase {
|
||||
class MediaWikiServicesTest extends MediaWikiTestCase {
|
||||
private $deprecatedServices = [];
|
||||
|
||||
/**
|
||||
|
|
@ -292,8 +292,8 @@ class MediaWikiServicesTest extends \MediaWikiUnitTestCase {
|
|||
$this->hideDeprecated( MediaWikiServices::class . "::$getter" );
|
||||
}
|
||||
|
||||
// Check all services via an instance using the global configuration, not a dummy instance!
|
||||
$services = $this->newMediaWikiServices( new GlobalVarConfig() );
|
||||
// Test against the default instance, since the dummy will not know the default services.
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$service = $services->$getter();
|
||||
$this->assertInstanceOf( $type, $service );
|
||||
}
|
||||
|
|
@ -317,18 +317,18 @@ class MediaWikiServicesTest extends \MediaWikiUnitTestCase {
|
|||
* @dataProvider provideGetService
|
||||
*/
|
||||
public function testGetService( $name, $type ) {
|
||||
// Check all services via an instance using the global configuration, not a dummy instance!
|
||||
$services = $this->newMediaWikiServices( new GlobalVarConfig() );
|
||||
// Test against the default instance, since the dummy will not know the default services.
|
||||
$services = MediaWikiServices::getInstance();
|
||||
|
||||
$service = $services->getService( $name );
|
||||
$this->assertInstanceOf( $type, $service );
|
||||
}
|
||||
|
||||
public function testDefaultServiceInstantiation() {
|
||||
// Check all services via an instance using the global configuration, not a dummy instance!
|
||||
// Check all services in the default instance, not a dummy instance!
|
||||
// Note that we instantiate all services here, including any that
|
||||
// were registered by extensions.
|
||||
$services = $this->newMediaWikiServices( new GlobalVarConfig() );
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$names = $services->getServiceNames();
|
||||
|
||||
foreach ( $names as $name ) {
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
|
||||
*/
|
||||
class MediaWikiVersionFetcherTest extends \MediaWikiUnitTestCase {
|
||||
class MediaWikiVersionFetcherTest extends MediaWikiTestCase {
|
||||
|
||||
public function testReturnsResult() {
|
||||
global $wgVersion;
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* @covers PathRouter
|
||||
*/
|
||||
class PathRouterTest extends \MediaWikiUnitTestCase {
|
||||
class PathRouterTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @var PathRouter
|
||||
|
|
@ -3,12 +3,13 @@
|
|||
namespace MediaWiki\Tests\Revision;
|
||||
|
||||
use MediaWiki\Revision\FallbackSlotRoleHandler;
|
||||
use MediaWikiTestCase;
|
||||
use Title;
|
||||
|
||||
/**
|
||||
* @covers \MediaWiki\Revision\FallbackSlotRoleHandler
|
||||
*/
|
||||
class FallbackSlotRoleHandlerTest extends \MediaWikiUnitTestCase {
|
||||
class FallbackSlotRoleHandlerTest extends MediaWikiTestCase {
|
||||
|
||||
private function makeBlankTitleObject() {
|
||||
/** @var Title $title */
|
||||
|
|
@ -3,13 +3,14 @@
|
|||
namespace MediaWiki\Tests\Revision;
|
||||
|
||||
use MediaWiki\Revision\MainSlotRoleHandler;
|
||||
use MediaWikiTestCase;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Title;
|
||||
|
||||
/**
|
||||
* @covers \MediaWiki\Revision\MainSlotRoleHandler
|
||||
*/
|
||||
class MainSlotRoleHandlerTest extends \MediaWikiUnitTestCase {
|
||||
class MainSlotRoleHandlerTest extends MediaWikiTestCase {
|
||||
|
||||
private function makeTitleObject( $ns ) {
|
||||
/** @var Title|MockObject $title */
|
||||
|
|
@ -13,6 +13,7 @@ use MediaWiki\Storage\BlobStoreFactory;
|
|||
use MediaWiki\Storage\NameTableStore;
|
||||
use MediaWiki\Storage\NameTableStoreFactory;
|
||||
use MediaWiki\Storage\SqlBlobStore;
|
||||
use MediaWikiTestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\NullLogger;
|
||||
use WANObjectCache;
|
||||
|
|
@ -20,7 +21,7 @@ use Wikimedia\Rdbms\ILBFactory;
|
|||
use Wikimedia\Rdbms\ILoadBalancer;
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
class RevisionStoreFactoryTest extends \MediaWikiUnitTestCase {
|
||||
class RevisionStoreFactoryTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @covers \MediaWiki\Revision\RevisionStoreFactory::__construct
|
||||
|
|
@ -7,12 +7,13 @@ use LogicException;
|
|||
use MediaWiki\Revision\IncompleteRevisionException;
|
||||
use MediaWiki\Revision\SlotRecord;
|
||||
use MediaWiki\Revision\SuppressedDataException;
|
||||
use MediaWikiTestCase;
|
||||
use WikitextContent;
|
||||
|
||||
/**
|
||||
* @covers \MediaWiki\Revision\SlotRecord
|
||||
*/
|
||||
class SlotRecordTest extends \MediaWikiUnitTestCase {
|
||||
class SlotRecordTest extends MediaWikiTestCase {
|
||||
|
||||
private function makeRow( $data = [] ) {
|
||||
$data = $data + [
|
||||
|
|
@ -3,12 +3,13 @@
|
|||
namespace MediaWiki\Tests\Revision;
|
||||
|
||||
use MediaWiki\Revision\SlotRoleHandler;
|
||||
use MediaWikiTestCase;
|
||||
use Title;
|
||||
|
||||
/**
|
||||
* @covers \MediaWiki\Revision\SlotRoleHandler
|
||||
*/
|
||||
class SlotRoleHandlerTest extends \MediaWikiUnitTestCase {
|
||||
class SlotRoleHandlerTest extends MediaWikiTestCase {
|
||||
|
||||
private function makeBlankTitleObject() {
|
||||
/** @var Title $title */
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* @coversNothing
|
||||
*/
|
||||
class ServiceWiringTest extends \MediaWikiUnitTestCase {
|
||||
class ServiceWiringTest extends MediaWikiTestCase {
|
||||
public function testServicesAreSorted() {
|
||||
global $IP;
|
||||
$services = array_keys( require "$IP/includes/ServiceWiring.php" );
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class SiteConfigurationTest extends \MediaWikiUnitTestCase {
|
||||
class SiteConfigurationTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @var SiteConfiguration
|
||||
|
|
@ -5,28 +5,13 @@ namespace MediaWiki\Tests\Storage;
|
|||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Storage\BlobStore;
|
||||
use MediaWiki\Storage\SqlBlobStore;
|
||||
use Wikimedia\Rdbms\LBFactory;
|
||||
use MediaWikiTestCase;
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
/**
|
||||
* @covers \MediaWiki\Storage\BlobStoreFactory
|
||||
*/
|
||||
class BlobStoreFactoryTest extends \MediaWikiUnitTestCase {
|
||||
|
||||
/** @var LBFactory|\PHPUnit_Framework_MockObject_MockObject $lbFactoryMock */
|
||||
private $lbFactoryMock;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->lbFactoryMock = $this->createMock( LBFactory::class );
|
||||
|
||||
$lbFactoryMockProvider = function (): LBFactory {
|
||||
return $this->lbFactoryMock;
|
||||
};
|
||||
|
||||
$this->overrideMwServices( [ 'DBLoadBalancerFactory' => $lbFactoryMockProvider ] );
|
||||
}
|
||||
class BlobStoreFactoryTest extends MediaWikiTestCase {
|
||||
|
||||
public function provideWikiIds() {
|
||||
yield [ false ];
|
||||
|
|
@ -37,11 +22,6 @@ class BlobStoreFactoryTest extends \MediaWikiUnitTestCase {
|
|||
* @dataProvider provideWikiIds
|
||||
*/
|
||||
public function testNewBlobStore( $wikiId ) {
|
||||
$this->lbFactoryMock->expects( $this->any() )
|
||||
->method( 'getMainLB' )
|
||||
->with( $wikiId )
|
||||
->willReturn( $this->createMock( \LoadBalancer::class ) );
|
||||
|
||||
$factory = MediaWikiServices::getInstance()->getBlobStoreFactory();
|
||||
$store = $factory->newBlobStore( $wikiId );
|
||||
$this->assertInstanceOf( BlobStore::class, $store );
|
||||
|
|
@ -55,11 +35,6 @@ class BlobStoreFactoryTest extends \MediaWikiUnitTestCase {
|
|||
* @dataProvider provideWikiIds
|
||||
*/
|
||||
public function testNewSqlBlobStore( $wikiId ) {
|
||||
$this->lbFactoryMock->expects( $this->any() )
|
||||
->method( 'getMainLB' )
|
||||
->with( $wikiId )
|
||||
->willReturn( $this->createMock( \LoadBalancer::class ) );
|
||||
|
||||
$factory = MediaWikiServices::getInstance()->getBlobStoreFactory();
|
||||
$store = $factory->newSqlBlobStore( $wikiId );
|
||||
$this->assertInstanceOf( SqlBlobStore::class, $store );
|
||||
|
|
@ -67,4 +42,5 @@ class BlobStoreFactoryTest extends \MediaWikiUnitTestCase {
|
|||
$wrapper = TestingAccessWrapper::newFromObject( $store );
|
||||
$this->assertEquals( $wikiId, $wrapper->wikiId );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,11 +3,12 @@
|
|||
namespace MediaWiki\Edit;
|
||||
|
||||
use ParserOutput;
|
||||
use MediaWikiTestCase;
|
||||
|
||||
/**
|
||||
* @covers \MediaWiki\Edit\PreparedEdit
|
||||
*/
|
||||
class PreparedEditTest extends \MediaWikiUnitTestCase {
|
||||
class PreparedEditTest extends MediaWikiTestCase {
|
||||
function testCallback() {
|
||||
$output = new ParserOutput();
|
||||
$edit = new PreparedEdit();
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* @group Xml
|
||||
*/
|
||||
class XmlSelectTest extends \MediaWikiUnitTestCase {
|
||||
class XmlSelectTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @var XmlSelect
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* @author Derick N. Alangi
|
||||
*/
|
||||
class ViewActionTest extends \MediaWikiUnitTestCase {
|
||||
class ViewActionTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* @return ViewAction
|
||||
*/
|
||||
43
tests/phpunit/includes/api/ApiBlockInfoTraitTest.php
Normal file
43
tests/phpunit/includes/api/ApiBlockInfoTraitTest.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
use MediaWiki\Block\DatabaseBlock;
|
||||
use MediaWiki\Block\SystemBlock;
|
||||
|
||||
/**
|
||||
* @covers ApiBlockInfoTrait
|
||||
*/
|
||||
class ApiBlockInfoTraitTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* @dataProvider provideGetBlockDetails
|
||||
*/
|
||||
public function testGetBlockDetails( $block, $expectedInfo ) {
|
||||
$mock = $this->getMockForTrait( ApiBlockInfoTrait::class );
|
||||
$info = TestingAccessWrapper::newFromObject( $mock )->getBlockDetails( $block );
|
||||
$subset = array_merge( [
|
||||
'blockid' => null,
|
||||
'blockedby' => '',
|
||||
'blockedbyid' => 0,
|
||||
'blockreason' => '',
|
||||
'blockexpiry' => 'infinite',
|
||||
], $expectedInfo );
|
||||
$this->assertArraySubset( $subset, $info );
|
||||
}
|
||||
|
||||
public static function provideGetBlockDetails() {
|
||||
return [
|
||||
'Sitewide block' => [
|
||||
new DatabaseBlock(),
|
||||
[ 'blockpartial' => false ],
|
||||
],
|
||||
'Partial block' => [
|
||||
new DatabaseBlock( [ 'sitewide' => false ] ),
|
||||
[ 'blockpartial' => true ],
|
||||
],
|
||||
'System block' => [
|
||||
new SystemBlock( [ 'systemBlock' => 'proxy' ] ),
|
||||
[ 'systemblocktype' => 'proxy' ]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* @covers ApiContinuationManager
|
||||
* @group API
|
||||
*/
|
||||
class ApiContinuationManagerTest extends \MediaWikiUnitTestCase {
|
||||
class ApiContinuationManagerTest extends MediaWikiTestCase {
|
||||
|
||||
private static function getManager( $continue, $allModules, $generatedModules ) {
|
||||
$context = new DerivativeContext( RequestContext::getMain() );
|
||||
|
|
@ -5,7 +5,7 @@ use Wikimedia\TestingAccessWrapper;
|
|||
/**
|
||||
* @group API
|
||||
*/
|
||||
class ApiMessageTest extends \MediaWikiUnitTestCase {
|
||||
class ApiMessageTest extends MediaWikiTestCase {
|
||||
|
||||
private function compareMessages( Message $msg, Message $msg2 ) {
|
||||
$this->assertSame( $msg->getKey(), $msg2->getKey(), 'getKey' );
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* @covers ApiResult
|
||||
* @group API
|
||||
*/
|
||||
class ApiResultTest extends \MediaWikiUnitTestCase {
|
||||
class ApiResultTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @covers ApiResult
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* @covers ApiUsageException
|
||||
*/
|
||||
class ApiUsageExceptionTest extends \MediaWikiUnitTestCase {
|
||||
class ApiUsageExceptionTest extends MediaWikiTestCase {
|
||||
|
||||
public function testCreateWithStatusValue_CanGetAMessageObject() {
|
||||
$messageKey = 'some-message-key';
|
||||
|
|
@ -6,7 +6,7 @@ namespace MediaWiki\Auth;
|
|||
* @group AuthManager
|
||||
* @covers \MediaWiki\Auth\AbstractPreAuthenticationProvider
|
||||
*/
|
||||
class AbstractPreAuthenticationProviderTest extends \MediaWikiUnitTestCase {
|
||||
class AbstractPreAuthenticationProviderTest extends \MediaWikiTestCase {
|
||||
public function testAbstractPreAuthenticationProvider() {
|
||||
$user = \User::newFromName( 'UTSysop' );
|
||||
|
||||
|
|
@ -6,7 +6,7 @@ namespace MediaWiki\Auth;
|
|||
* @group AuthManager
|
||||
* @covers \MediaWiki\Auth\AbstractSecondaryAuthenticationProvider
|
||||
*/
|
||||
class AbstractSecondaryAuthenticationProviderTest extends \MediaWikiUnitTestCase {
|
||||
class AbstractSecondaryAuthenticationProviderTest extends \MediaWikiTestCase {
|
||||
public function testAbstractSecondaryAuthenticationProvider() {
|
||||
$user = \User::newFromName( 'UTSysop' );
|
||||
|
||||
|
|
@ -6,7 +6,7 @@ namespace MediaWiki\Auth;
|
|||
* @group AuthManager
|
||||
* @covers \MediaWiki\Auth\AuthenticationResponse
|
||||
*/
|
||||
class AuthenticationResponseTest extends \MediaWikiUnitTestCase {
|
||||
class AuthenticationResponseTest extends \MediaWikiTestCase {
|
||||
/**
|
||||
* @dataProvider provideConstructors
|
||||
* @param string $constructor
|
||||
|
|
@ -8,7 +8,7 @@ use Wikimedia\TestingAccessWrapper;
|
|||
* @group AuthManager
|
||||
* @covers \MediaWiki\Auth\ConfirmLinkSecondaryAuthenticationProvider
|
||||
*/
|
||||
class ConfirmLinkSecondaryAuthenticationProviderTest extends \MediaWikiUnitTestCase {
|
||||
class ConfirmLinkSecondaryAuthenticationProviderTest extends \MediaWikiTestCase {
|
||||
/**
|
||||
* @dataProvider provideGetAuthenticationRequests
|
||||
* @param string $action
|
||||
|
|
@ -3,39 +3,12 @@
|
|||
namespace MediaWiki\Auth;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
use Wikimedia\Rdbms\LoadBalancer;
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
/**
|
||||
* @covers \MediaWiki\Auth\EmailNotificationSecondaryAuthenticationProvider
|
||||
*/
|
||||
class EmailNotificationSecondaryAuthenticationProviderTest extends \MediaWikiUnitTestCase {
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$lbMock = $this->createMock( LoadBalancer::class );
|
||||
$dbMock = $this->getMockBuilder( IDatabase::class )
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$lbMock->expects( $this->any() )
|
||||
->method( 'getConnection' )
|
||||
->willReturn( $dbMock );
|
||||
$dbMock->expects( $this->any() )
|
||||
->method( 'onTransactionCommitOrIdle' )
|
||||
->willReturnCallback( function ( callable $callback ) {
|
||||
$callback();
|
||||
} );
|
||||
|
||||
$lbMockFactory = function () use ( $lbMock ): LoadBalancer {
|
||||
return $lbMock;
|
||||
};
|
||||
|
||||
$this->overrideMwServices( [ 'DBLoadBalancer' => $lbMockFactory ] );
|
||||
}
|
||||
|
||||
class EmailNotificationSecondaryAuthenticationProviderTest extends \PHPUnit\Framework\TestCase {
|
||||
public function testConstructor() {
|
||||
$config = new \HashConfig( [
|
||||
'EnableEmail' => true,
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* @covers ChangesListFilterGroup
|
||||
*/
|
||||
class ChangesListFilterGroupTest extends \MediaWikiUnitTestCase {
|
||||
class ChangesListFilterGroupTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* phpcs:disable Generic.Files.LineLength
|
||||
* @expectedException MWException
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* @covers CustomUppercaseCollation
|
||||
*/
|
||||
class CustomUppercaseCollationTest extends \MediaWikiUnitTestCase {
|
||||
class CustomUppercaseCollationTest extends MediaWikiTestCase {
|
||||
|
||||
public function setUp() {
|
||||
$this->collation = new CustomUppercaseCollation( [
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
class ConfigFactoryTest extends \MediaWikiUnitTestCase {
|
||||
class ConfigFactoryTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @covers ConfigFactory::register
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class HashConfigTest extends \MediaWikiUnitTestCase {
|
||||
class HashConfigTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @covers HashConfig::newInstance
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class MultiConfigTest extends \MediaWikiUnitTestCase {
|
||||
class MultiConfigTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* Tests that settings are fetched in the right order
|
||||
|
|
@ -5,7 +5,7 @@ use MediaWiki\Config\ServiceOptions;
|
|||
/**
|
||||
* @coversDefaultClass \MediaWiki\Config\ServiceOptions
|
||||
*/
|
||||
class ServiceOptionsTest extends \MediaWikiUnitTestCase {
|
||||
class ServiceOptionsTest extends MediaWikiTestCase {
|
||||
public static $testObj;
|
||||
|
||||
public static function setUpBeforeClass() {
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class JsonContentHandlerTest extends \MediaWikiUnitTestCase {
|
||||
class JsonContentHandlerTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @covers JsonContentHandler::makeEmptyContent
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class MWDebugTest extends \MediaWikiUnitTestCase {
|
||||
class MWDebugTest extends MediaWikiTestCase {
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
|
@ -20,9 +20,10 @@
|
|||
|
||||
namespace MediaWiki\Logger;
|
||||
|
||||
use MediaWikiTestCase;
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
class MonologSpiTest extends \MediaWikiUnitTestCase {
|
||||
class MonologSpiTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @covers MediaWiki\Logger\MonologSpi::mergeConfig
|
||||
|
|
@ -20,12 +20,13 @@
|
|||
|
||||
namespace MediaWiki\Logger\Monolog;
|
||||
|
||||
use MediaWikiTestCase;
|
||||
use PHPUnit_Framework_Error_Notice;
|
||||
|
||||
/**
|
||||
* @covers \MediaWiki\Logger\Monolog\AvroFormatter
|
||||
*/
|
||||
class AvroFormatterTest extends \MediaWikiUnitTestCase {
|
||||
class AvroFormatterTest extends MediaWikiTestCase {
|
||||
|
||||
protected function setUp() {
|
||||
if ( !class_exists( 'AvroStringIO' ) ) {
|
||||
|
|
@ -20,13 +20,14 @@
|
|||
|
||||
namespace MediaWiki\Logger\Monolog;
|
||||
|
||||
use MediaWikiTestCase;
|
||||
use Monolog\Logger;
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
/**
|
||||
* @covers \MediaWiki\Logger\Monolog\KafkaHandler
|
||||
*/
|
||||
class KafkaHandlerTest extends \MediaWikiUnitTestCase {
|
||||
class KafkaHandlerTest extends MediaWikiTestCase {
|
||||
|
||||
protected function setUp() {
|
||||
if ( !class_exists( 'Monolog\Handler\AbstractProcessingHandler' )
|
||||
|
|
@ -24,9 +24,10 @@ use AssertionError;
|
|||
use InvalidArgumentException;
|
||||
use LengthException;
|
||||
use LogicException;
|
||||
use MediaWikiTestCase;
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
class LineFormatterTest extends \MediaWikiUnitTestCase {
|
||||
class LineFormatterTest extends MediaWikiTestCase {
|
||||
|
||||
protected function setUp() {
|
||||
if ( !class_exists( 'Monolog\Formatter\LineFormatter' ) ) {
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* @group Diff
|
||||
*/
|
||||
class ArrayDiffFormatterTest extends \MediaWikiUnitTestCase {
|
||||
class ArrayDiffFormatterTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @param Diff $input
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @group Diff
|
||||
*/
|
||||
class DiffOpTest extends \MediaWikiUnitTestCase {
|
||||
class DiffOpTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @covers DiffOp::getType
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* @group Diff
|
||||
*/
|
||||
class DiffTest extends \MediaWikiUnitTestCase {
|
||||
class DiffTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @covers Diff::getEdits
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* @covers HttpError
|
||||
*/
|
||||
class HttpErrorTest extends \MediaWikiUnitTestCase {
|
||||
class HttpErrorTest extends MediaWikiTestCase {
|
||||
|
||||
public function testIsLoggable() {
|
||||
$httpError = new HttpError( 500, 'server error!' );
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
* @file
|
||||
*/
|
||||
|
||||
class MWExceptionHandlerTest extends \MediaWikiUnitTestCase {
|
||||
class MWExceptionHandlerTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @covers MWExceptionHandler::getRedactedTrace
|
||||
16
tests/phpunit/includes/exception/ReadOnlyErrorTest.php
Normal file
16
tests/phpunit/includes/exception/ReadOnlyErrorTest.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @covers ReadOnlyError
|
||||
* @author Addshore
|
||||
*/
|
||||
class ReadOnlyErrorTest extends MediaWikiTestCase {
|
||||
|
||||
public function testConstruction() {
|
||||
$e = new ReadOnlyError();
|
||||
$this->assertEquals( 'readonly', $e->title );
|
||||
$this->assertEquals( 'readonlytext', $e->msg );
|
||||
$this->assertEquals( wfReadOnlyReason() ?: [], $e->params );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* @covers UserNotLoggedIn
|
||||
* @author Addshore
|
||||
*/
|
||||
class UserNotLoggedInTest extends \MediaWikiUnitTestCase {
|
||||
class UserNotLoggedInTest extends MediaWikiTestCase {
|
||||
|
||||
public function testConstruction() {
|
||||
$e = new UserNotLoggedIn();
|
||||
|
|
@ -12,7 +12,7 @@ use Wikimedia\TestingAccessWrapper;
|
|||
* @covers SwiftFileBackendFileList
|
||||
* @covers SwiftFileBackendList
|
||||
*/
|
||||
class SwiftFileBackendTest extends \MediaWikiUnitTestCase {
|
||||
class SwiftFileBackendTest extends MediaWikiTestCase {
|
||||
/** @var TestingAccessWrapper Proxy to SwiftFileBackend */
|
||||
private $backend;
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class FileBackendDBRepoWrapperTest extends \MediaWikiUnitTestCase {
|
||||
class FileBackendDBRepoWrapperTest extends MediaWikiTestCase {
|
||||
protected $backendName = 'foo-backend';
|
||||
protected $repoName = 'pureTestRepo';
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class FileRepoTest extends \MediaWikiUnitTestCase {
|
||||
class FileRepoTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @expectedException MWException
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* @covers HTMLAutoCompleteSelectField
|
||||
*/
|
||||
class HTMLAutoCompleteSelectFieldTest extends \MediaWikiUnitTestCase {
|
||||
class HTMLAutoCompleteSelectFieldTest extends MediaWikiTestCase {
|
||||
|
||||
public $options = [
|
||||
'Bulgaria' => 'BGR',
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* @covers HTMLCheckMatrix
|
||||
*/
|
||||
class HTMLCheckMatrixTest extends \MediaWikiUnitTestCase {
|
||||
class HTMLCheckMatrixTest extends MediaWikiTestCase {
|
||||
private static $defaultOptions = [
|
||||
'rows' => [ 'r1', 'r2' ],
|
||||
'columns' => [ 'c1', 'c2' ],
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
* @license GPL-2.0-or-later
|
||||
* @author Gergő Tisza
|
||||
*/
|
||||
class HTMLFormTest extends \MediaWikiUnitTestCase {
|
||||
class HTMLFormTest extends MediaWikiTestCase {
|
||||
|
||||
private function newInstance() {
|
||||
$form = new HTMLForm( [] );
|
||||
|
|
@ -13,7 +13,7 @@ use GuzzleHttp\Psr7\Request;
|
|||
* @covers GuzzleHttpRequest
|
||||
* @covers MWHttpRequest
|
||||
*/
|
||||
class GuzzleHttpRequestTest extends \MediaWikiUnitTestCase {
|
||||
class GuzzleHttpRequestTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* Placeholder url to use for various tests. This is never contacted, but we must use
|
||||
* a url of valid format to avoid validation errors.
|
||||
|
|
@ -5,7 +5,7 @@ use MediaWiki\Http\HttpRequestFactory;
|
|||
/**
|
||||
* @covers MediaWiki\Http\HttpRequestFactory
|
||||
*/
|
||||
class HttpRequestFactoryTest extends \MediaWikiUnitTestCase {
|
||||
class HttpRequestFactoryTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @return HttpRequestFactory
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class InstallDocFormatterTest extends \MediaWikiUnitTestCase {
|
||||
class InstallDocFormatterTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* @covers InstallDocFormatter
|
||||
* @dataProvider provideDocFormattingTests
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* @group Database
|
||||
* @group Installer
|
||||
*/
|
||||
class OracleInstallerTest extends \MediaWikiUnitTestCase {
|
||||
class OracleInstallerTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @dataProvider provideOracleConnectStrings
|
||||
|
|
@ -8,7 +8,7 @@ use MediaWiki\Interwiki\InterwikiLookupAdapter;
|
|||
* @group MediaWiki
|
||||
* @group Interwiki
|
||||
*/
|
||||
class InterwikiLookupAdapterTest extends \MediaWikiUnitTestCase {
|
||||
class InterwikiLookupAdapterTest extends MediaWikiTestCase {
|
||||
|
||||
/**
|
||||
* @var InterwikiLookupAdapter
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* @covers FormatJson
|
||||
*/
|
||||
class FormatJsonTest extends \MediaWikiUnitTestCase {
|
||||
class FormatJsonTest extends MediaWikiTestCase {
|
||||
|
||||
public static function provideEncoderPrettyPrinting() {
|
||||
return [
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue