Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4087863
FileContentsHasherTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
FileContentsHasherTest.php
View Options
<?php
/**
* @covers \FileContentsHasher
*/
class
FileContentsHasherTest
extends
PHPUnit\Framework\TestCase
{
use
MediaWikiCoversValidator
;
public
static
function
provideSingleFile
()
{
return
array_map
(
static
function
(
$file
)
{
return
[
$file
,
file_get_contents
(
$file
)
];
},
glob
(
__DIR__
.
'/../../data/filecontentshasher/*.*'
)
);
}
/**
* @dataProvider provideSingleFile
*/
public
function
testSingleFileHash
(
$fileName
,
$contents
)
{
$expected
=
hash
(
'md4'
,
$contents
);
$actualHash
=
FileContentsHasher
::
getFileContentsHash
(
$fileName
);
$this
->
assertEquals
(
$expected
,
$actualHash
);
$actualHashRepeat
=
FileContentsHasher
::
getFileContentsHash
(
$fileName
);
$this
->
assertEquals
(
$expected
,
$actualHashRepeat
);
}
public
function
provideMultipleFiles
()
{
return
[
[
$this
->
provideSingleFile
()
]
];
}
/**
* @dataProvider provideMultipleFiles
*/
public
function
testMultipleFileHash
(
$files
)
{
$fileNames
=
[];
$hashes
=
[];
foreach
(
$files
as
[
$fileName
,
$contents
]
)
{
$fileNames
[]
=
$fileName
;
$hashes
[]
=
hash
(
'md4'
,
$contents
);
}
$expectedHash
=
hash
(
'md4'
,
implode
(
''
,
$hashes
)
);
$actualHash
=
FileContentsHasher
::
getFileContentsHash
(
$fileNames
);
$this
->
assertEquals
(
$expectedHash
,
$actualHash
);
$actualHashRepeat
=
FileContentsHasher
::
getFileContentsHash
(
$fileNames
);
$this
->
assertEquals
(
$expectedHash
,
$actualHashRepeat
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 18 2026, 09:44 (6 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
8c/6d/4bce222b90223e63852099e122b0
Default Alt Text
FileContentsHasherTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment