diff options
Diffstat (limited to 'tests/phpunit')
28 files changed, 79 insertions, 87 deletions
diff --git a/tests/phpunit/includes/RevisionTest.php b/tests/phpunit/includes/RevisionTest.php index 1c33bfe08dab..d2f426602605 100644 --- a/tests/phpunit/includes/RevisionTest.php +++ b/tests/phpunit/includes/RevisionTest.php @@ -166,7 +166,7 @@ class RevisionTest extends MediaWikiTestCase { ]; yield 'with bad content object (class)' => [ - [ 'content' => new stdClass() ], + [ 'content' => (object)[] ], new MWException( 'content field must contain a Content object' ) ]; yield 'with bad content object (string)' => [ @@ -556,8 +556,7 @@ class RevisionTest extends MediaWikiTestCase { * @covers Revision::compressRevisionText */ public function testCompressRevisionTextUtf8() { - $row = new stdClass; - $row->old_text = "Wiki est l'\xc3\xa9cole superieur !"; + $row = (object)[ 'old_text' => "Wiki est l'\xc3\xa9cole superieur !" ]; $row->old_flags = Revision::compressRevisionText( $row->old_text ); $this->assertTrue( strpos( $row->old_flags, 'utf-8' ) !== false, "Flags should contain 'utf-8'" ); @@ -580,8 +579,7 @@ class RevisionTest extends MediaWikiTestCase { $blobStore->setCompressBlobs( true ); $this->setService( 'BlobStoreFactory', $this->mockBlobStoreFactory( $blobStore ) ); - $row = new stdClass; - $row->old_text = "Wiki est l'\xc3\xa9cole superieur !"; + $row = (object)[ 'old_text' => "Wiki est l'\xc3\xa9cole superieur !" ]; $row->old_flags = Revision::compressRevisionText( $row->old_text ); $this->assertTrue( strpos( $row->old_flags, 'utf-8' ) !== false, "Flags should contain 'utf-8'" ); diff --git a/tests/phpunit/includes/Storage/SqlBlobStoreTest.php b/tests/phpunit/includes/Storage/SqlBlobStoreTest.php index 497c3764f714..2aec6fddf9c0 100644 --- a/tests/phpunit/includes/Storage/SqlBlobStoreTest.php +++ b/tests/phpunit/includes/Storage/SqlBlobStoreTest.php @@ -9,7 +9,6 @@ use MediaWiki\MediaWikiServices; use MediaWiki\Storage\BlobAccessException; use MediaWiki\Storage\SqlBlobStore; use MediaWikiTestCase; -use stdClass; use TitleValue; use WANObjectCache; @@ -189,8 +188,7 @@ class SqlBlobStoreTest extends MediaWikiTestCase { */ public function testCompressRevisionTextUtf8() { $store = $this->getBlobStore(); - $row = new stdClass; - $row->old_text = "Wiki est l'\xc3\xa9cole superieur !"; + $row = (object)[ 'old_text' => "Wiki est l'\xc3\xa9cole superieur !" ]; $row->old_flags = $store->compressData( $row->old_text ); $this->assertTrue( strpos( $row->old_flags, 'utf-8' ) !== false, "Flags should contain 'utf-8'" ); @@ -208,8 +206,7 @@ class SqlBlobStoreTest extends MediaWikiTestCase { $store->setCompressBlobs( true ); $this->checkPHPExtension( 'zlib' ); - $row = new stdClass; - $row->old_text = "Wiki est l'\xc3\xa9cole superieur !"; + $row = (object)[ 'old_text' => "Wiki est l'\xc3\xa9cole superieur !" ]; $row->old_flags = $store->compressData( $row->old_text ); $this->assertTrue( strpos( $row->old_flags, 'utf-8' ) !== false, "Flags should contain 'utf-8'" ); diff --git a/tests/phpunit/includes/api/ApiResultTest.php b/tests/phpunit/includes/api/ApiResultTest.php index bbd2b8b0a171..51d593821c5a 100644 --- a/tests/phpunit/includes/api/ApiResultTest.php +++ b/tests/phpunit/includes/api/ApiResultTest.php @@ -87,9 +87,7 @@ class ApiResultTest extends MediaWikiTestCase { $arr = []; $title = Title::newFromText( "MediaWiki:Foobar" ); - $obj = new stdClass; - $obj->foo = 1; - $obj->bar = 2; + $obj = (object)[ 'foo' => 1, 'bar' => 2 ]; ApiResult::setValue( $arr, 'title', $title ); ApiResult::setValue( $arr, 'obj', $obj ); $this->assertSame( [ @@ -221,7 +219,7 @@ class ApiResultTest extends MediaWikiTestCase { 1 => "\xc3\xa1", ], $arr ); - $obj = new stdClass; + $obj = (object)[]; $obj->{'1'} = 'one'; $arr = []; ApiResult::setValue( $arr, 'foo', $obj ); @@ -337,9 +335,7 @@ class ApiResultTest extends MediaWikiTestCase { $result->reset(); $title = Title::newFromText( "MediaWiki:Foobar" ); - $obj = new stdClass; - $obj->foo = 1; - $obj->bar = 2; + $obj = (object)[ 'foo' => 1, 'bar' => 2 ]; $result->addValue( null, 'title', $title ); $result->addValue( null, 'obj', $obj ); $this->assertSame( [ @@ -526,7 +522,7 @@ class ApiResultTest extends MediaWikiTestCase { ], $result->getResultData() ); $result = new ApiResult( 8388608 ); - $obj = new stdClass; + $obj = (object)[]; $obj->{'1'} = 'one'; $arr = []; $result->addValue( $arr, 'foo', $obj ); diff --git a/tests/phpunit/includes/block/BlockRestrictionStoreTest.php b/tests/phpunit/includes/block/BlockRestrictionStoreTest.php index ca8dc305826f..513bbf31dafe 100644 --- a/tests/phpunit/includes/block/BlockRestrictionStoreTest.php +++ b/tests/phpunit/includes/block/BlockRestrictionStoreTest.php @@ -155,7 +155,7 @@ class BlockRestrictionStoreTest extends \MediaWikiLangTestCase { $pageBar = $this->getExistingTestPage( 'Bar' ); $restrictions = [ - new \stdClass(), + (object)[], new PageRestriction( $block->getId(), $pageFoo->getId() ), new PageRestriction( $block->getId(), $pageBar->getId() ), new NamespaceRestriction( $block->getId(), NS_USER ) @@ -165,7 +165,7 @@ class BlockRestrictionStoreTest extends \MediaWikiLangTestCase { $this->assertTrue( $result ); $restrictions = [ - new \stdClass(), + (object)[], ]; $result = $this->blockRestrictionStore->insert( $restrictions ); @@ -193,7 +193,7 @@ class BlockRestrictionStoreTest extends \MediaWikiLangTestCase { ] ); $restrictions = [ - new \stdClass(), + (object)[], new PageRestriction( $block->getId(), $pageFoo->getId() ), new PageRestriction( $block->getId(), $pageBar->getId() ), new NamespaceRestriction( $block->getId(), NS_USER ), @@ -221,7 +221,7 @@ class BlockRestrictionStoreTest extends \MediaWikiLangTestCase { ] ); $this->blockRestrictionStore->update( [ - new \stdClass(), + (object)[], new PageRestriction( $block->getId(), $pageBar->getId() ), new NamespaceRestriction( $block->getId(), NS_USER ), ] ); @@ -422,7 +422,7 @@ class BlockRestrictionStoreTest extends \MediaWikiLangTestCase { $this->assertCount( 1, $restrictions ); $result = $this->blockRestrictionStore->delete( - array_merge( $restrictions, [ new \stdClass() ] ) + array_merge( $restrictions, [ (object)[] ] ) ); $this->assertTrue( $result ); @@ -500,11 +500,11 @@ class BlockRestrictionStoreTest extends \MediaWikiLangTestCase { return [ [ [ - new \stdClass(), + (object)[], new PageRestriction( 1, 1 ), ], [ - new \stdClass(), + (object)[], new PageRestriction( 1, 2 ) ], false, @@ -563,7 +563,7 @@ class BlockRestrictionStoreTest extends \MediaWikiLangTestCase { */ public function testSetBlockId() { $restrictions = [ - new \stdClass(), + (object)[], new PageRestriction( 1, 1 ), new PageRestriction( 1, 2 ), new NamespaceRestriction( 1, NS_USER ), diff --git a/tests/phpunit/includes/changes/RecentChangeTest.php b/tests/phpunit/includes/changes/RecentChangeTest.php index eeca4b550f51..4718ba0d1979 100644 --- a/tests/phpunit/includes/changes/RecentChangeTest.php +++ b/tests/phpunit/includes/changes/RecentChangeTest.php @@ -32,13 +32,14 @@ class RecentChangeTest extends MediaWikiTestCase { $user = $this->getTestUser()->getUser(); $actorId = $user->getActorId(); - $row = new stdClass(); - $row->rc_foo = 'AAA'; - $row->rc_timestamp = '20150921134808'; - $row->rc_deleted = 'bar'; - $row->rc_comment_text = 'comment'; - $row->rc_comment_data = null; - $row->rc_user = $user->getId(); + $row = (object)[ + 'rc_foo' => 'AAA', + 'rc_timestamp' => '20150921134808', + 'rc_deleted' => 'bar', + 'rc_comment_text' => 'comment', + 'rc_comment_data' => null, + 'rc_user' => $user->getId(), + ]; $rc = RecentChange::newFromRow( $row ); @@ -55,12 +56,13 @@ class RecentChangeTest extends MediaWikiTestCase { ]; $this->assertEquals( $expected, $rc->getAttributes() ); - $row = new stdClass(); - $row->rc_foo = 'AAA'; - $row->rc_timestamp = '20150921134808'; - $row->rc_deleted = 'bar'; - $row->rc_comment = 'comment'; - $row->rc_user = $user->getId(); + $row = (object)[ + 'rc_foo' => 'AAA', + 'rc_timestamp' => '20150921134808', + 'rc_deleted' => 'bar', + 'rc_comment' => 'comment', + 'rc_user' => $user->getId(), + ]; Wikimedia\suppressWarnings(); $rc = RecentChange::newFromRow( $row ); diff --git a/tests/phpunit/includes/config/ConfigFactoryTest.php b/tests/phpunit/includes/config/ConfigFactoryTest.php index b6913dea205b..6a6c2662ad3e 100644 --- a/tests/phpunit/includes/config/ConfigFactoryTest.php +++ b/tests/phpunit/includes/config/ConfigFactoryTest.php @@ -28,7 +28,7 @@ class ConfigFactoryTest extends \MediaWikiIntegrationTestCase { public function testRegisterInvalidInstance() { $factory = new ConfigFactory(); $this->expectException( InvalidArgumentException::class ); - $factory->register( 'invalidInstance', new stdClass ); + $factory->register( 'invalidInstance', (object)[] ); } /** diff --git a/tests/phpunit/includes/filebackend/FileBackendIntegrationTest.php b/tests/phpunit/includes/filebackend/FileBackendIntegrationTest.php index 3abc94737024..b98a999345cb 100644 --- a/tests/phpunit/includes/filebackend/FileBackendIntegrationTest.php +++ b/tests/phpunit/includes/filebackend/FileBackendIntegrationTest.php @@ -1398,7 +1398,7 @@ class FileBackendIntegrationTest extends MediaWikiIntegrationTestCase { ); } - $obj = new stdClass(); + $obj = (object)[]; $tmpFile->bind( $obj ); } diff --git a/tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php b/tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php index 247089df2a6f..f8b4d0c5fbeb 100644 --- a/tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php +++ b/tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php @@ -32,9 +32,10 @@ class MigrateFileRepoLayoutTest extends MediaWikiTestCase { ->disableOriginalConstructor() ->getMock(); - $imageRow = new stdClass; - $imageRow->img_name = $filename; - $imageRow->img_sha1 = sha1( $this->text ); + $imageRow = (object)[ + 'img_name' => $filename, + 'img_sha1' => sha1( $this->text ), + ]; $dbMock->expects( $this->any() ) ->method( 'select' ) diff --git a/tests/phpunit/includes/jobqueue/JobTest.php b/tests/phpunit/includes/jobqueue/JobTest.php index 5ea01c8d07ea..3fae11e13fa3 100644 --- a/tests/phpunit/includes/jobqueue/JobTest.php +++ b/tests/phpunit/includes/jobqueue/JobTest.php @@ -44,7 +44,7 @@ class JobTest extends MediaWikiTestCase { 'someCommand Special: 0=val1 1=val2 ' . $requestId ], [ - $this->getMockJob( [ new stdClass() ] ), + $this->getMockJob( [ (object)[] ] ), 'someCommand Special: 0=object(stdClass) ' . $requestId ], [ diff --git a/tests/phpunit/includes/libs/GenericArrayObjectTest.php b/tests/phpunit/includes/libs/GenericArrayObjectTest.php index 3be2b06465dc..e3ef867042ca 100644 --- a/tests/phpunit/includes/libs/GenericArrayObjectTest.php +++ b/tests/phpunit/includes/libs/GenericArrayObjectTest.php @@ -180,7 +180,7 @@ abstract class GenericArrayObjectTest extends PHPUnit\Framework\TestCase { $elementClass = $list->getObjectType(); - foreach ( [ 42, 'foo', [], new stdClass(), 4.2 ] as $element ) { + foreach ( [ 42, 'foo', [], (object)[], 4.2 ] as $element ) { $validValid = $element instanceof $elementClass; try { diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php index 2695907f88d6..0aace789d10f 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php @@ -114,7 +114,7 @@ class ResourceLoaderTest extends ResourceLoaderTestCase { $resourceLoader = new EmptyResourceLoader(); $this->expectException( InvalidArgumentException::class ); $this->expectExceptionMessage( 'Invalid module info' ); - $resourceLoader->register( [ 'test' => new stdClass() ] ); + $resourceLoader->register( [ 'test' => (object)[] ] ); } /** diff --git a/tests/phpunit/includes/specials/pagers/BlockListPagerTest.php b/tests/phpunit/includes/specials/pagers/BlockListPagerTest.php index 8ee60563b422..d0ce4b5f8fb6 100644 --- a/tests/phpunit/includes/specials/pagers/BlockListPagerTest.php +++ b/tests/phpunit/includes/specials/pagers/BlockListPagerTest.php @@ -40,7 +40,7 @@ class BlockListPagerTest extends MediaWikiTestCase { $value = $name === 'ipb_timestamp' ? MWTimestamp::time() : ''; $expected = $expected ?? MWTimestamp::getInstance()->format( 'H:i, j F Y' ); - $row = $row ?: new stdClass; + $row = $row ?: (object)[]; $pager = new BlockListPager( new SpecialPage(), [], $this->linkRenderer ); $wrappedPager = TestingAccessWrapper::newFromObject( $pager ); $wrappedPager->mCurrentRow = $row; diff --git a/tests/phpunit/includes/user/UserTest.php b/tests/phpunit/includes/user/UserTest.php index 355c363335ea..6ff722adba0f 100644 --- a/tests/phpunit/includes/user/UserTest.php +++ b/tests/phpunit/includes/user/UserTest.php @@ -1587,7 +1587,7 @@ class UserTest extends MediaWikiTestCase { */ public function testNewFromRow() { // TODO: Create real tests here for loadFromRow - $row = new stdClass; + $row = (object)[]; $user = User::newFromRow( $row ); $this->assertInstanceOf( User::class, $user, 'newFromRow returns a user object' ); } diff --git a/tests/phpunit/includes/watcheditem/WatchedItemQueryServiceUnitTest.php b/tests/phpunit/includes/watcheditem/WatchedItemQueryServiceUnitTest.php index 9493de25d867..d12522227254 100644 --- a/tests/phpunit/includes/watcheditem/WatchedItemQueryServiceUnitTest.php +++ b/tests/phpunit/includes/watcheditem/WatchedItemQueryServiceUnitTest.php @@ -236,7 +236,7 @@ class WatchedItemQueryServiceUnitTest extends MediaWikiTestCase { } private function getFakeRow( array $rowValues ) { - $fakeRow = new stdClass(); + $fakeRow = (object)[]; foreach ( $rowValues as $valueName => $value ) { $fakeRow->$valueName = $value; } diff --git a/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php b/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php index 7bfa775ee305..443ded42a0d0 100644 --- a/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php +++ b/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php @@ -153,7 +153,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { } private function getFakeRow( array $rowValues ) { - $fakeRow = new stdClass(); + $fakeRow = (object)[]; foreach ( $rowValues as $valueName => $value ) { $fakeRow->$valueName = $value; } diff --git a/tests/phpunit/unit/includes/TitleArrayFromResultTest.php b/tests/phpunit/unit/includes/TitleArrayFromResultTest.php index 4195ef148208..b772992dab57 100644 --- a/tests/phpunit/unit/includes/TitleArrayFromResultTest.php +++ b/tests/phpunit/unit/includes/TitleArrayFromResultTest.php @@ -22,10 +22,10 @@ class TitleArrayFromResultTest extends MediaWikiUnitTestCase { } private function getRowWithTitle( $namespace = 3, $title = 'foo' ) { - $row = new stdClass(); - $row->page_namespace = $namespace; - $row->page_title = $title; - return $row; + return (object)[ + 'page_namespace' => $namespace, + 'page_title' => $title, + ]; } /** diff --git a/tests/phpunit/unit/includes/composer/ComposerVersionNormalizerTest.php b/tests/phpunit/unit/includes/composer/ComposerVersionNormalizerTest.php index 05d4277d0c19..7682471f0e92 100644 --- a/tests/phpunit/unit/includes/composer/ComposerVersionNormalizerTest.php +++ b/tests/phpunit/unit/includes/composer/ComposerVersionNormalizerTest.php @@ -24,7 +24,7 @@ class ComposerVersionNormalizerTest extends MediaWikiUnitTestCase { [ null ], [ 42 ], [ [] ], - [ new stdClass() ], + [ (object)[] ], [ true ], ]; } diff --git a/tests/phpunit/unit/includes/config/ServiceOptionsTest.php b/tests/phpunit/unit/includes/config/ServiceOptionsTest.php index 7d4918ee10a9..385b1bacb342 100644 --- a/tests/phpunit/unit/includes/config/ServiceOptionsTest.php +++ b/tests/phpunit/unit/includes/config/ServiceOptionsTest.php @@ -11,7 +11,7 @@ class ServiceOptionsTest extends \MediaWikiUnitTestCase { public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); - self::$testObj = new stdclass(); + self::$testObj = (object)[]; } /** diff --git a/tests/phpunit/unit/includes/exception/MWExceptionHandlerTest.php b/tests/phpunit/unit/includes/exception/MWExceptionHandlerTest.php index a67a6a8f75a6..931f16f0fb17 100644 --- a/tests/phpunit/unit/includes/exception/MWExceptionHandlerTest.php +++ b/tests/phpunit/unit/includes/exception/MWExceptionHandlerTest.php @@ -29,7 +29,7 @@ class MWExceptionHandlerTest extends \MediaWikiUnitTestCase { $refvar = 'value'; try { $array = [ 'a', 'b' ]; - $object = new stdClass(); + $object = (object)[]; self::helperThrowAnException( $array, $object, $refvar ); } catch ( Exception $e ) { } diff --git a/tests/phpunit/unit/includes/filebackend/FileBackendGroupTestTrait.php b/tests/phpunit/unit/includes/filebackend/FileBackendGroupTestTrait.php index 63e6093bb767..7a21c6983778 100644 --- a/tests/phpunit/unit/includes/filebackend/FileBackendGroupTestTrait.php +++ b/tests/phpunit/unit/includes/filebackend/FileBackendGroupTestTrait.php @@ -94,7 +94,7 @@ trait FileBackendGroupTestTrait { public function testConstructor_backendObject() { // 'backend' being an object makes that repo from configuration ignored // XXX This is not documented in DefaultSettings.php, does it do anything useful? - $obj = $this->newObj( [ 'ForeignFileRepos' => [ [ 'backend' => new stdclass ] ] ] ); + $obj = $this->newObj( [ 'ForeignFileRepos' => [ [ 'backend' => (object)[] ] ] ] ); $this->assertSame( FSFileBackend::class, $obj->config( 'local-backend' )['class'] ); } diff --git a/tests/phpunit/unit/includes/htmlform/HTMLCheckMatrixTest.php b/tests/phpunit/unit/includes/htmlform/HTMLCheckMatrixTest.php index 53165939ba45..db2da106df5c 100644 --- a/tests/phpunit/unit/includes/htmlform/HTMLCheckMatrixTest.php +++ b/tests/phpunit/unit/includes/htmlform/HTMLCheckMatrixTest.php @@ -44,7 +44,7 @@ class HTMLCheckMatrixTest extends MediaWikiUnitTestCase { $this->assertFalse( $this->validate( $field, null ) ); $this->assertFalse( $this->validate( $field, true ) ); $this->assertFalse( $this->validate( $field, 'abc' ) ); - $this->assertFalse( $this->validate( $field, new stdClass ) ); + $this->assertFalse( $this->validate( $field, (object)[] ) ); $this->assertTrue( $this->validate( $field, [] ) ); } diff --git a/tests/phpunit/unit/includes/json/FormatJsonUnitTest.php b/tests/phpunit/unit/includes/json/FormatJsonUnitTest.php index 487e081a513c..80b69bf1a71c 100644 --- a/tests/phpunit/unit/includes/json/FormatJsonUnitTest.php +++ b/tests/phpunit/unit/includes/json/FormatJsonUnitTest.php @@ -22,7 +22,7 @@ class FormatJsonUnitTest extends MediaWikiUnitTestCase { */ public function testEncoderPrettyPrinting( $pretty, $expectedIndent ) { $obj = [ - 'emptyObject' => new stdClass, + 'emptyObject' => (object)[], 'emptyArray' => [], 'string' => 'foobar\\', 'filledArray' => [ @@ -111,8 +111,8 @@ class FormatJsonUnitTest extends MediaWikiUnitTestCase { public function testEncodeFail() { // Set up a recursive object that can't be encoded. - $a = new stdClass; - $b = new stdClass; + $a = (object)[]; + $b = (object)[]; $a->b = $b; $b->a = $a; $this->assertFalse( FormatJson::encode( $a ) ); diff --git a/tests/phpunit/unit/includes/libs/MemoizedCallableTest.php b/tests/phpunit/unit/includes/libs/MemoizedCallableTest.php index 48383b3d080b..876cc03e011c 100644 --- a/tests/phpunit/unit/includes/libs/MemoizedCallableTest.php +++ b/tests/phpunit/unit/includes/libs/MemoizedCallableTest.php @@ -112,7 +112,7 @@ class MemoizedCallableTest extends PHPUnit\Framework\TestCase { $memoized = new MemoizedCallable( 'gettype' ); $this->expectExceptionMessage( "non-scalar argument" ); $this->expectException( InvalidArgumentException::class ); - $memoized->invoke( new stdClass() ); + $memoized->invoke( (object)[] ); } public function testNotCallable() { diff --git a/tests/phpunit/unit/includes/libs/ProcessCacheLRUTest.php b/tests/phpunit/unit/includes/libs/ProcessCacheLRUTest.php index 430fe809a4be..81d35b157169 100644 --- a/tests/phpunit/unit/includes/libs/ProcessCacheLRUTest.php +++ b/tests/phpunit/unit/includes/libs/ProcessCacheLRUTest.php @@ -85,7 +85,7 @@ class ProcessCacheLRUTest extends PHPUnit\Framework\TestCase { return [ [ null ], [ [] ], - [ new stdClass() ], + [ (object)[] ], [ 0 ], [ '5' ], [ -1 ], diff --git a/tests/phpunit/unit/includes/libs/filebackend/FileBackendTest.php b/tests/phpunit/unit/includes/libs/filebackend/FileBackendTest.php index 0daf03411149..441a8c13594b 100644 --- a/tests/phpunit/unit/includes/libs/filebackend/FileBackendTest.php +++ b/tests/phpunit/unit/includes/libs/filebackend/FileBackendTest.php @@ -171,7 +171,7 @@ class FileBackendTest extends MediaWikiUnitTestCase { 'Function' => [ function () { } ], 'Float' => [ -13.402 ], - 'Object' => [ new stdclass ], + 'Object' => [ (object)[] ], 'Array' => [ [] ], ]; } diff --git a/tests/phpunit/unit/includes/libs/filebackend/fsfile/TempFSFileTestTrait.php b/tests/phpunit/unit/includes/libs/filebackend/fsfile/TempFSFileTestTrait.php index d32e01efcda4..80d9479e4fe5 100644 --- a/tests/phpunit/unit/includes/libs/filebackend/fsfile/TempFSFileTestTrait.php +++ b/tests/phpunit/unit/includes/libs/filebackend/fsfile/TempFSFileTestTrait.php @@ -27,7 +27,7 @@ trait TempFSFileTestTrait { $file = $this->newFile(); $path = $file->getPath(); $this->assertTrue( file_exists( $path ) ); - $obj = new stdclass; + $obj = (object)[]; $file->bind( $obj ); unset( $file ); $this->assertTrue( file_exists( $path ) ); diff --git a/tests/phpunit/unit/includes/libs/services/ServiceContainerTest.php b/tests/phpunit/unit/includes/libs/services/ServiceContainerTest.php index 29f9c468858f..90087a933b20 100644 --- a/tests/phpunit/unit/includes/libs/services/ServiceContainerTest.php +++ b/tests/phpunit/unit/includes/libs/services/ServiceContainerTest.php @@ -46,7 +46,7 @@ class ServiceContainerTest extends PHPUnit\Framework\TestCase { public function testGetService() { $services = $this->newServiceContainer( [ 'Foo' ] ); - $theService = new stdClass(); + $theService = (object)[]; $name = 'TestService92834576'; $count = 0; @@ -110,14 +110,14 @@ class ServiceContainerTest extends PHPUnit\Framework\TestCase { $services->defineService( 'Foo', function () { - return new stdClass(); + return (object)[]; } ); $services->defineService( 'Bar', function () { - return new stdClass(); + return (object)[]; } ); @@ -148,7 +148,7 @@ class ServiceContainerTest extends PHPUnit\Framework\TestCase { public function testDefineService() { $services = $this->newServiceContainer(); - $theService = new stdClass(); + $theService = (object)[]; $name = 'TestService92834576'; $services->defineService( $name, function ( $actualLocator ) use ( $services, $theService ) { @@ -163,7 +163,7 @@ class ServiceContainerTest extends PHPUnit\Framework\TestCase { public function testDefineService_fail_duplicate() { $services = $this->newServiceContainer(); - $theService = new stdClass(); + $theService = (object)[]; $name = 'TestService92834576'; $services->defineService( $name, function () use ( $theService ) { @@ -292,7 +292,7 @@ class ServiceContainerTest extends PHPUnit\Framework\TestCase { public function testRedefineService() { $services = $this->newServiceContainer( [ 'Foo' ] ); - $theService1 = new stdClass(); + $theService1 = (object)[]; $name = 'TestService92834576'; $services->defineService( $name, function () { @@ -318,7 +318,7 @@ class ServiceContainerTest extends PHPUnit\Framework\TestCase { public function testRedefineService_disabled() { $services = $this->newServiceContainer( [ 'Foo' ] ); - $theService1 = new stdClass(); + $theService1 = (object)[]; $name = 'TestService92834576'; $services->defineService( $name, function () { @@ -339,7 +339,7 @@ class ServiceContainerTest extends PHPUnit\Framework\TestCase { public function testRedefineService_fail_undefined() { $services = $this->newServiceContainer(); - $theService = new stdClass(); + $theService = (object)[]; $name = 'TestService92834576'; $this->expectException( Wikimedia\Services\NoSuchServiceException::class ); @@ -352,7 +352,7 @@ class ServiceContainerTest extends PHPUnit\Framework\TestCase { public function testRedefineService_fail_in_use() { $services = $this->newServiceContainer( [ 'Foo' ] ); - $theService = new stdClass(); + $theService = (object)[]; $name = 'TestService92834576'; $services->defineService( $name, function () { @@ -372,8 +372,8 @@ class ServiceContainerTest extends PHPUnit\Framework\TestCase { public function testAddServiceManipulator() { $services = $this->newServiceContainer( [ 'Foo' ] ); - $theService1 = new stdClass(); - $theService2 = new stdClass(); + $theService1 = (object)[]; + $theService2 = (object)[]; $name = 'TestService92834576'; $services->defineService( @@ -406,7 +406,7 @@ class ServiceContainerTest extends PHPUnit\Framework\TestCase { public function testAddServiceManipulator_fail_undefined() { $services = $this->newServiceContainer(); - $theService = new stdClass(); + $theService = (object)[]; $name = 'TestService92834576'; $this->expectException( Wikimedia\Services\NoSuchServiceException::class ); @@ -419,7 +419,7 @@ class ServiceContainerTest extends PHPUnit\Framework\TestCase { public function testAddServiceManipulator_fail_in_use() { $services = $this->newServiceContainer( [ 'Foo' ] ); - $theService = new stdClass(); + $theService = (object)[]; $name = 'TestService92834576'; $services->defineService( $name, function () use ( $theService ) { @@ -448,10 +448,10 @@ class ServiceContainerTest extends PHPUnit\Framework\TestCase { return $destructible; } ); $services->defineService( 'Bar', function () { - return new stdClass(); + return (object)[]; } ); $services->defineService( 'Qux', function () { - return new stdClass(); + return (object)[]; } ); // instantiate Foo and Bar services @@ -485,7 +485,7 @@ class ServiceContainerTest extends PHPUnit\Framework\TestCase { public function testDisableService_fail_undefined() { $services = $this->newServiceContainer(); - $theService = new stdClass(); + $theService = (object)[]; $name = 'TestService92834576'; $this->expectException( Wikimedia\Services\NoSuchServiceException::class ); @@ -508,7 +508,7 @@ class ServiceContainerTest extends PHPUnit\Framework\TestCase { } ); $services->defineService( 'Bar', function () { - return new stdClass(); + return (object)[]; } ); // create the service diff --git a/tests/phpunit/unit/includes/user/UserArrayFromResultTest.php b/tests/phpunit/unit/includes/user/UserArrayFromResultTest.php index 2ceae6c4280e..087aff8273d5 100644 --- a/tests/phpunit/unit/includes/user/UserArrayFromResultTest.php +++ b/tests/phpunit/unit/includes/user/UserArrayFromResultTest.php @@ -22,9 +22,7 @@ class UserArrayFromResultTest extends \MediaWikiUnitTestCase { } private function getRowWithUsername( $username = 'fooUser' ) { - $row = new stdClass(); - $row->user_name = $username; - return $row; + return (object)[ 'user_name' => $username ]; } /** |