Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4109487
FilePathTest.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
FilePathTest.php
View Options
<?php
namespace
MediaWiki\Tests\Unit\ResourceLoader
;
use
MediaWiki\ResourceLoader\FilePath
;
use
MediaWikiUnitTestCase
;
use
RuntimeException
;
/**
* @group ResourceLoader
* @covers \MediaWiki\ResourceLoader\FilePath
*/
class
FilePathTest
extends
MediaWikiUnitTestCase
{
public
function
testGetterSimple
()
{
$path
=
new
FilePath
(
'dummy/path'
,
'/local'
,
'/remote'
);
$this
->
assertSame
(
'/local/dummy/path'
,
$path
->
getLocalPath
()
);
$this
->
assertSame
(
'/remote/dummy/path'
,
$path
->
getRemotePath
()
);
$this
->
assertSame
(
'/local'
,
$path
->
getLocalBasePath
()
);
$this
->
assertSame
(
'/remote'
,
$path
->
getRemoteBasePath
()
);
$this
->
assertSame
(
'dummy/path'
,
$path
->
getPath
()
);
}
public
function
testGetterWebRoot
()
{
$path
=
new
FilePath
(
'dummy/path'
,
'/local'
,
'/'
);
$this
->
assertSame
(
'/local/dummy/path'
,
$path
->
getLocalPath
()
);
// No double slash (T284391)
$this
->
assertSame
(
'/dummy/path'
,
$path
->
getRemotePath
()
);
$this
->
assertSame
(
'/local'
,
$path
->
getLocalBasePath
()
);
$this
->
assertSame
(
'/'
,
$path
->
getRemoteBasePath
()
);
$this
->
assertSame
(
'dummy/path'
,
$path
->
getPath
()
);
}
public
function
testGetterNoBase
()
{
$path
=
new
FilePath
(
'dummy/path'
);
try
{
$path
->
getLocalPath
();
$this
->
fail
(
'Expected exception not thrown'
);
}
catch
(
RuntimeException
$ex
)
{
$this
->
assertSame
(
'Base path was not provided'
,
$ex
->
getMessage
(),
'Expected exception'
);
}
try
{
$path
->
getRemotePath
();
$this
->
fail
(
'Expected exception not thrown'
);
}
catch
(
RuntimeException
$ex
)
{
$this
->
assertSame
(
'Base path was not provided'
,
$ex
->
getMessage
(),
'Expected exception'
);
}
$this
->
assertSame
(
null
,
$path
->
getLocalBasePath
()
);
$this
->
assertSame
(
null
,
$path
->
getRemoteBasePath
()
);
$this
->
assertSame
(
'dummy/path'
,
$path
->
getPath
()
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Aug 18, 21:06 (2 w, 21 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
a5/fd/43b55b35db9e50854747edb3240f
Default Alt Text
FilePathTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment