Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F585024
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
88 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/tests/phpunit/MediaWikiIntegrationTestCase.php b/tests/phpunit/MediaWikiIntegrationTestCase.php
index 5b021301881..b2b496c8d35 100644
--- a/tests/phpunit/MediaWikiIntegrationTestCase.php
+++ b/tests/phpunit/MediaWikiIntegrationTestCase.php
@@ -2367,7 +2367,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
*
* @return array
*/
- protected function arrayWrap( array $elements ) {
+ protected static function arrayWrap( array $elements ) {
return array_map(
static function ( $element ) {
return [ $element ];
diff --git a/tests/phpunit/includes/Revision/RevisionQueryInfoTest.php b/tests/phpunit/includes/Revision/RevisionQueryInfoTest.php
index 01068cc98de..f3e5a538132 100644
--- a/tests/phpunit/includes/Revision/RevisionQueryInfoTest.php
+++ b/tests/phpunit/includes/Revision/RevisionQueryInfoTest.php
@@ -13,7 +13,7 @@ use MediaWikiIntegrationTestCase;
*/
class RevisionQueryInfoTest extends MediaWikiIntegrationTestCase {
- protected function getRevisionQueryFields( $returnTextIdField = true ) {
+ protected static function getRevisionQueryFields( $returnTextIdField = true ) {
$fields = [
'rev_id',
'rev_page',
@@ -30,7 +30,7 @@ class RevisionQueryInfoTest extends MediaWikiIntegrationTestCase {
return $fields;
}
- protected function getArchiveQueryFields( $returnTextFields = true ) {
+ protected static function getArchiveQueryFields( $returnTextFields = true ) {
$fields = [
'ar_id',
'ar_page_id',
@@ -50,7 +50,7 @@ class RevisionQueryInfoTest extends MediaWikiIntegrationTestCase {
return $fields;
}
- protected function getCommentQueryFields( $prefix ) {
+ protected static function getCommentQueryFields( $prefix ) {
return [
"{$prefix}_comment_text" => "comment_{$prefix}_comment.comment_text",
"{$prefix}_comment_data" => "comment_{$prefix}_comment.comment_data",
@@ -58,7 +58,7 @@ class RevisionQueryInfoTest extends MediaWikiIntegrationTestCase {
];
}
- protected function getActorQueryFields( $prefix, $tmp = false ) {
+ protected static function getActorQueryFields( $prefix, $tmp = false ) {
if ( $tmp ) {
return [
"{$prefix}_user" => "actor_{$prefix}_user.actor_user",
@@ -87,7 +87,7 @@ class RevisionQueryInfoTest extends MediaWikiIntegrationTestCase {
];
}
- protected function getPageQueryFields() {
+ protected static function getPageQueryFields() {
return [
'page_namespace',
'page_title',
@@ -98,7 +98,7 @@ class RevisionQueryInfoTest extends MediaWikiIntegrationTestCase {
];
}
- protected function getUserQueryFields() {
+ protected static function getUserQueryFields() {
return [
'user_name',
];
@@ -111,7 +111,7 @@ class RevisionQueryInfoTest extends MediaWikiIntegrationTestCase {
];
}
- public function provideArchiveQueryInfo() {
+ public static function provideArchiveQueryInfo() {
yield 'no options' => [
[],
[
@@ -121,9 +121,9 @@ class RevisionQueryInfoTest extends MediaWikiIntegrationTestCase {
'comment_ar_comment' => 'comment',
],
'fields' => array_merge(
- $this->getArchiveQueryFields( false ),
- $this->getActorQueryFields( 'ar' ),
- $this->getCommentQueryFields( 'ar' )
+ self::getArchiveQueryFields( false ),
+ self::getActorQueryFields( 'ar' ),
+ self::getCommentQueryFields( 'ar' )
),
'joins' => [
'comment_ar_comment'
@@ -134,7 +134,7 @@ class RevisionQueryInfoTest extends MediaWikiIntegrationTestCase {
];
}
- public function provideQueryInfo() {
+ public static function provideQueryInfo() {
// TODO: more option variations
yield 'page and user option, actor-new' => [
[],
@@ -148,11 +148,11 @@ class RevisionQueryInfoTest extends MediaWikiIntegrationTestCase {
'comment_rev_comment' => 'comment',
],
'fields' => array_merge(
- $this->getRevisionQueryFields( false ),
- $this->getPageQueryFields(),
- $this->getUserQueryFields(),
- $this->getActorQueryFields( 'rev' ),
- $this->getCommentQueryFields( 'rev' )
+ self::getRevisionQueryFields( false ),
+ self::getPageQueryFields(),
+ self::getUserQueryFields(),
+ self::getActorQueryFields( 'rev' ),
+ self::getCommentQueryFields( 'rev' )
),
'joins' => [
'page' => [ 'JOIN', [ 'page_id = rev_page' ] ],
@@ -175,9 +175,9 @@ class RevisionQueryInfoTest extends MediaWikiIntegrationTestCase {
'comment_rev_comment' => 'comment',
],
'fields' => array_merge(
- $this->getRevisionQueryFields( false ),
- $this->getActorQueryFields( 'rev' ),
- $this->getCommentQueryFields( 'rev' )
+ self::getRevisionQueryFields( false ),
+ self::getActorQueryFields( 'rev' ),
+ self::getCommentQueryFields( 'rev' )
),
'joins' => [
'comment_rev_comment' => [ 'JOIN', 'comment_rev_comment.comment_id = rev_comment_id' ],
diff --git a/tests/phpunit/includes/Revision/RevisionStoreDbTest.php b/tests/phpunit/includes/Revision/RevisionStoreDbTest.php
index 544087cc514..ae26c0dbb3d 100644
--- a/tests/phpunit/includes/Revision/RevisionStoreDbTest.php
+++ b/tests/phpunit/includes/Revision/RevisionStoreDbTest.php
@@ -344,12 +344,12 @@ class RevisionStoreDbTest extends MediaWikiIntegrationTestCase {
return $rev;
}
- public function provideInsertRevisionOn_successes() {
+ public static function provideInsertRevisionOn_successes() {
yield 'Bare minimum revision insertion' => [
[
'slot' => SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'Chicken' ) ),
'page' => true,
- 'comment' => $this->getRandomCommentStoreComment(),
+ 'comment' => self::getRandomCommentStoreComment(),
'timestamp' => '20171117010101',
'user' => true,
],
@@ -359,7 +359,7 @@ class RevisionStoreDbTest extends MediaWikiIntegrationTestCase {
'slot' => SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'Chicken' ) ),
'parent' => true,
'page' => true,
- 'comment' => $this->getRandomCommentStoreComment(),
+ 'comment' => self::getRandomCommentStoreComment(),
'timestamp' => '20171117010101',
'user' => true,
'minor' => true,
@@ -373,14 +373,14 @@ class RevisionStoreDbTest extends MediaWikiIntegrationTestCase {
'aux' => new TextContent( 'Egg' ),
],
'page' => true,
- 'comment' => $this->getRandomCommentStoreComment(),
+ 'comment' => self::getRandomCommentStoreComment(),
'timestamp' => '20171117010101',
'user' => true,
],
];
}
- protected function getRandomCommentStoreComment() {
+ protected static function getRandomCommentStoreComment() {
return CommentStoreComment::newUnsavedComment( __METHOD__ . '.' . rand( 0, 1000 ) );
}
@@ -479,7 +479,7 @@ class RevisionStoreDbTest extends MediaWikiIntegrationTestCase {
$revDetails = [
'slot' => SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'Chicken' ) ),
'parent' => true,
- 'comment' => $this->getRandomCommentStoreComment(),
+ 'comment' => self::getRandomCommentStoreComment(),
'timestamp' => '20171117010101',
'user' => true,
];
@@ -512,10 +512,10 @@ class RevisionStoreDbTest extends MediaWikiIntegrationTestCase {
$this->assertSame( $secondReturn->getId(), $secondMainSlot->getRevision() );
}
- public function provideInsertRevisionOn_failures() {
+ public static function provideInsertRevisionOn_failures() {
yield 'no slot' => [
[
- 'comment' => $this->getRandomCommentStoreComment(),
+ 'comment' => self::getRandomCommentStoreComment(),
'timestamp' => '20171117010101',
'user' => true,
],
@@ -524,7 +524,7 @@ class RevisionStoreDbTest extends MediaWikiIntegrationTestCase {
yield 'no main slot' => [
[
'slot' => SlotRecord::newUnsaved( 'aux', new WikitextContent( 'Turkey' ) ),
- 'comment' => $this->getRandomCommentStoreComment(),
+ 'comment' => self::getRandomCommentStoreComment(),
'timestamp' => '20171117010101',
'user' => true,
],
@@ -533,7 +533,7 @@ class RevisionStoreDbTest extends MediaWikiIntegrationTestCase {
yield 'no timestamp' => [
[
'slot' => SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'Chicken' ) ),
- 'comment' => $this->getRandomCommentStoreComment(),
+ 'comment' => self::getRandomCommentStoreComment(),
'user' => true,
],
new IncompleteRevisionException( 'timestamp field must not be NULL!' )
@@ -549,7 +549,7 @@ class RevisionStoreDbTest extends MediaWikiIntegrationTestCase {
yield 'no user' => [
[
'slot' => SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'Chicken' ) ),
- 'comment' => $this->getRandomCommentStoreComment(),
+ 'comment' => self::getRandomCommentStoreComment(),
'timestamp' => '20171117010101',
],
new IncompleteRevisionException( 'user must not be NULL!' )
@@ -557,7 +557,7 @@ class RevisionStoreDbTest extends MediaWikiIntegrationTestCase {
yield 'size mismatch' => [
[
'slot' => SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'Chicken' ) ),
- 'comment' => $this->getRandomCommentStoreComment(),
+ 'comment' => self::getRandomCommentStoreComment(),
'timestamp' => '20171117010101',
'user' => true,
'size' => 123456
@@ -567,7 +567,7 @@ class RevisionStoreDbTest extends MediaWikiIntegrationTestCase {
yield 'sha1 mismatch' => [
[
'slot' => SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'Chicken' ) ),
- 'comment' => $this->getRandomCommentStoreComment(),
+ 'comment' => self::getRandomCommentStoreComment(),
'timestamp' => '20171117010101',
'user' => true,
'sha1' => 'DEADBEEF',
diff --git a/tests/phpunit/includes/Storage/SqlBlobStoreTest.php b/tests/phpunit/includes/Storage/SqlBlobStoreTest.php
index 1073cb8e724..d28429983a0 100644
--- a/tests/phpunit/includes/Storage/SqlBlobStoreTest.php
+++ b/tests/phpunit/includes/Storage/SqlBlobStoreTest.php
@@ -55,13 +55,13 @@ class SqlBlobStoreTest extends MediaWikiIntegrationTestCase {
$this->assertTrue( $store->getUseExternalStore() );
}
- private function makeObjectBlob( $text ) {
+ private static function makeObjectBlob( $text ) {
$obj = new ConcatenatedGzipHistoryBlob();
$obj->setText( $text );
return serialize( $obj );
}
- public function provideDecompress() {
+ public static function provideDecompress() {
yield '(no legacy encoding), empty in empty out' => [ false, '', [], '' ];
yield '(no legacy encoding), string in string out' => [ false, 'A', [], 'A' ];
yield '(no legacy encoding), error flag -> false' => [ false, 'X', [ 'error' ], false ];
@@ -76,13 +76,13 @@ class SqlBlobStoreTest extends MediaWikiIntegrationTestCase {
yield '(no legacy encoding), serialized object in with object flag returns string' => [
false,
- $this->makeObjectBlob( 'HHJJDDFF' ),
+ self::makeObjectBlob( 'HHJJDDFF' ),
[ 'object' ],
'HHJJDDFF',
];
yield '(no legacy encoding), serialized object in with object & gzip flag returns string' => [
false,
- gzdeflate( $this->makeObjectBlob( '8219JJJ840' ) ),
+ gzdeflate( self::makeObjectBlob( '8219JJJ840' ) ),
[ 'object', 'gzip' ],
'8219JJJ840',
];
@@ -100,13 +100,13 @@ class SqlBlobStoreTest extends MediaWikiIntegrationTestCase {
];
yield '(ISO-8859-1 encoding), serialized object in with object flags returns string' => [
'ISO-8859-1',
- $this->makeObjectBlob( iconv( 'utf-8', 'ISO-8859-1', "3®Àþ3" ) ),
+ self::makeObjectBlob( iconv( 'utf-8', 'ISO-8859-1', "3®Àþ3" ) ),
[ 'object' ],
'3®Àþ3',
];
yield '(ISO-8859-1 encoding), serialized object in with object & gzip flags returns string' => [
'ISO-8859-1',
- gzdeflate( $this->makeObjectBlob( iconv( 'utf-8', 'ISO-8859-1', "2®Àþ2" ) ) ),
+ gzdeflate( self::makeObjectBlob( iconv( 'utf-8', 'ISO-8859-1', "2®Àþ2" ) ) ),
[ 'gzip', 'object' ],
'2®Àþ2',
];
diff --git a/tests/phpunit/includes/api/ApiResultTest.php b/tests/phpunit/includes/api/ApiResultTest.php
index 92bb3a3c883..7d44ad2bc56 100644
--- a/tests/phpunit/includes/api/ApiResultTest.php
+++ b/tests/phpunit/includes/api/ApiResultTest.php
@@ -767,7 +767,7 @@ class ApiResultTest extends MediaWikiIntegrationTestCase {
}
}
- public function provideTransformations() {
+ public static function provideTransformations() {
$kvp = static function ( $keyKey, $key, $valKey, $value ) {
return [
$keyKey => $key,
@@ -1268,7 +1268,7 @@ class ApiResultTest extends MediaWikiIntegrationTestCase {
ApiResult::META_PRESERVE_KEYS => [ '_dummy2', '_dummy3' ],
],
[
- 'Custom' => [ $this, 'customTransform' ],
+ 'Custom' => [ self::class, 'customTransform' ],
'BC' => [],
'Types' => [],
'Strip' => 'all'
@@ -1318,7 +1318,7 @@ class ApiResultTest extends MediaWikiIntegrationTestCase {
* @param array &$data
* @param array &$metadata
*/
- public function customTransform( &$data, &$metadata ) {
+ public static function customTransform( &$data, &$metadata ) {
// Prevent recursion
if ( isset( $metadata['_added'] ) ) {
$metadata[ApiResult::META_TYPE] = 'array';
diff --git a/tests/phpunit/includes/api/query/ApiQuerySearchTest.php b/tests/phpunit/includes/api/query/ApiQuerySearchTest.php
index 92ecd118414..04f95b85b8c 100644
--- a/tests/phpunit/includes/api/query/ApiQuerySearchTest.php
+++ b/tests/phpunit/includes/api/query/ApiQuerySearchTest.php
@@ -28,27 +28,27 @@ class ApiQuerySearchTest extends ApiTestCase {
$this->overrideConfigValue( MainConfigNames::SearchType, MockSearchEngine::class );
}
- public function provideSearchResults() {
+ public static function provideSearchResults() {
return [
'empty search result' => [ [], [] ],
'has search results' => [
[ 'Zomg' ],
- [ $this->mockResultClosure( 'Zomg' ) ],
+ [ self::mockResultClosure( 'Zomg' ) ],
],
'filters broken search results' => [
[ 'A', 'B' ],
[
- $this->mockResultClosure( 'a' ),
- $this->mockResultClosure( 'Zomg', [ 'setBrokenTitle' => true ] ),
- $this->mockResultClosure( 'b' ),
+ self::mockResultClosure( 'a' ),
+ self::mockResultClosure( 'Zomg', [ 'setBrokenTitle' => true ] ),
+ self::mockResultClosure( 'b' ),
],
],
'filters results with missing revision' => [
[ 'B', 'A' ],
[
- $this->mockResultClosure( 'Zomg', [ 'setMissingRevision' => true ] ),
- $this->mockResultClosure( 'b' ),
- $this->mockResultClosure( 'a' ),
+ self::mockResultClosure( 'Zomg', [ 'setMissingRevision' => true ] ),
+ self::mockResultClosure( 'b' ),
+ self::mockResultClosure( 'a' ),
],
],
];
@@ -68,7 +68,7 @@ class ApiQuerySearchTest extends ApiTestCase {
$this->assertEquals( $expect, $titles );
}
- public function provideInterwikiResults() {
+ public static function provideInterwikiResults() {
return [
'empty' => [ [], [] ],
'one wiki response' => [
@@ -76,7 +76,7 @@ class ApiQuerySearchTest extends ApiTestCase {
[
ISearchResultSet::SECONDARY_RESULTS => [
'utwiki' => new MockSearchResultSet( [
- $this->mockResultClosure(
+ self::mockResultClosure(
'Qwerty',
[ 'setInterwikiPrefix' => 'utwiki' ]
),
@@ -125,7 +125,7 @@ class ApiQuerySearchTest extends ApiTestCase {
* @param array $setters
* @return callable function(): MockSearchResult
*/
- private function mockResultClosure( $titleText, $setters = [] ) {
+ private static function mockResultClosure( $titleText, $setters = [] ) {
return static function () use ( $titleText, $setters ) {
$title = Title::newFromText( $titleText );
$title->resetArticleID( 0 );
diff --git a/tests/phpunit/includes/filerepo/file/FileTest.php b/tests/phpunit/includes/filerepo/file/FileTest.php
index a41a18dbe9f..129685a5ec8 100644
--- a/tests/phpunit/includes/filerepo/file/FileTest.php
+++ b/tests/phpunit/includes/filerepo/file/FileTest.php
@@ -316,7 +316,7 @@ class FileTest extends MediaWikiMediaTestCase {
$data['message'] );
}
- public function generateBucketsIfNeededProvider() {
+ public static function generateBucketsIfNeededProvider() {
$defaultBuckets = [ 256, 512, 1024, 2048, 4096 ];
return [
@@ -325,12 +325,12 @@ class FileTest extends MediaWikiMediaTestCase {
'width' => 256,
'physicalWidth' => 256,
'physicalHeight' => 100,
- 'expectedGetBucketThumbPathCalls' => $this->never(),
- 'expectedFileExistsCalls' => $this->never(),
+ 'expectedGetBucketThumbPathCalls' => self::never(),
+ 'expectedFileExistsCalls' => self::never(),
'fileExistsReturn' => null,
- 'expectedMakeTransformTmpFile' => $this->never(),
+ 'expectedMakeTransformTmpFile' => self::never(),
'makeTransformTmpFileReturn' => false,
- 'expectedGenerateAndSaveThumb' => $this->never(),
+ 'expectedGenerateAndSaveThumb' => self::never(),
'generateAndSaveThumbReturn' => false,
'expectedResult' => false,
'message' => 'No bucket found, nothing to generate'
@@ -340,12 +340,12 @@ class FileTest extends MediaWikiMediaTestCase {
'width' => 5000,
'physicalWidth' => 300,
'physicalHeight' => 200,
- 'expectedGetBucketThumbPathCalls' => $this->once(),
- 'expectedFileExistsCalls' => $this->once(),
+ 'expectedGetBucketThumbPathCalls' => self::once(),
+ 'expectedFileExistsCalls' => self::once(),
'fileExistsReturn' => true,
- 'expectedMakeTransformTmpFile' => $this->never(),
+ 'expectedMakeTransformTmpFile' => self::never(),
'makeTransformTmpFileReturn' => false,
- 'expectedGenerateAndSaveThumb' => $this->never(),
+ 'expectedGenerateAndSaveThumb' => self::never(),
'generateAndSaveThumbReturn' => false,
'expectedResult' => false,
'message' => 'File already exists, no reason to generate buckets'
@@ -355,12 +355,12 @@ class FileTest extends MediaWikiMediaTestCase {
'width' => 5000,
'physicalWidth' => 300,
'physicalHeight' => 200,
- 'expectedGetBucketThumbPathCalls' => $this->once(),
- 'expectedFileExistsCalls' => $this->once(),
+ 'expectedGetBucketThumbPathCalls' => self::once(),
+ 'expectedFileExistsCalls' => self::once(),
'fileExistsReturn' => false,
- 'expectedMakeTransformTmpFile' => $this->once(),
+ 'expectedMakeTransformTmpFile' => self::once(),
'makeTransformTmpFileReturn' => false,
- 'expectedGenerateAndSaveThumb' => $this->never(),
+ 'expectedGenerateAndSaveThumb' => self::never(),
'generateAndSaveThumbReturn' => false,
'expectedResult' => false,
'message' => 'Cannot generate temp file for bucket'
@@ -370,12 +370,12 @@ class FileTest extends MediaWikiMediaTestCase {
'width' => 5000,
'physicalWidth' => 300,
'physicalHeight' => 200,
- 'expectedGetBucketThumbPathCalls' => $this->once(),
- 'expectedFileExistsCalls' => $this->once(),
+ 'expectedGetBucketThumbPathCalls' => self::once(),
+ 'expectedFileExistsCalls' => self::once(),
'fileExistsReturn' => false,
- 'expectedMakeTransformTmpFile' => $this->once(),
+ 'expectedMakeTransformTmpFile' => self::once(),
'makeTransformTmpFileReturn' => new TempFSFile( '/tmp/foo' ),
- 'expectedGenerateAndSaveThumb' => $this->once(),
+ 'expectedGenerateAndSaveThumb' => self::once(),
'generateAndSaveThumbReturn' => false,
'expectedResult' => false,
'message' => 'Bucket image could not be generated'
@@ -385,12 +385,12 @@ class FileTest extends MediaWikiMediaTestCase {
'width' => 5000,
'physicalWidth' => 300,
'physicalHeight' => 200,
- 'expectedGetBucketThumbPathCalls' => $this->once(),
- 'expectedFileExistsCalls' => $this->once(),
+ 'expectedGetBucketThumbPathCalls' => self::once(),
+ 'expectedFileExistsCalls' => self::once(),
'fileExistsReturn' => false,
- 'expectedMakeTransformTmpFile' => $this->once(),
+ 'expectedMakeTransformTmpFile' => self::once(),
'makeTransformTmpFileReturn' => new TempFSFile( '/tmp/foo' ),
- 'expectedGenerateAndSaveThumb' => $this->once(),
+ 'expectedGenerateAndSaveThumb' => self::once(),
'generateAndSaveThumbReturn' => new ThumbnailImage( false, 'bar', false, false ),
'expectedResult' => true,
'message' => 'Bucket image could not be generated'
diff --git a/tests/phpunit/includes/site/SiteListTest.php b/tests/phpunit/includes/site/SiteListTest.php
index 2046f56c9dc..c97d62c559f 100644
--- a/tests/phpunit/includes/site/SiteListTest.php
+++ b/tests/phpunit/includes/site/SiteListTest.php
@@ -35,8 +35,8 @@ class SiteListTest extends MediaWikiIntegrationTestCase {
* Returns instances of SiteList implementing objects.
* @return array
*/
- public function siteListProvider() {
- $sitesArrays = $this->siteArrayProvider();
+ public static function siteListProvider() {
+ $sitesArrays = self::siteArrayProvider();
$listInstances = [];
@@ -44,14 +44,14 @@ class SiteListTest extends MediaWikiIntegrationTestCase {
$listInstances[] = new SiteList( $sitesArray[0] );
}
- return $this->arrayWrap( $listInstances );
+ return self::arrayWrap( $listInstances );
}
/**
* Returns arrays with instances of Site implementing objects.
* @return array
*/
- public function siteArrayProvider() {
+ public static function siteArrayProvider() {
$sites = TestSites::getSites();
$siteArrays = [];
@@ -62,7 +62,7 @@ class SiteListTest extends MediaWikiIntegrationTestCase {
$siteArrays[] = [ array_shift( $sites ), array_shift( $sites ) ];
- return $this->arrayWrap( $siteArrays );
+ return self::arrayWrap( $siteArrays );
}
/**
diff --git a/tests/phpunit/includes/site/SiteTest.php b/tests/phpunit/includes/site/SiteTest.php
index b719dc6c259..11893941e4e 100644
--- a/tests/phpunit/includes/site/SiteTest.php
+++ b/tests/phpunit/includes/site/SiteTest.php
@@ -33,8 +33,8 @@ use MediaWikiIntegrationTestCase;
*/
class SiteTest extends MediaWikiIntegrationTestCase {
- public function instanceProvider() {
- return $this->arrayWrap( TestSites::getSites() );
+ public static function instanceProvider() {
+ return self::arrayWrap( TestSites::getSites() );
}
/**
diff --git a/tests/phpunit/includes/title/NamespaceInfoTest.php b/tests/phpunit/includes/title/NamespaceInfoTest.php
index fcb4f3f72bc..8f55659460c 100644
--- a/tests/phpunit/includes/title/NamespaceInfoTest.php
+++ b/tests/phpunit/includes/title/NamespaceInfoTest.php
@@ -326,13 +326,13 @@ class NamespaceInfoTest extends MediaWikiIntegrationTestCase {
$this->assertSame( $expected, $obj->wantSignatures( $index ) );
}
- public function provideWantSignatures_ExtraSignatureNamespaces() {
+ public static function provideWantSignatures_ExtraSignatureNamespaces() {
$ret = array_map(
static function ( $arr ) {
// We've added all these as extra signature namespaces, so expect true
return [ $arr[0], true ];
},
- $this->provideWantSignatures()
+ self::provideWantSignatures()
);
// Add one more that's false
diff --git a/tests/phpunit/includes/utils/FileContentsHasherTest.php b/tests/phpunit/includes/utils/FileContentsHasherTest.php
index 33e047fb3c8..c72dd6d51bf 100644
--- a/tests/phpunit/includes/utils/FileContentsHasherTest.php
+++ b/tests/phpunit/includes/utils/FileContentsHasherTest.php
@@ -25,9 +25,9 @@ class FileContentsHasherTest extends PHPUnit\Framework\TestCase {
$this->assertEquals( $expected, $actualHashRepeat );
}
- public function provideMultipleFiles() {
+ public static function provideMultipleFiles() {
return [
- [ $this->provideSingleFile() ]
+ [ self::provideSingleFile() ]
];
}
diff --git a/tests/phpunit/integration/includes/HTMLForm/HTMLFormFieldTest.php b/tests/phpunit/integration/includes/HTMLForm/HTMLFormFieldTest.php
index 69de302bd9a..b84282e092d 100644
--- a/tests/phpunit/integration/includes/HTMLForm/HTMLFormFieldTest.php
+++ b/tests/phpunit/integration/includes/HTMLForm/HTMLFormFieldTest.php
@@ -15,6 +15,7 @@ use MediaWiki\Status\Status;
use MediaWiki\Title\Title;
use MediaWikiCoversValidator;
use MediaWikiIntegrationTestCase;
+use PHPUnit\Framework\Assert;
use StatusValue;
use Wikimedia\TestingAccessWrapper;
@@ -64,7 +65,7 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
$callback( $form, $form->mFieldData );
}
- public function provideCondState() {
+ public static function provideCondState() {
yield 'Field hidden if "check" field is checked' => [
'fieldInfo' => [
'text1' => [ 'hide-if' => [ '===', 'check1', '1' ] ],
@@ -72,8 +73,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'requestData' => [
'wpcheck1' => '1',
],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
}
];
yield 'Field hidden if "check" field is not checked' => [
@@ -81,8 +82,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'text1' => [ 'hide-if' => [ '===', 'check1', '' ] ],
],
'requestData' => [],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
}
];
yield 'Field not hidden if "check" field is not checked' => [
@@ -90,8 +91,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'text1' => [ 'hide-if' => [ '===', 'check1', '1' ] ],
],
'requestData' => [],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertFalse( $form->getField( 'text1' )->isHidden( $fieldData ) );
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertFalse( $form->getField( 'text1' )->isHidden( $fieldData ) );
}
];
yield 'Field hidden if "check" field (invert) is checked' => [
@@ -101,8 +102,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'requestData' => [
'wpcheck2' => '1',
],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
}
];
yield 'Field hidden if "check" field (invert) is not checked' => [
@@ -110,8 +111,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'text1' => [ 'hide-if' => [ '!==', 'check2', '1' ] ],
],
'requestData' => [],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
}
];
yield 'Field not hidden if "check" field (invert) is checked' => [
@@ -121,8 +122,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'requestData' => [
'wpcheck2' => '1',
],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertFalse( $form->getField( 'text1' )->isHidden( $fieldData ) );
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertFalse( $form->getField( 'text1' )->isHidden( $fieldData ) );
}
];
yield 'Field hidden if "select" field has value' => [
@@ -132,8 +133,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'requestData' => [
'wpselect1' => 'a',
],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
}
];
yield 'Field hidden if "text" field has value' => [
@@ -143,8 +144,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'requestData' => [
'wptext1' => 'hello',
],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $form->getField( 'select1' )->isHidden( $fieldData ) );
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( $form->getField( 'select1' )->isHidden( $fieldData ) );
}
];
@@ -159,8 +160,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'wpcheck1' => '1',
'wpselect1' => 'a',
],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
}
];
yield 'Field hidden using OR conditions' => [
@@ -173,8 +174,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'requestData' => [
'wpcheck1' => '1',
],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
}
];
yield 'Field hidden using NAND conditions' => [
@@ -187,8 +188,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'requestData' => [
'wpcheck1' => '1',
],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
}
];
yield 'Field hidden using NOR conditions' => [
@@ -199,8 +200,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
] ],
],
'requestData' => [],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
}
];
yield 'Field hidden using complex conditions' => [
@@ -214,8 +215,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
] ],
],
'requestData' => [],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( $form->getField( 'text1' )->isHidden( $fieldData ) );
}
];
@@ -267,8 +268,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'requestData' => [
'wpcheck1' => '1',
],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $form->getField( 'text1' )->isDisabled( $fieldData ) );
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( $form->getField( 'text1' )->isDisabled( $fieldData ) );
}
];
yield 'Field disabled if hidden' => [
@@ -278,8 +279,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'requestData' => [
'wpcheck1' => '1',
],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $form->getField( 'text1' )->isDisabled( $fieldData ) );
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( $form->getField( 'text1' )->isDisabled( $fieldData ) );
}
];
@@ -290,8 +291,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'requestData' => [
'foo' => '1',
],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $form->getField( 'text1' )->isDisabled( $fieldData ) );
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( $form->getField( 'text1' )->isDisabled( $fieldData ) );
}
];
yield 'Field disabled even the \'wp\' prefix is used (back-compat)' => [
@@ -301,8 +302,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'requestData' => [
'wpcheck1' => '1',
],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $form->getField( 'text1' )->isDisabled( $fieldData ) );
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( $form->getField( 'text1' )->isDisabled( $fieldData ) );
}
];
yield 'Field name does not exist' => [
@@ -323,8 +324,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'requestData' => [
'wpcloner' => [ 0 => [ 'check1' => '1' ] ],
],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $this->getFieldInCloner( $form, 'cloner', 0, 'check2' )
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( self::getFieldInCloner( $form, 'cloner', 0, 'check2' )
->isDisabled( $fieldData ) );
}
];
@@ -337,8 +338,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'requestData' => [
'wpcloner' => [ 0 => [ 'check2' => '1' ] ],
],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $this->getFieldInCloner( $form, 'cloner', 0, 'check1' )
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( self::getFieldInCloner( $form, 'cloner', 0, 'check1' )
->isDisabled( $fieldData ) );
}
];
@@ -351,8 +352,8 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'requestData' => [
'wpcloner' => [ 0 => [ 'foo' => '1' ] ],
],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $this->getFieldInCloner( $form, 'cloner', 0, 'check1' )
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( self::getFieldInCloner( $form, 'cloner', 0, 'check1' )
->isDisabled( $fieldData ) );
}
];
@@ -365,14 +366,14 @@ class HTMLFormFieldTest extends MediaWikiIntegrationTestCase {
'requestData' => [
'wpselect1' => 'a',
],
- 'callback' => function ( $form, $fieldData ) {
- $this->assertTrue( $this->getFieldInCloner( $form, 'cloner', 0, 'check1' )
+ 'callback' => static function ( $form, $fieldData ) {
+ Assert::assertTrue( self::getFieldInCloner( $form, 'cloner', 0, 'check1' )
->isDisabled( $fieldData ) );
}
];
}
- private function getFieldInCloner( $form, $clonerName, $index, $fieldName ) {
+ private static function getFieldInCloner( $form, $clonerName, $index, $fieldName ) {
$cloner = TestingAccessWrapper::newFromObject( $form->getField( $clonerName ) );
return $cloner->getFieldsForKey( $index )[$fieldName];
}
diff --git a/tests/phpunit/integration/includes/Rest/Handler/Helper/HtmlInputTransformHelperTest.php b/tests/phpunit/integration/includes/Rest/Handler/Helper/HtmlInputTransformHelperTest.php
index 204e811d90b..603e8c891b7 100644
--- a/tests/phpunit/integration/includes/Rest/Handler/Helper/HtmlInputTransformHelperTest.php
+++ b/tests/phpunit/integration/includes/Rest/Handler/Helper/HtmlInputTransformHelperTest.php
@@ -108,16 +108,16 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
);
}
- private function getTextFromFile( string $name ): string {
+ private static function getTextFromFile( string $name ): string {
return trim( file_get_contents( __DIR__ . "/../data/Transform/$name" ) );
}
- private function getJsonFromFile( string $name ): array {
- $text = $this->getTextFromFile( $name );
+ private static function getJsonFromFile( string $name ): array {
+ $text = self::getTextFromFile( $name );
return json_decode( $text, JSON_OBJECT_AS_ARRAY );
}
- public function provideRequests() {
+ public static function provideRequests() {
$profileVersion = '2.4.0';
$wikitextProfileUri = 'https://www.mediawiki.org/wiki/Specs/wikitext/1.0.0';
$htmlProfileUri = 'https://www.mediawiki.org/wiki/Specs/HTML/' . $profileVersion;
@@ -138,7 +138,7 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
];
// should convert html to wikitext ///////////////////////////////////
- $html = $this->getTextFromFile( 'MainPage-data-parsoid.html' );
+ $html = self::getTextFromFile( 'MainPage-data-parsoid.html' );
$expectedText = [
'MediaWiki has been successfully installed',
'== Getting started ==',
@@ -164,7 +164,7 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
];
// should accept original wikitext in body ////////////////////
- $originalWikitext = $this->getTextFromFile( 'OriginalMainPage.wikitext' );
+ $originalWikitext = self::getTextFromFile( 'OriginalMainPage.wikitext' );
$params = [];
$body = [
'html' => $html,
@@ -184,7 +184,7 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
];
// should use original html for selser (default) //////////////////////
- $originalDataParsoid = $this->getJsonFromFile( 'MainPage-original.data-parsoid' );
+ $originalDataParsoid = self::getJsonFromFile( 'MainPage-original.data-parsoid' );
$params = [
'from' => ParsoidFormatHelper::FORMAT_PAGEBUNDLE,
];
@@ -193,7 +193,7 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
'original' => [
'html' => [
'headers' => $htmlHeaders,
- 'body' => $this->getTextFromFile( 'MainPage-original.html' ),
+ 'body' => self::getTextFromFile( 'MainPage-original.html' ),
],
'data-parsoid' => [
'headers' => [
@@ -220,7 +220,7 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
// version given in the HTML?
'content-type' => 'text/html; profile="mediawiki.org/specs/html/1.1.1"',
],
- 'body' => $this->getTextFromFile( 'MainPage-data-parsoid-1.1.1.html' ),
+ 'body' => self::getTextFromFile( 'MainPage-data-parsoid-1.1.1.html' ),
],
'data-parsoid' => [
'headers' => [
@@ -249,7 +249,7 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
'content-type' => 'text/html; profile="mediawiki.org/specs/html/1.1.1"',
],
// No schema version in HTML
- 'body' => $this->getTextFromFile( 'MainPage-original.html' ),
+ 'body' => self::getTextFromFile( 'MainPage-original.html' ),
],
'data-parsoid' => [
'headers' => [
@@ -485,7 +485,7 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
];
// should apply original data-mw when modified is absent (captions 1) ///////////
- $html = $this->getTextFromFile( 'Image.html' );
+ $html = self::getTextFromFile( 'Image.html' );
$dataParsoid = [ 'ids' => [
'mwAg' => [ 'optList' => [ [ 'ck' => 'caption', 'ak' => 'Testing 123' ] ] ],
'mwAw' => [ 'a' => [ 'href' => './File:Foobar.jpg' ], 'sa' => [] ],
@@ -519,7 +519,7 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
];
// should give precedence to inline data-mw over modified (captions 2) /////////////
- $htmlModified = $this->getTextFromFile( 'Image-data-mw.html' );
+ $htmlModified = self::getTextFromFile( 'Image-data-mw.html' );
$dataMediaWikiModified = [
'ids' => [
'mwAg' => [ 'caption' => 'Testing 123' ]
@@ -598,7 +598,7 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
];
// should apply version downgrade ///////////
- $htmlOfMinimal = $this->getTextFromFile( 'Minimal.html' ); // Uses profile version 2.4.0
+ $htmlOfMinimal = self::getTextFromFile( 'Minimal.html' ); // Uses profile version 2.4.0
$params = [
'from' => ParsoidFormatHelper::FORMAT_PAGEBUNDLE,
];
@@ -624,7 +624,7 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
];
// should not apply version downgrade if versions are the same ///////////
- $htmlOfMinimal = $this->getTextFromFile( 'Minimal.html' ); // Uses profile version 2.4.0
+ $htmlOfMinimal = self::getTextFromFile( 'Minimal.html' ); // Uses profile version 2.4.0
$params = [];
$body = [
'html' => $htmlOfMinimal,
@@ -647,7 +647,7 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
];
// should convert html to json ///////////////////////////////////
- $html = $this->getTextFromFile( 'JsonConfig.html' );
+ $html = self::getTextFromFile( 'JsonConfig.html' );
$expectedText = [
'{"a":4,"b":3}',
];
@@ -664,7 +664,7 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
];
// page bundle input should work with no original data present ///////////
- $htmlOfMinimal = $this->getTextFromFile( 'Minimal.html' ); // Uses profile version 2.4.0
+ $htmlOfMinimal = self::getTextFromFile( 'Minimal.html' ); // Uses profile version 2.4.0
$params = [];
$body = [
'html' => $htmlOfMinimal,
@@ -741,10 +741,10 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
);
}
- public function provideOriginal() {
+ public static function provideOriginal() {
$unchangedPB = new PageBundle(
- $this->getTextFromFile( 'MainPage-original.html' ),
- $this->getJsonFromFile( 'MainPage-original.data-parsoid' ),
+ self::getTextFromFile( 'MainPage-original.html' ),
+ self::getJsonFromFile( 'MainPage-original.data-parsoid' ),
null,
Parsoid::defaultHTMLVersion()
);
@@ -830,7 +830,7 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
$stash->set( $renderID, $stashed );
}
- $html = $this->getTextFromFile( 'MainPage-original.html' );
+ $html = self::getTextFromFile( 'MainPage-original.html' );
$params = [];
$body = [
@@ -899,7 +899,7 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
public function testResponseForFakeRevision() {
$wikitext = 'Unsaved Revision Content';
- $html = $this->getTextFromFile( 'Minimal.html' );
+ $html = self::getTextFromFile( 'Minimal.html' );
$page = PageIdentityValue::localIdentity( 7, NS_MAIN, $body['pageName'] ?? 'HtmlInputTransformHelperTest' );
// Create a fake revision. Since the HTML didn't change, we expect to get back the content
@@ -945,8 +945,8 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
$page = $this->getExistingTestPage();
$oldWikitext = $page->getContent()->serialize();
- $html = $this->getTextFromFile( 'MainPage-original.html' );
- $dataParsoid = $this->getJsonFromFile( 'MainPage-original.data-parsoid' );
+ $html = self::getTextFromFile( 'MainPage-original.html' );
+ $dataParsoid = self::getJsonFromFile( 'MainPage-original.data-parsoid' );
$pb = new PageBundle(
$html,
@@ -990,8 +990,8 @@ class HtmlInputTransformHelperTest extends MediaWikiIntegrationTestCase {
$page = $this->getNonexistingTestPage();
- $html = $this->getTextFromFile( 'MainPage-original.html' );
- $dataParsoid = $this->getJsonFromFile( 'MainPage-original.data-parsoid' );
+ $html = self::getTextFromFile( 'MainPage-original.html' );
+ $dataParsoid = self::getJsonFromFile( 'MainPage-original.data-parsoid' );
$oldWikitext = 'Fake old wikitext';
$content = new WikitextContent( $oldWikitext );
diff --git a/tests/phpunit/integration/includes/Rest/Handler/ParsoidHandlerTest.php b/tests/phpunit/integration/includes/Rest/Handler/ParsoidHandlerTest.php
index e9c27afc8d2..c8e16d7ac01 100644
--- a/tests/phpunit/integration/includes/Rest/Handler/ParsoidHandlerTest.php
+++ b/tests/phpunit/integration/includes/Rest/Handler/ParsoidHandlerTest.php
@@ -322,12 +322,12 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
return $pageConfigFactory;
}
- private function getTextFromFile( string $name ): string {
+ private static function getTextFromFile( string $name ): string {
return trim( file_get_contents( __DIR__ . "/data/Transform/$name" ) );
}
- private function getJsonFromFile( string $name ): array {
- $text = $this->getTextFromFile( $name );
+ private static function getJsonFromFile( string $name ): array {
+ $text = self::getTextFromFile( $name );
return json_decode( $text, JSON_OBJECT_AS_ARRAY );
}
@@ -359,7 +359,7 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
return $expectedMime === $actualMime && $expectedSpec === $actualSpec;
}
- public function provideHtml2wt() {
+ public static function provideHtml2wt() {
$profileVersion = '2.6.0';
$wikitextProfileUri = 'https://www.mediawiki.org/wiki/Specs/wikitext/1.0.0';
$htmlProfileUri = 'https://www.mediawiki.org/wiki/Specs/HTML/' . $profileVersion;
@@ -380,7 +380,7 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
];
// should convert html to wikitext ///////////////////////////////////
- $html = $this->getTextFromFile( 'MainPage-data-parsoid.html' );
+ $html = self::getTextFromFile( 'MainPage-data-parsoid.html' );
$expectedText = [
'MediaWiki has been successfully installed',
'== Getting started ==',
@@ -404,7 +404,7 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
];
// should accept original wikitext in body ////////////////////
- $originalWikitext = $this->getTextFromFile( 'OriginalMainPage.wikitext' );
+ $originalWikitext = self::getTextFromFile( 'OriginalMainPage.wikitext' );
$attribs = [
'opts' => [
'original' => [
@@ -424,14 +424,14 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
];
// should use original html for selser (default) //////////////////////
- $originalDataParsoid = $this->getJsonFromFile( 'MainPage-original.data-parsoid' );
+ $originalDataParsoid = self::getJsonFromFile( 'MainPage-original.data-parsoid' );
$attribs = [
'opts' => [
'from' => ParsoidFormatHelper::FORMAT_PAGEBUNDLE,
'original' => [
'html' => [
'headers' => $htmlHeaders,
- 'body' => $this->getTextFromFile( 'MainPage-original.html' ),
+ 'body' => self::getTextFromFile( 'MainPage-original.html' ),
],
'data-parsoid' => [
'headers' => [
@@ -459,7 +459,7 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
// version given in the HTML?
'content-type' => 'text/html; profile="mediawiki.org/specs/html/1.1.1"',
],
- 'body' => $this->getTextFromFile( 'MainPage-data-parsoid-1.1.1.html' ),
+ 'body' => self::getTextFromFile( 'MainPage-data-parsoid-1.1.1.html' ),
],
'data-parsoid' => [
'headers' => [
@@ -487,7 +487,7 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
'content-type' => 'text/html; profile="mediawiki.org/specs/html/1.1.1"',
],
// No schema version in HTML
- 'body' => $this->getTextFromFile( 'MainPage-original.html' ),
+ 'body' => self::getTextFromFile( 'MainPage-original.html' ),
],
'data-parsoid' => [
'headers' => [
@@ -507,7 +507,7 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
// Return original wikitext when HTML doesn't change ////////////////////////////
// New and old html are identical, which should produce no diffs
// and reuse the original wikitext.
- $html = $this->getTextFromFile( 'Selser.html' );
+ $html = self::getTextFromFile( 'Selser.html' );
// Original wikitext (to be preserved by selser)
$originalWikitext = self::IMPERFECT_WIKITEXT;
@@ -748,7 +748,7 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
];
// should apply original data-mw when modified is absent (captions 1) ///////////
- $html = $this->getTextFromFile( 'Image.html' );
+ $html = self::getTextFromFile( 'Image.html' );
$dataParsoid = [ 'ids' => [
'mwAg' => [ 'optList' => [ [ 'ck' => 'caption', 'ak' => 'Testing 123' ] ] ],
'mwAw' => [ 'a' => [ 'href' => './File:Foobar.jpg' ], 'sa' => [] ],
@@ -783,7 +783,7 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
];
// should give precedence to inline data-mw over modified (captions 2) /////////////
- $htmlModified = $this->getTextFromFile( 'Image-data-mw.html' );
+ $htmlModified = self::getTextFromFile( 'Image-data-mw.html' );
$dataMediaWikiModified = [
'ids' => [
'mwAg' => [ 'caption' => 'Testing 123' ]
@@ -863,7 +863,7 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
];
// should apply version downgrade ///////////
- $htmlOfMinimal = $this->getTextFromFile( 'Minimal.html' ); // Uses profile version 2.4.0
+ $htmlOfMinimal = self::getTextFromFile( 'Minimal.html' ); // Uses profile version 2.4.0
$attribs = [
'opts' => [
'from' => ParsoidFormatHelper::FORMAT_PAGEBUNDLE,
@@ -888,7 +888,7 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
];
// should not apply version downgrade if versions are the same ///////////
- $htmlOfMinimal = $this->getTextFromFile( 'Minimal.html' ); // Uses profile version 2.4.0
+ $htmlOfMinimal = self::getTextFromFile( 'Minimal.html' ); // Uses profile version 2.4.0
$attribs = [
'opts' => [
'from' => ParsoidFormatHelper::FORMAT_PAGEBUNDLE,
@@ -912,7 +912,7 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
];
// should convert html to json ///////////////////////////////////
- $html = $this->getTextFromFile( 'JsonConfig.html' );
+ $html = self::getTextFromFile( 'JsonConfig.html' );
$expectedText = [
'{"a":4,"b":3}',
];
@@ -932,7 +932,7 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
];
// page bundle input should work with no original data present ///////////
- $htmlOfMinimal = $this->getTextFromFile( 'Minimal.html' ); // Uses profile version 2.4.0
+ $htmlOfMinimal = self::getTextFromFile( 'Minimal.html' ); // Uses profile version 2.4.0
$attribs = [
'opts' => [
'from' => ParsoidFormatHelper::FORMAT_PAGEBUNDLE,
@@ -1015,7 +1015,7 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
}
}
- public function provideHtml2wtThrows() {
+ public static function provideHtml2wtThrows() {
$html = '<html lang="en"><body>123</body></html>';
$profileVersion = '2.4.0';
@@ -1053,8 +1053,8 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
];
// should fail to downgrade the original version for an unknown transition ///////////
- $htmlOfMinimal = $this->getTextFromFile( 'Minimal.html' );
- $htmlOfMinimal2222 = $this->getTextFromFile( 'Minimal-2222.html' );
+ $htmlOfMinimal = self::getTextFromFile( 'Minimal.html' );
+ $htmlOfMinimal2222 = self::getTextFromFile( 'Minimal-2222.html' );
$attribs = [
'opts' => [
'from' => ParsoidFormatHelper::FORMAT_PAGEBUNDLE,
diff --git a/tests/phpunit/integration/includes/parser/Parsoid/LanguageVariantConverterTest.php b/tests/phpunit/integration/includes/parser/Parsoid/LanguageVariantConverterTest.php
index 8f9dc9de23a..f660b12bd3e 100644
--- a/tests/phpunit/integration/includes/parser/Parsoid/LanguageVariantConverterTest.php
+++ b/tests/phpunit/integration/includes/parser/Parsoid/LanguageVariantConverterTest.php
@@ -180,8 +180,8 @@ class LanguageVariantConverterTest extends MediaWikiIntegrationTestCase {
$this->assertEquals( Parsoid::defaultHTMLVersion(), $outputPageBundle->version );
}
- public function provideConvertParserOutputVariant() {
- foreach ( $this->provideConvertPageBundleVariant() as $name => $case ) {
+ public static function provideConvertParserOutputVariant() {
+ foreach ( self::provideConvertPageBundleVariant() as $name => $case ) {
$case[0] = PageBundleParserOutputConverter::parserOutputFromPageBundle( $case[0] );
yield $name => $case;
}
diff --git a/tests/phpunit/unit/includes/Permissions/RestrictionStoreTest.php b/tests/phpunit/unit/includes/Permissions/RestrictionStoreTest.php
index cdcfa663de0..6ec61bfd39b 100644
--- a/tests/phpunit/unit/includes/Permissions/RestrictionStoreTest.php
+++ b/tests/phpunit/unit/includes/Permissions/RestrictionStoreTest.php
@@ -211,8 +211,8 @@ class RestrictionStoreTest extends MediaWikiUnitTestCase {
$this->assertSame( $expected, $obj->getRestrictions( $page, $action ) );
}
- public function provideGetRestrictions(): array {
- $all = $this->provideGetAllRestrictions();
+ public static function provideGetRestrictions(): array {
+ $all = self::provideGetAllRestrictions();
$ret = [];
foreach ( $all as $name => $arr ) {
@@ -716,7 +716,7 @@ class RestrictionStoreTest extends MediaWikiUnitTestCase {
$this->assertSame( $expected, $obj->listApplicableRestrictionTypes( $page ) );
}
- public function provideListApplicableRestrictionTypes(): array {
+ public static function provideListApplicableRestrictionTypes(): array {
$expandedRestrictions = array_merge( self::DEFAULT_RESTRICTION_TYPES, [ 'liquify' ] );
return [
'Special page' => [
@@ -807,15 +807,15 @@ class RestrictionStoreTest extends MediaWikiUnitTestCase {
'Hook not run for special page' => [
[],
self::newImproperPageIdentity( NS_SPECIAL, 'X' ),
- [ 'hookFn' => function () {
- $this->fail( 'Should be unreached' );
+ [ 'hookFn' => static function () {
+ Assert::fail( 'Should be unreached' );
} ],
],
'Hook not run for media page' => [
[],
self::newImproperPageIdentity( NS_MEDIA, 'X' ),
- [ 'hookFn' => function () {
- $this->fail( 'Should be unreached' );
+ [ 'hookFn' => static function () {
+ Assert::fail( 'Should be unreached' );
} ],
],
];
diff --git a/tests/phpunit/unit/includes/Revision/MutableRevisionSlotsTest.php b/tests/phpunit/unit/includes/Revision/MutableRevisionSlotsTest.php
index 9f504bfd120..024f2e143f1 100644
--- a/tests/phpunit/unit/includes/Revision/MutableRevisionSlotsTest.php
+++ b/tests/phpunit/unit/includes/Revision/MutableRevisionSlotsTest.php
@@ -20,7 +20,7 @@ class MutableRevisionSlotsTest extends RevisionSlotsTest {
* @param SlotRecord[] $slots
* @return RevisionSlots
*/
- protected function newRevisionSlots( $slots = [] ) {
+ protected static function newRevisionSlots( $slots = [] ) {
return new MutableRevisionSlots( $slots );
}
diff --git a/tests/phpunit/unit/includes/Revision/RevisionSlotsTest.php b/tests/phpunit/unit/includes/Revision/RevisionSlotsTest.php
index 323254c341b..baeb22266eb 100644
--- a/tests/phpunit/unit/includes/Revision/RevisionSlotsTest.php
+++ b/tests/phpunit/unit/includes/Revision/RevisionSlotsTest.php
@@ -23,7 +23,7 @@ class RevisionSlotsTest extends MediaWikiUnitTestCase {
* @param string $text
* @return TextContent
*/
- protected function getTextContent( $text ) {
+ protected static function getTextContent( $text ) {
return new class( $text ) extends TextContent {
public function getContentHandler() {
return new TextContentHandler();
@@ -35,7 +35,7 @@ class RevisionSlotsTest extends MediaWikiUnitTestCase {
* @param SlotRecord[] $slots
* @return RevisionSlots
*/
- protected function newRevisionSlots( $slots = [] ) {
+ protected static function newRevisionSlots( $slots = [] ) {
return new RevisionSlots( $slots );
}
@@ -61,7 +61,7 @@ class RevisionSlotsTest extends MediaWikiUnitTestCase {
public function testGetSlot() {
$mainSlot = SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'A' ) );
$auxSlot = SlotRecord::newUnsaved( 'aux', new WikitextContent( 'B' ) );
- $slots = $this->newRevisionSlots( [ $mainSlot, $auxSlot ] );
+ $slots = self::newRevisionSlots( [ $mainSlot, $auxSlot ] );
$this->assertSame( $mainSlot, $slots->getSlot( SlotRecord::MAIN ) );
$this->assertSame( $auxSlot, $slots->getSlot( 'aux' ) );
@@ -72,7 +72,7 @@ class RevisionSlotsTest extends MediaWikiUnitTestCase {
public function testHasSlot() {
$mainSlot = SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'A' ) );
$auxSlot = SlotRecord::newUnsaved( 'aux', new WikitextContent( 'B' ) );
- $slots = $this->newRevisionSlots( [ $mainSlot, $auxSlot ] );
+ $slots = self::newRevisionSlots( [ $mainSlot, $auxSlot ] );
$this->assertTrue( $slots->hasSlot( SlotRecord::MAIN ) );
$this->assertTrue( $slots->hasSlot( 'aux' ) );
@@ -85,7 +85,7 @@ class RevisionSlotsTest extends MediaWikiUnitTestCase {
$auxContent = new WikitextContent( 'B' );
$mainSlot = SlotRecord::newUnsaved( SlotRecord::MAIN, $mainContent );
$auxSlot = SlotRecord::newUnsaved( 'aux', $auxContent );
- $slots = $this->newRevisionSlots( [ $mainSlot, $auxSlot ] );
+ $slots = self::newRevisionSlots( [ $mainSlot, $auxSlot ] );
$this->assertSame( $mainContent, $slots->getContent( SlotRecord::MAIN ) );
$this->assertSame( $auxContent, $slots->getContent( 'aux' ) );
@@ -96,13 +96,13 @@ class RevisionSlotsTest extends MediaWikiUnitTestCase {
public function testGetSlotRoles_someSlots() {
$mainSlot = SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'A' ) );
$auxSlot = SlotRecord::newUnsaved( 'aux', new WikitextContent( 'B' ) );
- $slots = $this->newRevisionSlots( [ $mainSlot, $auxSlot ] );
+ $slots = self::newRevisionSlots( [ $mainSlot, $auxSlot ] );
$this->assertSame( [ SlotRecord::MAIN, 'aux' ], $slots->getSlotRoles() );
}
public function testGetSlotRoles_noSlots() {
- $slots = $this->newRevisionSlots( [] );
+ $slots = self::newRevisionSlots( [] );
$this->assertSame( [], $slots->getSlotRoles() );
}
@@ -111,7 +111,7 @@ class RevisionSlotsTest extends MediaWikiUnitTestCase {
$mainSlot = SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'A' ) );
$auxSlot = SlotRecord::newUnsaved( 'aux', new WikitextContent( 'B' ) );
$slotsArray = [ $mainSlot, $auxSlot ];
- $slots = $this->newRevisionSlots( $slotsArray );
+ $slots = self::newRevisionSlots( $slotsArray );
$this->assertEquals( [ SlotRecord::MAIN => $mainSlot, 'aux' => $auxSlot ], $slots->getSlots() );
}
@@ -120,7 +120,7 @@ class RevisionSlotsTest extends MediaWikiUnitTestCase {
$mainSlot = SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'A' ) );
$auxSlot = SlotRecord::newDerived( 'aux', new WikitextContent( 'B' ) );
$slotsArray = [ $mainSlot, $auxSlot ];
- $slots = $this->newRevisionSlots( $slotsArray );
+ $slots = self::newRevisionSlots( $slotsArray );
$this->assertEquals( [ SlotRecord::MAIN => $mainSlot ], $slots->getPrimarySlots() );
}
@@ -134,7 +134,7 @@ class RevisionSlotsTest extends MediaWikiUnitTestCase {
)
);
$slotsArray = [ $mainSlot, $auxSlot ];
- $slots = $this->newRevisionSlots( $slotsArray );
+ $slots = self::newRevisionSlots( $slotsArray );
$this->assertEquals( [ 'aux' => $auxSlot ], $slots->getInheritedSlots() );
}
@@ -148,7 +148,7 @@ class RevisionSlotsTest extends MediaWikiUnitTestCase {
)
);
$slotsArray = [ $mainSlot, $auxSlot ];
- $slots = $this->newRevisionSlots( $slotsArray );
+ $slots = self::newRevisionSlots( $slotsArray );
$this->assertEquals( [ SlotRecord::MAIN => $mainSlot ], $slots->getOriginalSlots() );
}
@@ -167,7 +167,7 @@ class RevisionSlotsTest extends MediaWikiUnitTestCase {
foreach ( $contentStrings as $key => $contentString ) {
$slotsArray[] = SlotRecord::newUnsaved( strval( $key ), new WikitextContent( $contentString ) );
}
- $slots = $this->newRevisionSlots( $slotsArray );
+ $slots = self::newRevisionSlots( $slotsArray );
$this->assertSame( $expected, $slots->computeSize() );
}
@@ -188,26 +188,26 @@ class RevisionSlotsTest extends MediaWikiUnitTestCase {
foreach ( $contentStrings as $key => $contentString ) {
$slotsArray[] = SlotRecord::newUnsaved(
strval( $key ),
- $this->getTextContent( $contentString )
+ self::getTextContent( $contentString )
);
}
- $slots = $this->newRevisionSlots( $slotsArray );
+ $slots = self::newRevisionSlots( $slotsArray );
$this->assertSame( $expected, $slots->computeSha1() );
}
- public function provideHasSameContent() {
- $fooX = SlotRecord::newUnsaved( 'x', $this->getTextContent( 'Foo' ) );
- $barZ = SlotRecord::newUnsaved( 'z', $this->getTextContent( 'Bar' ) );
- $fooY = SlotRecord::newUnsaved( 'y', $this->getTextContent( 'Foo' ) );
+ public static function provideHasSameContent() {
+ $fooX = SlotRecord::newUnsaved( 'x', self::getTextContent( 'Foo' ) );
+ $barZ = SlotRecord::newUnsaved( 'z', self::getTextContent( 'Bar' ) );
+ $fooY = SlotRecord::newUnsaved( 'y', self::getTextContent( 'Foo' ) );
$barZS = SlotRecord::newSaved( 7, 7, 'xyz', $barZ );
- $barZ2 = SlotRecord::newUnsaved( 'z', $this->getTextContent( 'Baz' ) );
+ $barZ2 = SlotRecord::newUnsaved( 'z', self::getTextContent( 'Baz' ) );
- $a = $this->newRevisionSlots( [ 'x' => $fooX, 'z' => $barZ ] );
- $a2 = $this->newRevisionSlots( [ 'x' => $fooX, 'z' => $barZ ] );
- $a3 = $this->newRevisionSlots( [ 'x' => $fooX, 'z' => $barZS ] );
- $b = $this->newRevisionSlots( [ 'y' => $fooY, 'z' => $barZ ] );
- $c = $this->newRevisionSlots( [ 'x' => $fooX, 'z' => $barZ2 ] );
+ $a = self::newRevisionSlots( [ 'x' => $fooX, 'z' => $barZ ] );
+ $a2 = self::newRevisionSlots( [ 'x' => $fooX, 'z' => $barZ ] );
+ $a3 = self::newRevisionSlots( [ 'x' => $fooX, 'z' => $barZS ] );
+ $b = self::newRevisionSlots( [ 'y' => $fooY, 'z' => $barZ ] );
+ $c = self::newRevisionSlots( [ 'x' => $fooX, 'z' => $barZ2 ] );
yield 'same instance' => [ $a, $a, true ];
yield 'same slots' => [ $a, $a2, true ];
@@ -225,18 +225,18 @@ class RevisionSlotsTest extends MediaWikiUnitTestCase {
$this->assertSame( $same, $b->hasSameContent( $a ) );
}
- public function provideGetRolesWithDifferentContent() {
- $fooX = SlotRecord::newUnsaved( 'x', $this->getTextContent( 'Foo' ) );
- $barZ = SlotRecord::newUnsaved( 'z', $this->getTextContent( 'Bar' ) );
- $fooY = SlotRecord::newUnsaved( 'y', $this->getTextContent( 'Foo' ) );
+ public static function provideGetRolesWithDifferentContent() {
+ $fooX = SlotRecord::newUnsaved( 'x', self::getTextContent( 'Foo' ) );
+ $barZ = SlotRecord::newUnsaved( 'z', self::getTextContent( 'Bar' ) );
+ $fooY = SlotRecord::newUnsaved( 'y', self::getTextContent( 'Foo' ) );
$barZS = SlotRecord::newSaved( 7, 7, 'xyz', $barZ );
- $barZ2 = SlotRecord::newUnsaved( 'z', $this->getTextContent( 'Baz' ) );
+ $barZ2 = SlotRecord::newUnsaved( 'z', self::getTextContent( 'Baz' ) );
- $a = $this->newRevisionSlots( [ 'x' => $fooX, 'z' => $barZ ] );
- $a2 = $this->newRevisionSlots( [ 'x' => $fooX, 'z' => $barZ ] );
- $a3 = $this->newRevisionSlots( [ 'x' => $fooX, 'z' => $barZS ] );
- $b = $this->newRevisionSlots( [ 'y' => $fooY, 'z' => $barZ ] );
- $c = $this->newRevisionSlots( [ 'x' => $fooX, 'z' => $barZ2 ] );
+ $a = self::newRevisionSlots( [ 'x' => $fooX, 'z' => $barZ ] );
+ $a2 = self::newRevisionSlots( [ 'x' => $fooX, 'z' => $barZ ] );
+ $a3 = self::newRevisionSlots( [ 'x' => $fooX, 'z' => $barZS ] );
+ $b = self::newRevisionSlots( [ 'y' => $fooY, 'z' => $barZ ] );
+ $c = self::newRevisionSlots( [ 'x' => $fooX, 'z' => $barZ2 ] );
yield 'same instance' => [ $a, $a, [] ];
yield 'same slots' => [ $a, $a2, [] ];
diff --git a/tests/phpunit/unit/includes/Revision/SlotRecordTest.php b/tests/phpunit/unit/includes/Revision/SlotRecordTest.php
index b0e6ea3c8a9..c0599588ab7 100644
--- a/tests/phpunit/unit/includes/Revision/SlotRecordTest.php
+++ b/tests/phpunit/unit/includes/Revision/SlotRecordTest.php
@@ -15,7 +15,7 @@ use MediaWikiUnitTestCase;
*/
class SlotRecordTest extends MediaWikiUnitTestCase {
- private function makeRow( $data = [] ) {
+ private static function makeRow( $data = [] ) {
$data = $data + [
'slot_id' => 1234,
'slot_content_id' => 33,
@@ -32,7 +32,7 @@ class SlotRecordTest extends MediaWikiUnitTestCase {
}
public function testCompleteConstruction() {
- $row = $this->makeRow();
+ $row = self::makeRow();
$record = new SlotRecord( $row, new DummyContentForTesting( 'A' ) );
$this->assertTrue( $record->hasAddress() );
@@ -53,7 +53,7 @@ class SlotRecordTest extends MediaWikiUnitTestCase {
}
public function testConstructionDeferred() {
- $row = $this->makeRow( [
+ $row = self::makeRow( [
'content_size' => null, // to be computed
'content_sha1' => null, // to be computed
'format_name' => static function () {
@@ -131,11 +131,11 @@ class SlotRecordTest extends MediaWikiUnitTestCase {
$record->getAddress();
}
- public function provideIncomplete() {
+ public static function provideIncomplete() {
$unsaved = SlotRecord::newUnsaved( SlotRecord::MAIN, new DummyContentForTesting( 'A' ) );
yield 'unsaved' => [ $unsaved ];
- $parent = new SlotRecord( $this->makeRow(), new DummyContentForTesting( 'A' ) );
+ $parent = new SlotRecord( self::makeRow(), new DummyContentForTesting( 'A' ) );
$inherited = SlotRecord::newInherited( $parent );
yield 'inherited' => [ $inherited ];
}
@@ -178,7 +178,7 @@ class SlotRecordTest extends MediaWikiUnitTestCase {
}
public function testHashComputed() {
- $row = $this->makeRow();
+ $row = self::makeRow();
$row->content_sha1 = '';
$rec = new SlotRecord( $row, new DummyContentForTesting( 'A' ) );
@@ -186,7 +186,7 @@ class SlotRecordTest extends MediaWikiUnitTestCase {
}
public function testNewWithSuppressedContent() {
- $input = new SlotRecord( $this->makeRow(), new DummyContentForTesting( 'A' ) );
+ $input = new SlotRecord( self::makeRow(), new DummyContentForTesting( 'A' ) );
$output = SlotRecord::newWithSuppressedContent( $input );
$this->expectException( SuppressedDataException::class );
@@ -194,7 +194,7 @@ class SlotRecordTest extends MediaWikiUnitTestCase {
}
public function testNewInherited() {
- $row = $this->makeRow( [ 'slot_revision_id' => 7, 'slot_origin' => 7 ] );
+ $row = self::makeRow( [ 'slot_revision_id' => 7, 'slot_origin' => 7 ] );
$parent = new SlotRecord( $row, new DummyContentForTesting( 'A' ) );
// This would happen while doing an edit, before saving revision meta-data.
@@ -259,8 +259,8 @@ class SlotRecordTest extends MediaWikiUnitTestCase {
$this->assertFalse( $unsaved->isDerived() );
}
- public function provideNewSaved_LogicException() {
- $freshRow = $this->makeRow( [
+ public static function provideNewSaved_LogicException() {
+ $freshRow = self::makeRow( [
'content_id' => 10,
'content_address' => 'address:1',
'slot_origin' => 1,
@@ -272,7 +272,7 @@ class SlotRecordTest extends MediaWikiUnitTestCase {
yield 'mismatching revision' => [ 5, 10, 'address:1', $freshSlot ];
yield 'mismatching content ID' => [ 1, 17, 'address:1', $freshSlot ];
- $inheritedRow = $this->makeRow( [
+ $inheritedRow = self::makeRow( [
'content_id' => null,
'content_address' => null,
'slot_origin' => 0,
@@ -296,13 +296,13 @@ class SlotRecordTest extends MediaWikiUnitTestCase {
SlotRecord::newSaved( $revisionId, $contentId, $contentAddress, $protoSlot );
}
- public function provideHasSameContent() {
+ public static function provideHasSameContent() {
$fail = static function () {
self::fail( 'There should be no need to actually load the content.' );
};
$a100a1 = new SlotRecord(
- $this->makeRow(
+ self::makeRow(
[
'model_name' => 'A',
'content_size' => 100,
@@ -313,7 +313,7 @@ class SlotRecordTest extends MediaWikiUnitTestCase {
$fail
);
$a100a1b = new SlotRecord(
- $this->makeRow(
+ self::makeRow(
[
'model_name' => 'A',
'content_size' => 100,
@@ -324,7 +324,7 @@ class SlotRecordTest extends MediaWikiUnitTestCase {
$fail
);
$a100null = new SlotRecord(
- $this->makeRow(
+ self::makeRow(
[
'model_name' => 'A',
'content_size' => 100,
@@ -335,7 +335,7 @@ class SlotRecordTest extends MediaWikiUnitTestCase {
$fail
);
$a100a2 = new SlotRecord(
- $this->makeRow(
+ self::makeRow(
[
'model_name' => 'A',
'content_size' => 100,
@@ -346,7 +346,7 @@ class SlotRecordTest extends MediaWikiUnitTestCase {
$fail
);
$b100a1 = new SlotRecord(
- $this->makeRow(
+ self::makeRow(
[
'model_name' => 'B',
'content_size' => 100,
@@ -357,7 +357,7 @@ class SlotRecordTest extends MediaWikiUnitTestCase {
$fail
);
$a200a1 = new SlotRecord(
- $this->makeRow(
+ self::makeRow(
[
'model_name' => 'A',
'content_size' => 200,
@@ -368,7 +368,7 @@ class SlotRecordTest extends MediaWikiUnitTestCase {
$fail
);
$a100x1 = new SlotRecord(
- $this->makeRow(
+ self::makeRow(
[
'model_name' => 'A',
'content_size' => 100,
diff --git a/tests/phpunit/unit/includes/Storage/EditResultBuilderTest.php b/tests/phpunit/unit/includes/Storage/EditResultBuilderTest.php
index 7230b841661..f849c69d8a0 100644
--- a/tests/phpunit/unit/includes/Storage/EditResultBuilderTest.php
+++ b/tests/phpunit/unit/includes/Storage/EditResultBuilderTest.php
@@ -121,10 +121,10 @@ class EditResultBuilderTest extends MediaWikiUnitTestCase {
$this->assertArrayEquals( [], $er->getRevertTags(), 'EditResult::getRevertTags' );
}
- public function provideEnabledSoftwareTagsForRollback(): array {
+ public static function provideEnabledSoftwareTagsForRollback(): array {
return [
"all change tags enabled" => [
- $this->getSoftwareTags(),
+ self::getSoftwareTags(),
[ "mw-rollback" ]
],
"no change tags enabled" => [
@@ -179,10 +179,10 @@ class EditResultBuilderTest extends MediaWikiUnitTestCase {
'EditResult::getRevertTags' );
}
- public function provideEnabledSoftwareTagsForUndo(): array {
+ public static function provideEnabledSoftwareTagsForUndo(): array {
return [
"all change tags enabled" => [
- $this->getSoftwareTags(),
+ self::getSoftwareTags(),
[ "mw-undo" ]
],
"no change tags enabled" => [
@@ -268,7 +268,7 @@ class EditResultBuilderTest extends MediaWikiUnitTestCase {
public function testRevertWithoutOriginalRevision() {
$erb = $this->getNewEditResultBuilder(
null,
- $this->getSoftwareTags()
+ self::getSoftwareTags()
);
$newRevision = $this->getDummyRevision();
@@ -301,7 +301,7 @@ class EditResultBuilderTest extends MediaWikiUnitTestCase {
public function testManualRevertDetectionDisabled() {
$erb = $this->getNewEditResultBuilder(
null,
- $this->getSoftwareTags(),
+ self::getSoftwareTags(),
0 // set the search radius to 0 to disable the feature entirely
);
$newRevision = $this->getDummyRevision();
@@ -391,7 +391,7 @@ class EditResultBuilderTest extends MediaWikiUnitTestCase {
*
* @return string[]
*/
- private function getSoftwareTags(): array {
+ private static function getSoftwareTags(): array {
return [
"mw-contentmodelchange",
"mw-new-redirect",
diff --git a/tests/phpunit/unit/includes/debug/DeprecatablePropertyArrayTest.php b/tests/phpunit/unit/includes/debug/DeprecatablePropertyArrayTest.php
index 7582210e164..c8a641a013e 100644
--- a/tests/phpunit/unit/includes/debug/DeprecatablePropertyArrayTest.php
+++ b/tests/phpunit/unit/includes/debug/DeprecatablePropertyArrayTest.php
@@ -1,6 +1,7 @@
<?php
use MediaWiki\Debug\DeprecatablePropertyArray;
+use PHPUnit\Framework\Assert;
/**
* @covers \MediaWiki\Debug\DeprecatablePropertyArray
@@ -17,7 +18,7 @@ class DeprecatablePropertyArrayTest extends MediaWikiUnitTestCase {
$callback();
}
- public function provideDeprecationWarning() {
+ public static function provideDeprecationWarning() {
$propName = self::PROP_NAME;
$array = new DeprecatablePropertyArray(
[
@@ -34,20 +35,20 @@ class DeprecatablePropertyArrayTest extends MediaWikiUnitTestCase {
);
yield 'get' => [
- function () use ( $array ) {
- $this->assertSame( 'test_value', $array[ self::PROP_NAME ] );
+ static function () use ( $array ) {
+ Assert::assertSame( 'test_value', $array[ self::PROP_NAME ] );
},
"TEST get '{$propName}'"
];
yield 'get, callback' => [
- function () use ( $array ) {
- $this->assertSame( 'callback_test_value', $array[ 'callback' ] );
+ static function () use ( $array ) {
+ Assert::assertSame( 'callback_test_value', $array[ 'callback' ] );
},
"TEST get 'callback'"
];
yield 'exists' => [
- function () use ( $array ) {
- $this->assertTrue( isset( $array[ self::PROP_NAME ] ) );
+ static function () use ( $array ) {
+ Assert::assertTrue( isset( $array[ self::PROP_NAME ] ) );
},
"TEST exists '{$propName}'"
];
diff --git a/tests/phpunit/unit/includes/libs/ArrayUtilsTest.php b/tests/phpunit/unit/includes/libs/ArrayUtilsTest.php
index a4b1c448703..3a1a2da00da 100644
--- a/tests/phpunit/unit/includes/libs/ArrayUtilsTest.php
+++ b/tests/phpunit/unit/includes/libs/ArrayUtilsTest.php
@@ -3,6 +3,7 @@
namespace Wikimedia\Tests;
use MediaWikiCoversValidator;
+use PHPUnit\Framework\Assert;
use PHPUnit\Framework\TestCase;
use Wikimedia\ArrayUtils\ArrayUtils;
@@ -27,11 +28,11 @@ class ArrayUtilsTest extends TestCase {
);
}
- public function provideFindLowerBound() {
- $indexValueCallback = function ( $size ) {
- return function ( $val ) use ( $size ) {
- $this->assertTrue( $val >= 0 );
- $this->assertTrue( $val < $size );
+ public static function provideFindLowerBound() {
+ $indexValueCallback = static function ( $size ) {
+ return static function ( $val ) use ( $size ) {
+ Assert::assertTrue( $val >= 0 );
+ Assert::assertTrue( $val < $size );
return $val;
};
};
diff --git a/tests/phpunit/unit/includes/libs/GhostFieldAccessTraitTest.php b/tests/phpunit/unit/includes/libs/GhostFieldAccessTraitTest.php
index 4042fb353d6..9a20949815a 100644
--- a/tests/phpunit/unit/includes/libs/GhostFieldAccessTraitTest.php
+++ b/tests/phpunit/unit/includes/libs/GhostFieldAccessTraitTest.php
@@ -26,8 +26,8 @@ class GhostFieldAccessTraitTest extends MediaWikiUnitTestCase {
}
}
- public function provideUnserializedInstancesWithValues() {
- return $this->provideUnserializedInstances( 'withValues' );
+ public static function provideUnserializedInstancesWithValues() {
+ return self::provideUnserializedInstances( 'withValues' );
}
/**
@@ -39,8 +39,8 @@ class GhostFieldAccessTraitTest extends MediaWikiUnitTestCase {
$this->assertSame( 'public_value', $instance->getPublicField() );
}
- public function provideUnserializedInstancesWithNulls() {
- return $this->provideUnserializedInstances( 'withNulls' );
+ public static function provideUnserializedInstancesWithNulls() {
+ return self::provideUnserializedInstances( 'withNulls' );
}
/**
diff --git a/tests/phpunit/unit/includes/parser/Parsoid/PageBundleParserOutputConverterTest.php b/tests/phpunit/unit/includes/parser/Parsoid/PageBundleParserOutputConverterTest.php
index 2d1963d7cde..f58e6e931e7 100644
--- a/tests/phpunit/unit/includes/parser/Parsoid/PageBundleParserOutputConverterTest.php
+++ b/tests/phpunit/unit/includes/parser/Parsoid/PageBundleParserOutputConverterTest.php
@@ -135,9 +135,9 @@ class PageBundleParserOutputConverterTest extends MediaWikiUnitTestCase {
}
}
- public function providePageBundleFromParserOutput() {
+ public static function providePageBundleFromParserOutput() {
yield 'should convert ParsoidOutput containing data-parsoid and data-mw' => [
- $this->getParsoidOutput(
+ self::getParsoidOutput(
'hello world',
[
'parsoid' => [ 'ids' => '1.22' ],
@@ -150,7 +150,7 @@ class PageBundleParserOutputConverterTest extends MediaWikiUnitTestCase {
];
yield 'should convert ParsoidOutput that does not contain data-parsoid or data-mw' => [
- $this->getParsoidOutput(
+ self::getParsoidOutput(
'hello world',
[
'parsoid' => null,
@@ -170,7 +170,7 @@ class PageBundleParserOutputConverterTest extends MediaWikiUnitTestCase {
$this->assertEquals( 'de', $pb->headers['content-language'] );
}
- private function getParsoidOutput(
+ private static function getParsoidOutput(
string $rawText,
?array $pageBundleData
): ParserOutput {
diff --git a/tests/phpunit/unit/includes/registration/ExtensionProcessorTest.php b/tests/phpunit/unit/includes/registration/ExtensionProcessorTest.php
index 71a136e53da..809856738ea 100644
--- a/tests/phpunit/unit/includes/registration/ExtensionProcessorTest.php
+++ b/tests/phpunit/unit/includes/registration/ExtensionProcessorTest.php
@@ -302,7 +302,7 @@ class ExtensionProcessorTest extends MediaWikiUnitTestCase {
$this->assertNotContains( 'test2', $extracted['globals']['wgImplicitRights'] );
}
- public function provideMixedStyleHooks() {
+ public static function provideMixedStyleHooks() {
// Format:
// Content in extension.json
// Expected wgHooks
@@ -339,7 +339,7 @@ class ExtensionProcessorTest extends MediaWikiUnitTestCase {
'services' => [],
'name' => 'FooBar-HandlerObjectCallback'
],
- 'extensionPath' => $this->getExtensionPath()
+ 'extensionPath' => self::getExtensionPath()
],
[
'handler' => [
@@ -348,7 +348,7 @@ class ExtensionProcessorTest extends MediaWikiUnitTestCase {
'name' => 'FooBar-HandlerObjectCallback'
],
'deprecated' => true,
- 'extensionPath' => $this->getExtensionPath()
+ 'extensionPath' => self::getExtensionPath()
],
[
'handler' => [
@@ -356,7 +356,7 @@ class ExtensionProcessorTest extends MediaWikiUnitTestCase {
'services' => [],
'name' => 'FooBar-HandlerObjectCallback'
],
- 'extensionPath' => $this->getExtensionPath()
+ 'extensionPath' => self::getExtensionPath()
]
]
]
@@ -364,7 +364,7 @@ class ExtensionProcessorTest extends MediaWikiUnitTestCase {
];
}
- public function provideNonLegacyHooks() {
+ public static function provideNonLegacyHooks() {
// Format:
// Current Hooks attribute
// Content in extension.json
@@ -393,7 +393,7 @@ class ExtensionProcessorTest extends MediaWikiUnitTestCase {
'name' => 'FooBar-HandlerObjectCallback'
],
'deprecated' => true,
- 'extensionPath' => $this->getExtensionPath()
+ 'extensionPath' => self::getExtensionPath()
]
]
],
@@ -417,7 +417,7 @@ class ExtensionProcessorTest extends MediaWikiUnitTestCase {
'services' => [],
'name' => 'FooBar-HandlerObjectCallback'
],
- 'extensionPath' => $this->getExtensionPath()
+ 'extensionPath' => self::getExtensionPath()
],
]
],
@@ -446,7 +446,7 @@ class ExtensionProcessorTest extends MediaWikiUnitTestCase {
'services' => []
],
'deprecated' => true,
- 'extensionPath' => $this->getExtensionPath()
+ 'extensionPath' => self::getExtensionPath()
],
[
'handler' => [
@@ -454,7 +454,7 @@ class ExtensionProcessorTest extends MediaWikiUnitTestCase {
'class' => 'FooClass',
'services' => [],
],
- 'extensionPath' => $this->getExtensionPath()
+ 'extensionPath' => self::getExtensionPath()
]
]
],
@@ -482,7 +482,7 @@ class ExtensionProcessorTest extends MediaWikiUnitTestCase {
'class' => 'FooClass',
'services' => []
],
- 'extensionPath' => $this->getExtensionPath()
+ 'extensionPath' => self::getExtensionPath()
],
]
],
@@ -596,7 +596,7 @@ class ExtensionProcessorTest extends MediaWikiUnitTestCase {
$processor->getExtractedInfo();
}
- public function provideDomainEventDomainEventIngresses() {
+ public static function provideDomainEventDomainEventIngresses() {
// Format:
// Current attributes
// Content in extension.json
@@ -623,7 +623,7 @@ class ExtensionProcessorTest extends MediaWikiUnitTestCase {
'events' => [ 'FooDone', 'BarDone', ],
'class' => 'FooClass',
'services' => [],
- 'extensionPath' => $this->getExtensionPath()
+ 'extensionPath' => self::getExtensionPath()
]
]
],
diff --git a/tests/phpunit/unit/includes/skins/components/SkinComponentTableOfContentsTest.php b/tests/phpunit/unit/includes/skins/components/SkinComponentTableOfContentsTest.php
index 12180ec7766..245eea9418c 100644
--- a/tests/phpunit/unit/includes/skins/components/SkinComponentTableOfContentsTest.php
+++ b/tests/phpunit/unit/includes/skins/components/SkinComponentTableOfContentsTest.php
@@ -11,11 +11,11 @@ use Wikimedia\Parsoid\Core\TOCData;
*/
class SkinComponentTableOfContentsTest extends MediaWikiUnitTestCase {
- private function addDefaults( array $sectionData ): array {
+ private static function addDefaults( array $sectionData ): array {
return SectionMetadata::fromLegacy( $sectionData )->toLegacy();
}
- public function provideGetSectionsData(): array {
+ public static function provideGetSectionsData(): array {
// byteoffset and fromtitle are redacted from this test.
$SECTION_1 = [
'toclevel' => 1,
@@ -69,12 +69,12 @@ class SkinComponentTableOfContentsTest extends MediaWikiUnitTestCase {
[
'number-section-count' => 2,
'array-sections' => [
- $this->addDefaults( $SECTION_1 ) + [
+ self::addDefaults( $SECTION_1 ) + [
'array-sections' => [],
'is-top-level-section' => true,
'is-parent-section' => false,
],
- $this->addDefaults( $SECTION_2 ) + [
+ self::addDefaults( $SECTION_2 ) + [
'array-sections' => [],
'is-top-level-section' => true,
'is-parent-section' => false,
@@ -95,9 +95,9 @@ class SkinComponentTableOfContentsTest extends MediaWikiUnitTestCase {
[
'number-section-count' => 3,
'array-sections' => [
- $this->addDefaults( $SECTION_1 ) + [
+ self::addDefaults( $SECTION_1 ) + [
'array-sections' => [
- $this->addDefaults( $SECTION_1_1 ) + [
+ self::addDefaults( $SECTION_1_1 ) + [
'array-sections' => [],
'is-top-level-section' => false,
'is-parent-section' => false,
@@ -106,7 +106,7 @@ class SkinComponentTableOfContentsTest extends MediaWikiUnitTestCase {
'is-top-level-section' => true,
'is-parent-section' => true,
],
- $this->addDefaults( $SECTION_2 ) + [
+ self::addDefaults( $SECTION_2 ) + [
'array-sections' => [],
'is-top-level-section' => true,
'is-parent-section' => false,
@@ -130,16 +130,16 @@ class SkinComponentTableOfContentsTest extends MediaWikiUnitTestCase {
[
'number-section-count' => 6,
'array-sections' => [
- $this->addDefaults( $SECTION_1 ) + [
+ self::addDefaults( $SECTION_1 ) + [
'array-sections' => [
- $this->addDefaults( $SECTION_1_1 ) + [
+ self::addDefaults( $SECTION_1_1 ) + [
'array-sections' => [],
'is-top-level-section' => false,
'is-parent-section' => false,
],
- $this->addDefaults( $SECTION_1_2 ) + [
+ self::addDefaults( $SECTION_1_2 ) + [
'array-sections' => [
- $this->addDefaults( $SECTION_1_2_1 ) + [
+ self::addDefaults( $SECTION_1_2_1 ) + [
'array-sections' => [],
'is-top-level-section' => false,
'is-parent-section' => false,
@@ -148,7 +148,7 @@ class SkinComponentTableOfContentsTest extends MediaWikiUnitTestCase {
'is-top-level-section' => false,
'is-parent-section' => true,
],
- $this->addDefaults( $SECTION_1_3 ) + [
+ self::addDefaults( $SECTION_1_3 ) + [
'array-sections' => [],
'is-top-level-section' => false,
'is-parent-section' => false,
@@ -157,7 +157,7 @@ class SkinComponentTableOfContentsTest extends MediaWikiUnitTestCase {
'is-top-level-section' => true,
'is-parent-section' => true,
],
- $this->addDefaults( $SECTION_2 ) + [
+ self::addDefaults( $SECTION_2 ) + [
'array-sections' => [],
'is-top-level-section' => true,
'is-parent-section' => false,
diff --git a/tests/phpunit/unit/includes/title/TitleArrayFromResultTest.php b/tests/phpunit/unit/includes/title/TitleArrayFromResultTest.php
index bf3493f203f..c08d8ce0e0e 100644
--- a/tests/phpunit/unit/includes/title/TitleArrayFromResultTest.php
+++ b/tests/phpunit/unit/includes/title/TitleArrayFromResultTest.php
@@ -20,7 +20,7 @@ class TitleArrayFromResultTest extends MediaWikiUnitTestCase {
return $resultWrapper;
}
- private function getRowWithTitle( $namespace = 3, $title = 'foo' ) {
+ private static function getRowWithTitle( $namespace = 3, $title = 'foo' ) {
return (object)[
'page_namespace' => $namespace,
'page_title' => $title,
@@ -47,7 +47,7 @@ class TitleArrayFromResultTest extends MediaWikiUnitTestCase {
public function testConstructionWithRow() {
$namespace = 0;
$title = 'foo';
- $row = $this->getRowWithTitle( $namespace, $title );
+ $row = self::getRowWithTitle( $namespace, $title );
$resultWrapper = $this->getMockResultWrapper( $row );
$object = new TitleArrayFromResult( $resultWrapper );
@@ -73,7 +73,7 @@ class TitleArrayFromResultTest extends MediaWikiUnitTestCase {
*/
public function testCountWithVaryingValues( $numRows ) {
$object = new TitleArrayFromResult( $this->getMockResultWrapper(
- $this->getRowWithTitle(),
+ self::getRowWithTitle(),
$numRows
) );
$this->assertEquals( $numRows, $object->count() );
@@ -85,16 +85,16 @@ class TitleArrayFromResultTest extends MediaWikiUnitTestCase {
public function testCurrentAfterConstruction() {
$namespace = 0;
$title = 'foo';
- $row = $this->getRowWithTitle( $namespace, $title );
+ $row = self::getRowWithTitle( $namespace, $title );
$object = new TitleArrayFromResult( $this->getMockResultWrapper( $row ) );
$this->assertInstanceOf( Title::class, $object->current() );
$this->assertEquals( $namespace, $object->current->getNamespace() );
$this->assertEquals( $title, $object->current->getText() );
}
- public function provideTestValid() {
+ public static function provideTestValid() {
return [
- [ $this->getRowWithTitle(), true ],
+ [ self::getRowWithTitle(), true ],
[ false, false ],
];
}
diff --git a/tests/phpunit/unit/includes/title/TitleTest.php b/tests/phpunit/unit/includes/title/TitleTest.php
index 7b674bd6075..ddf5e8a7eae 100644
--- a/tests/phpunit/unit/includes/title/TitleTest.php
+++ b/tests/phpunit/unit/includes/title/TitleTest.php
@@ -195,8 +195,8 @@ class TitleTest extends MediaWikiUnitTestCase {
$this->assertTrue( $clone->equals( $title ) );
}
- public function provideCastFromLinkTarget() {
- return array_merge( [ [ null ] ], $this->provideNewFromTitleValue() );
+ public static function provideCastFromLinkTarget() {
+ return array_merge( [ [ null ] ], self::provideNewFromTitleValue() );
}
/**
diff --git a/tests/phpunit/unit/includes/user/UserArrayFromResultTest.php b/tests/phpunit/unit/includes/user/UserArrayFromResultTest.php
index c24336c5876..25e0a0ef991 100644
--- a/tests/phpunit/unit/includes/user/UserArrayFromResultTest.php
+++ b/tests/phpunit/unit/includes/user/UserArrayFromResultTest.php
@@ -23,7 +23,7 @@ class UserArrayFromResultTest extends \MediaWikiUnitTestCase {
return $resultWrapper;
}
- private function getRowWithUsername( string $username = 'fooUser' ): stdClass {
+ private static function getRowWithUsername( string $username = 'fooUser' ): stdClass {
return (object)[ 'user_name' => $username ];
}
@@ -39,7 +39,7 @@ class UserArrayFromResultTest extends \MediaWikiUnitTestCase {
public function testConstructionWithRow() {
$username = 'addshore';
- $row = $this->getRowWithUsername( $username );
+ $row = self::getRowWithUsername( $username );
$resultWrapper = $this->getMockResultWrapper( $row );
$object = new UserArrayFromResult( $resultWrapper );
@@ -63,7 +63,7 @@ class UserArrayFromResultTest extends \MediaWikiUnitTestCase {
*/
public function testCountWithVaryingValues( int $numRows ) {
$object = new UserArrayFromResult( $this->getMockResultWrapper(
- $this->getRowWithUsername(),
+ self::getRowWithUsername(),
$numRows
) );
$this->assertEquals( $numRows, $object->count() );
@@ -71,15 +71,15 @@ class UserArrayFromResultTest extends \MediaWikiUnitTestCase {
public function testCurrentAfterConstruction() {
$username = 'addshore';
- $userRow = $this->getRowWithUsername( $username );
+ $userRow = self::getRowWithUsername( $username );
$object = new UserArrayFromResult( $this->getMockResultWrapper( $userRow ) );
$this->assertInstanceOf( User::class, $object->current() );
$this->assertEquals( $username, $object->current()->mName );
}
- public function provideTestValid() {
+ public static function provideTestValid() {
return [
- [ $this->getRowWithUsername(), true ],
+ [ self::getRowWithUsername(), true ],
[ false, false ],
];
}
@@ -92,10 +92,10 @@ class UserArrayFromResultTest extends \MediaWikiUnitTestCase {
$this->assertSame( $expected, $object->valid() );
}
- public function provideTestKey() {
+ public static function provideTestKey() {
return [
- [ $this->getRowWithUsername(), 0 ],
- [ $this->getRowWithUsername( 'xSavitar' ), 0 ],
+ [ self::getRowWithUsername(), 0 ],
+ [ self::getRowWithUsername( 'xSavitar' ), 0 ],
[ (object)[], 0 ],
[ false, 0 ],
];
@@ -111,7 +111,7 @@ class UserArrayFromResultTest extends \MediaWikiUnitTestCase {
public function testNextOnce() {
$object = new UserArrayFromResult(
- $this->getMockResultWrapper( $this->getRowWithUsername() )
+ $this->getMockResultWrapper( self::getRowWithUsername() )
);
$object->next();
$this->assertSame( 1, $object->key() );
@@ -119,7 +119,7 @@ class UserArrayFromResultTest extends \MediaWikiUnitTestCase {
public function testNextTwice() {
$object = new UserArrayFromResult(
- $this->getMockResultWrapper( $this->getRowWithUsername() )
+ $this->getMockResultWrapper( self::getRowWithUsername() )
);
$object->next(); // once
$object->next(); // twice
@@ -128,7 +128,7 @@ class UserArrayFromResultTest extends \MediaWikiUnitTestCase {
public function testRewind() {
$object = new UserArrayFromResult(
- $this->getMockResultWrapper( $this->getRowWithUsername() )
+ $this->getMockResultWrapper( self::getRowWithUsername() )
);
$object->next();
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Jul 5, 5:31 AM (8 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
227476
Default Alt Text
(88 KB)
Attached To
Mode
rMW mediawiki
Attached
Detach File
Event Timeline
Log In to Comment