X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28%27user%27%2C%20userid=session.user.id%29%20%7D%7D?a=blobdiff_plain;f=tests%2Fphpunit%2Fdocumentation%2FReleaseNotesTest.php;h=2789571e2b571d514ee6e733db249abaaae22e00;hb=a47aec961e329fb8ae37d6c6646d7e82b101c191;hp=4de071d65ac8cc20e976efed084c1d6b6e800f41;hpb=0e2e1254dfefb89c3a81f4053e69fa01d478a22e;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/documentation/ReleaseNotesTest.php b/tests/phpunit/documentation/ReleaseNotesTest.php index 4de071d65a..2789571e2b 100644 --- a/tests/phpunit/documentation/ReleaseNotesTest.php +++ b/tests/phpunit/documentation/ReleaseNotesTest.php @@ -30,25 +30,38 @@ class ReleaseNotesTest extends MediaWikiTestCase { ); foreach ( $notesFiles as $index => $fileName ) { - $file = file( $fileName, FILE_IGNORE_NEW_LINES ); + $this->assertFileLength( "Release Notes", $fileName ); + } - $this->assertFalse( - !$file, - "Release Notes file '$fileName' is inaccessible." - ); + // Also test the README and similar files + $otherFiles = [ "$IP/COPYING", "$IP/FAQ", "$IP/INSTALL", "$IP/README", "$IP/SECURITY" ]; - $lines = count( $file ); + foreach ( $otherFiles as $index => $fileName ) { + $this->assertFileLength( "Help", $fileName ); + } + } - for ( $i = 0; $i < $lines; $i++ ) { - $line = $file[$i]; + /** + */ + private function assertFileLength( $type, $fileName ) { + $file = file( $fileName, FILE_IGNORE_NEW_LINES ); - $this->assertLessThanOrEqual( - // FILE_IGNORE_NEW_LINES drops the \n at the EOL, so max length is 80 not 81. - 80, - strlen( $line ), - "Release notes file '$fileName' line $i is longer than 80 chars:\n\t'$line'" - ); - } + $this->assertFalse( + !$file, + "$type file '$fileName' is inaccessible." + ); + + $lines = count( $file ); + + for ( $i = 0; $i < $lines; $i++ ) { + $line = $file[$i]; + + $this->assertLessThanOrEqual( + // FILE_IGNORE_NEW_LINES drops the \n at the EOL, so max length is 80 not 81. + 80, + mb_strlen( $line ), + "$type file '$fileName' line $i is longer than 80 chars:\n\t'$line'" + ); } } }