Minor cleanup

Change-Id: I0b8abdbeaece73fe8759ee220b9a3aefce240e68
This commit is contained in:
Reedy 2022-09-07 02:48:18 +01:00
parent 67f13d5cdd
commit 89d3f6152b
5 changed files with 33 additions and 21 deletions

View file

@ -141,7 +141,7 @@ class Database {
);
$result = [];
foreach ( $rows as $row ) {
$error = $this->makeLintError( $row );
$error = self::makeLintError( $row );
if ( !$error ) {
continue;
}

View file

@ -26,7 +26,7 @@ use MediaWikiIntegrationTestCase;
/**
* @group Database
* @covers MediaWiki\Linter\Database
* @covers \MediaWiki\Linter\Database
*/
class DatabaseTest extends MediaWikiIntegrationTestCase {
public function testConstructor() {
@ -112,7 +112,7 @@ class DatabaseTest extends MediaWikiIntegrationTestCase {
// For error counts <= MAX_ACCURATE_COUNT, both error
// count methods should return the same count.
self::createManyLintErrors( $lintDb, Database::MAX_ACCURATE_COUNT );
$this->createManyLintErrors( $lintDb, Database::MAX_ACCURATE_COUNT );
$resultTotals = $lintDb->getTotalsForPage();
$resultEstimatedTotals = $lintDb->getTotals();
$this->assertEquals( $resultTotals, $resultEstimatedTotals );
@ -126,7 +126,7 @@ class DatabaseTest extends MediaWikiIntegrationTestCase {
// // count methods should NOT return the same count in this test scenario
// // because previously added and deleted records will be included
// // in the estimated count which is normal.
// self::createManyLintErrors( $lintDb, Database::MAX_ACCURATE_COUNT + 1 );
// $this->createManyLintErrors( $lintDb, Database::MAX_ACCURATE_COUNT + 1 );
// $resultTotals = $lintDb->getTotalsForPage();
// $resultEstimatedTotals = $lintDb->getTotals();
// $this->assertNotEquals( $resultTotals, $resultEstimatedTotals );
@ -135,7 +135,7 @@ class DatabaseTest extends MediaWikiIntegrationTestCase {
// // count method should return a greater count in this test scenario
// // because previously added and deleted records will be included
// // in the estimated count which is normal.
// self::createManyLintErrors( $lintDb, Database::MAX_ACCURATE_COUNT * 10 );
// $this->createManyLintErrors( $lintDb, Database::MAX_ACCURATE_COUNT * 10 );
// $resultTotals = $lintDb->getTotalsForPage();
// $resultEstimatedTotals = $lintDb->getTotals();
// $this->assertGreaterThan( $resultTotals, $resultEstimatedTotals );

View file

@ -24,15 +24,16 @@ use ContentHandler;
use MediaWiki\Linter\Database;
use MediaWiki\Linter\LintError;
use MediaWiki\Linter\RecordLintJob;
use MediaWikiIntegrationTestCase;
use stdClass;
use Title;
use User;
/**
* @group Database
* @covers MediaWiki\Linter\RecordLintJob
* @covers \MediaWiki\Linter\RecordLintJob
*/
class RecordLintJobTest extends \MediaWikiIntegrationTestCase {
class RecordLintJobTest extends MediaWikiIntegrationTestCase {
/**
* @param string $titleText
* @return array
@ -122,8 +123,10 @@ class RecordLintJobTest extends \MediaWikiIntegrationTestCase {
$error = [
'type' => 'obsolete-tag',
'location' => [ 0, 10 ],
'params' => [ "name" => "center",
"templateInfo" => [ "name" => "Template:Echo" ] ],
'params' => [
"name" => "center",
"templateInfo" => [ "name" => "Template:Echo" ]
],
'dbid' => null,
];
$titleAndPage = $this->createTitleAndPage( 'TestPage2' );

View file

@ -21,19 +21,21 @@
namespace MediaWiki\Linter\Test;
use ContentHandler;
use Exception;
use FauxRequest;
use MediaWiki\Linter\CategoryManager;
use MediaWiki\Linter\Database;
use MediaWiki\Linter\LintError;
use MediaWiki\Linter\RecordLintJob;
use MediaWiki\Linter\SpecialLintErrors;
use SpecialPageTestBase;
use Title;
use User;
/**
* @covers MediaWiki\Linter\SpecialLintErrors
* @covers \MediaWiki\Linter\SpecialLintErrors
*/
class SpecialLintErrorsTest extends \SpecialPageTestBase {
class SpecialLintErrorsTest extends SpecialPageTestBase {
protected function newSpecialPage() {
return new SpecialLintErrors();
@ -190,19 +192,25 @@ class SpecialLintErrorsTest extends \SpecialPageTestBase {
private function createTitleAndPageAndLintErrorData(): array {
$pageData = [];
$pageData[] = [ 'name' => 'Lint Error One', 'ns' => 0,
'lintErrors' => [ [ 'type' => 'obsolete-tag', 'location' => [ 0, 10 ] ],
[ 'type' => 'misnested-tag', 'location' => [ 20, 30 ] ] ]
'lintErrors' => [
[ 'type' => 'obsolete-tag', 'location' => [ 0, 10 ] ],
[ 'type' => 'misnested-tag', 'location' => [ 20, 30 ] ]
]
];
$pageData[] = [ 'name' => 'LintErrorTwo', 'ns' => 3,
'lintErrors' => [ [ 'type' => 'obsolete-tag', 'location' => [ 0, 10 ] ] ]
];
$pageData[] = [ 'name' => 'NotANamespace:LintErrorThree', 'ns' => 0,
'lintErrors' => [ [ 'type' => 'obsolete-tag', 'location' => [ 0, 10 ] ],
[ 'type' => 'misnested-tag', 'location' => [ 20, 30 ] ] ]
'lintErrors' => [
[ 'type' => 'obsolete-tag', 'location' => [ 0, 10 ] ],
[ 'type' => 'misnested-tag', 'location' => [ 20, 30 ] ]
]
];
$pageData[] = [ 'name' => 'NotANamespace:LintErrorFour', 'ns' => 0,
'lintErrors' => [ [ 'type' => 'obsolete-tag', 'location' => [ 0, 10 ] ],
[ 'type' => 'misnested-tag', 'location' => [ 20, 30 ] ] ]
'lintErrors' => [
[ 'type' => 'obsolete-tag', 'location' => [ 0, 10 ] ],
[ 'type' => 'misnested-tag', 'location' => [ 20, 30 ] ]
]
];
$pageData[] = [ 'name' => 'Some other page', 'ns' => 0,
'lintErrors' => [ [ 'type' => 'bogus-image-options', 'location' => [ 30, 40 ] ] ]
@ -325,7 +333,7 @@ class SpecialLintErrorsTest extends \SpecialPageTestBase {
* @param string|null $subPage
* @param string $titleSearchString
* @return void
* @throws \Exception
* @throws Exception
*/
private function performLinterSearchTests( array $testConfig, ?string $subPage, string $titleSearchString ): void {
foreach ( $testConfig as $configIndex => $group ) {
@ -369,7 +377,7 @@ class SpecialLintErrorsTest extends \SpecialPageTestBase {
}
/**
* @throws \Exception
* @throws Exception
*/
public function testLinterSearchVariations(): void {
$this->createTitleAndPage();

View file

@ -21,11 +21,12 @@
namespace MediaWiki\Linter\Test\Unit;
use MediaWiki\Linter\LintError;
use MediaWikiUnitTestCase;
/**
* @covers MediaWiki\Linter\LintError
* @covers \MediaWiki\Linter\LintError
*/
class LintErrorTest extends \MediaWikiUnitTestCase {
class LintErrorTest extends MediaWikiUnitTestCase {
public function testLintError() {
$error1 = new LintError(
'fostered',