From: James D. Forrester Date: Tue, 3 Jul 2018 22:22:09 +0000 (-0700) Subject: tests: Add a doc test for release notes' existence and line length X-Git-Tag: 1.34.0-rc.0~4773^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=1b5ed07827471fe064dabe99e1598e5020d6d576;p=lhc%2Fweb%2Fwiklou.git tests: Add a doc test for release notes' existence and line length Change-Id: I502bedc0221e52b78b15b1749918500842533e7c --- diff --git a/tests/phpunit/documentation/ReleaseNotesTest.php b/tests/phpunit/documentation/ReleaseNotesTest.php new file mode 100644 index 0000000000..4de071d65a --- /dev/null +++ b/tests/phpunit/documentation/ReleaseNotesTest.php @@ -0,0 +1,54 @@ +assertGreaterThanOrEqual( + 1, + count( $notesFiles ), + 'Repo has at least one Release Notes file.' + ); + + $versionParts = explode( '.', explode( '-', $wgVersion )[0] ); + $this->assertContains( + "$IP/RELEASE-NOTES-$versionParts[0].$versionParts[1]", + $notesFiles, + 'Repo has a Release Notes file for the current $wgVersion.' + ); + + foreach ( $notesFiles as $index => $fileName ) { + $file = file( $fileName, FILE_IGNORE_NEW_LINES ); + + $this->assertFalse( + !$file, + "Release Notes 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, + strlen( $line ), + "Release notes file '$fileName' line $i is longer than 80 chars:\n\t'$line'" + ); + } + } + } +} diff --git a/tests/phpunit/suite.xml b/tests/phpunit/suite.xml index e8256ef2cb..e125b8a314 100644 --- a/tests/phpunit/suite.xml +++ b/tests/phpunit/suite.xml @@ -55,6 +55,9 @@ suites/ExtensionsParserTestSuite.php suites/LessTestSuite.php + + documentation +