4 * James doesn't like having to manually fix these things.
6 class ReleaseNotesTest
extends MediaWikiTestCase
{
8 * Verify that at least one Release Notes file exists, have content, and
11 * @group documentation
14 public function testReleaseNotesFilesExistAndAreNotMalformed() {
15 global $wgVersion, $IP;
17 $notesFiles = glob( "$IP/RELEASE-NOTES-*" );
19 $this->assertGreaterThanOrEqual(
22 'Repo has at least one Release Notes file.'
25 $versionParts = explode( '.', explode( '-', $wgVersion )[0] );
26 $this->assertContains(
27 "$IP/RELEASE-NOTES-$versionParts[0].$versionParts[1]",
29 'Repo has a Release Notes file for the current $wgVersion.'
32 foreach ( $notesFiles as $index => $fileName ) {
33 $this->assertFileLength( "Release Notes", $fileName );
36 // Also test the README and similar files
37 $otherFiles = [ "$IP/COPYING", "$IP/FAQ", "$IP/INSTALL", "$IP/README", "$IP/SECURITY" ];
39 foreach ( $otherFiles as $index => $fileName ) {
40 $this->assertFileLength( "Help", $fileName );
46 private function assertFileLength( $type, $fileName ) {
47 $file = file( $fileName, FILE_IGNORE_NEW_LINES
);
51 "$type file '$fileName' is inaccessible."
54 $lines = count( $file );
56 for ( $i = 0; $i < $lines; $i++
) {
59 $this->assertLessThanOrEqual(
60 // FILE_IGNORE_NEW_LINES drops the \n at the EOL, so max length is 80 not 81.
63 "$type file '$fileName' line $i is longer than 80 chars:\n\t'$line'"