ReleaseNotesTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * James doesn't like having to manually fix these things.
  4. */
  5. class ReleaseNotesTest extends MediaWikiTestCase {
  6. /**
  7. * Verify that at least one Release Notes file exists, have content, and
  8. * aren't overly long.
  9. *
  10. * @group documentation
  11. * @coversNothing
  12. */
  13. public function testReleaseNotesFilesExistAndAreNotMalformed() {
  14. global $wgVersion, $IP;
  15. $notesFiles = glob( "$IP/RELEASE-NOTES-*" );
  16. $this->assertGreaterThanOrEqual(
  17. 1,
  18. count( $notesFiles ),
  19. 'Repo has at least one Release Notes file.'
  20. );
  21. $versionParts = explode( '.', explode( '-', $wgVersion )[0] );
  22. $this->assertContains(
  23. "$IP/RELEASE-NOTES-$versionParts[0].$versionParts[1]",
  24. $notesFiles,
  25. 'Repo has a Release Notes file for the current $wgVersion.'
  26. );
  27. foreach ( $notesFiles as $index => $fileName ) {
  28. $file = file( $fileName, FILE_IGNORE_NEW_LINES );
  29. $this->assertFalse(
  30. !$file,
  31. "Release Notes file '$fileName' is inaccessible."
  32. );
  33. $lines = count( $file );
  34. for ( $i = 0; $i < $lines; $i++ ) {
  35. $line = $file[$i];
  36. $this->assertLessThanOrEqual(
  37. // FILE_IGNORE_NEW_LINES drops the \n at the EOL, so max length is 80 not 81.
  38. 80,
  39. mb_strlen( $line ),
  40. "Release notes file '$fileName' line $i is longer than 80 chars:\n\t'$line'"
  41. );
  42. }
  43. }
  44. }
  45. }