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 );
37 public static function provideFilesAtRoot() {
50 foreach ( $rootFiles as $rootFile ) {
51 $testCases["$rootFile file"] = [ "$IP/$rootFile" ];
57 * @dataProvider provideFilesAtRoot
60 public function testRootFilesHaveProperLineLength( $fileName ) {
61 $this->assertFileLength( "Help", $fileName );
64 private function assertFileLength( $type, $fileName ) {
65 $lines = file( $fileName, FILE_IGNORE_NEW_LINES
);
67 $this->assertNotFalse(
69 "$type file '$fileName' is inaccessible."
73 foreach ( $lines as $i => $line ) {
76 // FILE_IGNORE_NEW_LINES drops the \n at the EOL, so max length is 80 not 81.
79 $length = mb_strlen( $line );
80 if ( $length <= $max_length ) {
83 $errors[] = "line $num: length $length > $max_length:\n$line";
85 # Using assertSame() to show the full line
88 "$type file '$fileName' lines " .
89 "have at most $max_length characters"