Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4148379
ReleaseNotesTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
ReleaseNotesTest.php
View Options
<?php
/**
* James doesn't like having to manually fix these things.
* @group ReleaseNotes
*/
class
ReleaseNotesTest
extends
MediaWikiUnitTestCase
{
/**
* Verify that at least one Release Notes file exists, have content, and
* aren't overly long.
*
* @group documentation
* @coversNothing
*/
public
function
testReleaseNotesFilesExistAndAreNotMalformed
()
{
global
$IP
;
$notesFiles
=
glob
(
"$IP/RELEASE-NOTES-*"
);
$this
->
assertGreaterThanOrEqual
(
1
,
count
(
$notesFiles
),
'Repo has at least one Release Notes file.'
);
$versionParts
=
explode
(
'.'
,
explode
(
'-'
,
MW_VERSION
)[
0
]
);
$this
->
assertContains
(
"$IP/RELEASE-NOTES-$versionParts[0].$versionParts[1]"
,
$notesFiles
,
'Repo has a Release Notes file for the current MW_VERSION.'
);
foreach
(
$notesFiles
as
$fileName
)
{
$this
->
assertFileLength
(
"Release Notes"
,
$fileName
);
}
}
public
static
function
provideFilesAtRoot
()
{
global
$IP
;
$rootFiles
=
[
"COPYING"
,
"FAQ"
,
"HISTORY"
,
"INSTALL"
,
"SECURITY"
,
];
foreach
(
$rootFiles
as
$rootFile
)
{
yield
"$rootFile file"
=>
[
"$IP/$rootFile"
];
}
}
/**
* @dataProvider provideFilesAtRoot
* @coversNothing
*/
public
function
testRootFilesHaveProperLineLength
(
$fileName
)
{
$this
->
assertFileLength
(
"Help"
,
$fileName
);
}
private
function
assertFileLength
(
$type
,
$fileName
)
{
$lines
=
file
(
$fileName
,
FILE_IGNORE_NEW_LINES
);
$this
->
assertNotFalse
(
$lines
,
"$type file '$fileName' is inaccessible."
);
// FILE_IGNORE_NEW_LINES drops the \n at the EOL, so max length is 80 not 81.
$maxLength
=
80
;
$errors
=
[];
foreach
(
$lines
as
$i
=>
$line
)
{
$length
=
mb_strlen
(
$line
);
if
(
$length
<=
$maxLength
||
// Lines with nothing but a long URL cannot be split further
preg_match
(
'/^
\W
*https?:
\/\/\S
*$/'
,
$line
)
)
{
continue
;
}
$num
=
$i
+
1
;
$errors
[]
=
"line $num: length $length > $maxLength:
\n
$line"
;
}
// Use assertSame() instead of assertEqual(), to show the full line in the diff
$this
->
assertSame
(
[],
$errors
,
"$type file '$fileName' lines have at most $maxLength characters"
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 19 2026, 18:46 (6 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
8a/6d/7317811b7297fab099c7b17d2598
Default Alt Text
ReleaseNotesTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment