Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4128372
WfThumbIsStandardTest.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
WfThumbIsStandardTest.php
View Options
<?php
use
MediaWiki\MainConfigNames
;
use
Psr\Log\NullLogger
;
/**
* @group GlobalFunctions
* @covers ::wfThumbIsStandard
*/
class
WfThumbIsStandardTest
extends
MediaWikiIntegrationTestCase
{
protected
function
setUp
():
void
{
parent
::
setUp
();
$this
->
overrideConfigValues
(
[
MainConfigNames
::
ThumbLimits
=>
[
100
,
401
],
MainConfigNames
::
ImageLimits
=>
[
[
300
,
225
],
[
800
,
600
],
],
]
);
}
public
static
function
provideThumbParams
()
{
return
[
// Thumb limits
[
'Standard thumb width'
,
true
,
[
'width'
=>
100
],
],
[
'Standard thumb width'
,
true
,
[
'width'
=>
401
],
],
// wfThumbIsStandard should match Linker::processResponsiveImages
// in its rounding behaviour.
[
'Standard thumb width (HiDPI 1.5x) - incorrect rounding'
,
false
,
[
'width'
=>
601
],
],
[
'Standard thumb width (HiDPI 1.5x)'
,
true
,
[
'width'
=>
602
],
],
[
'Standard thumb width (HiDPI 2x)'
,
true
,
[
'width'
=>
802
],
],
[
'Non-standard thumb width'
,
false
,
[
'width'
=>
300
],
],
// Image limits
// Note: Image limits are measured as pairs. Individual values
// may be non-standard based on the aspect ratio.
[
'Standard image width/height pair'
,
true
,
[
'width'
=>
250
,
'height'
=>
225
],
],
[
'Standard image width/height pair'
,
true
,
[
'width'
=>
667
,
'height'
=>
600
],
],
[
'Standard image width where image does not fit aspect ratio'
,
false
,
[
'width'
=>
300
],
],
[
'Implicit width from image width/height pair aspect ratio fit'
,
true
,
// 2000x1800 fit inside 300x225 makes w=250
[
'width'
=>
250
],
],
[
'Height-only is always non-standard'
,
false
,
[
'height'
=>
225
],
],
];
}
/**
* @dataProvider provideThumbParams
*/
public
function
testIsStandard
(
$message
,
$expected
,
$params
)
{
$handlers
=
$this
->
getConfVar
(
MainConfigNames
::
ParserTestMediaHandlers
);
$this
->
setService
(
'MediaHandlerFactory'
,
new
MediaHandlerFactory
(
new
NullLogger
(),
$handlers
)
);
$this
->
assertSame
(
$expected
,
wfThumbIsStandard
(
new
FakeDimensionFile
(
[
2000
,
1800
],
'image/jpeg'
),
$params
),
$message
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Aug 19, 09:13 (2 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
61/99/73ccb2ac679e5de30ec3d0010c14
Default Alt Text
WfThumbIsStandardTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment