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() {
49 foreach ( $rootFiles as $rootFile ) {
50 yield
"$rootFile file" => [ "$IP/$rootFile" ];
55 * @dataProvider provideFilesAtRoot
58 public function testRootFilesHaveProperLineLength( $fileName ) {
59 $this->assertFileLength( "Help", $fileName );
62 private function assertFileLength( $type, $fileName ) {
63 $lines = file( $fileName, FILE_IGNORE_NEW_LINES
);
65 $this->assertNotFalse(
67 "$type file '$fileName' is inaccessible."
71 foreach ( $lines as $i => $line ) {
74 // FILE_IGNORE_NEW_LINES drops the \n at the EOL, so max length is 80 not 81.
77 $length = mb_strlen( $line );
78 if ( $length <= $max_length ) {
81 $errors[] = "line $num: length $length > $max_length:\n$line";
83 # Use assertSame() instead of assertEqual(), to show the full line in the diff
87 "$type file '$fileName' lines " .
88 "have at most $max_length characters"