diff options
author | Reedy <reedy@wikimedia.org> | 2021-12-15 23:13:24 +0000 |
---|---|---|
committer | Umherirrender <umherirrender_de.wp@web.de> | 2021-12-18 17:33:15 +0000 |
commit | 06e82d1c781bdbfc58372c7a4829fcd6b9d9a246 (patch) | |
tree | ff239f76865d6c899dd8e88f574c64f44b7244bb /tests/phpunit/unit/documentation/ReleaseNotesTest.php | |
parent | 7fec5ecda76c4ee565efe12671fc3c8be1a64a7b (diff) | |
download | mediawikicore-06e82d1c781bdbfc58372c7a4829fcd6b9d9a246.tar.gz mediawikicore-06e82d1c781bdbfc58372c7a4829fcd6b9d9a246.zip |
ReleaseNotesTest: Minor cleanup
* Remove unused $index in foreach
* Rename $max_length to $maxLength
* Don't repeatedly set $maxLength to the same value
* Don't set $num unless it is needed
Change-Id: I8b57d637918e883076349d209a845da27c2b78cd
Diffstat (limited to 'tests/phpunit/unit/documentation/ReleaseNotesTest.php')
-rw-r--r-- | tests/phpunit/unit/documentation/ReleaseNotesTest.php | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/phpunit/unit/documentation/ReleaseNotesTest.php b/tests/phpunit/unit/documentation/ReleaseNotesTest.php index d481d4b35bf9..f5da4877155b 100644 --- a/tests/phpunit/unit/documentation/ReleaseNotesTest.php +++ b/tests/phpunit/unit/documentation/ReleaseNotesTest.php @@ -29,7 +29,7 @@ class ReleaseNotesTest extends MediaWikiUnitTestCase { 'Repo has a Release Notes file for the current MW_VERSION.' ); - foreach ( $notesFiles as $index => $fileName ) { + foreach ( $notesFiles as $fileName ) { $this->assertFileLength( "Release Notes", $fileName ); } } @@ -66,24 +66,23 @@ class ReleaseNotesTest extends MediaWikiUnitTestCase { "$type file '$fileName' is inaccessible." ); + // FILE_IGNORE_NEW_LINES drops the \n at the EOL, so max length is 80 not 81. + $maxLength = 80; + $errors = []; foreach ( $lines as $i => $line ) { - $num = $i + 1; - - // FILE_IGNORE_NEW_LINES drops the \n at the EOL, so max length is 80 not 81. - $max_length = 80; - $length = mb_strlen( $line ); - if ( $length <= $max_length ) { + if ( $length <= $maxLength ) { continue; } - $errors[] = "line $num: length $length > $max_length:\n$line"; + $num = $i + 1; + $errors[] = "line $num: length $length > $maxLength:\n$line"; } // Use assertSame() instead of assertEqual(), to show the full line in the diff $this->assertSame( [], $errors, - "$type file '$fileName' lines have at most $max_length characters" + "$type file '$fileName' lines have at most $maxLength characters" ); } } |