2019-07-14 22:16:07 +00:00
|
|
|
<?php
|
|
|
|
|
|
2019-07-19 22:36:06 +00:00
|
|
|
/**
|
2022-05-16 14:43:33 +00:00
|
|
|
* @covers ResourceLoaderFilePath
|
2019-07-19 22:36:06 +00:00
|
|
|
*/
|
2022-05-16 14:43:33 +00:00
|
|
|
class ResourceLoaderFilePathTest extends MediaWikiUnitTestCase {
|
2019-07-14 22:16:07 +00:00
|
|
|
|
2019-07-19 22:36:06 +00:00
|
|
|
public function testConstructor() {
|
2022-05-16 14:43:33 +00:00
|
|
|
$path = new ResourceLoaderFilePath( 'dummy/path', '/local', '/remote' );
|
2019-07-14 22:16:07 +00:00
|
|
|
|
2022-05-16 14:43:33 +00:00
|
|
|
$this->assertInstanceOf( ResourceLoaderFilePath::class, $path );
|
2019-07-14 22:16:07 +00:00
|
|
|
}
|
|
|
|
|
|
2021-06-08 23:34:03 +00:00
|
|
|
public function testGetterSimple() {
|
2022-05-16 14:43:33 +00:00
|
|
|
$path = new ResourceLoaderFilePath( 'dummy/path', '/local', '/remote' );
|
2019-07-14 22:16:07 +00:00
|
|
|
|
2019-07-19 22:36:06 +00:00
|
|
|
$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() );
|
2019-07-14 22:16:07 +00:00
|
|
|
}
|
2021-06-08 23:34:03 +00:00
|
|
|
|
|
|
|
|
public function testGetterWebRoot() {
|
2022-05-16 14:43:33 +00:00
|
|
|
$path = new ResourceLoaderFilePath( 'dummy/path', '/local', '/' );
|
2021-06-08 23:34:03 +00:00
|
|
|
|
|
|
|
|
$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() {
|
2022-05-16 14:43:33 +00:00
|
|
|
$path = new ResourceLoaderFilePath( 'dummy/path', '', '' );
|
2021-06-08 23:34:03 +00:00
|
|
|
|
|
|
|
|
// No transformation
|
|
|
|
|
$this->assertSame( 'dummy/path', $path->getLocalPath() );
|
|
|
|
|
$this->assertSame( 'dummy/path', $path->getRemotePath() );
|
|
|
|
|
$this->assertSame( '', $path->getLocalBasePath() );
|
|
|
|
|
$this->assertSame( '', $path->getRemoteBasePath() );
|
|
|
|
|
$this->assertSame( 'dummy/path', $path->getPath() );
|
|
|
|
|
}
|
2019-07-14 22:16:07 +00:00
|
|
|
}
|