Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader itself.
Move the tests by analogy.
I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".
I did not address DependencyStore which continues to have a non-standard
location and namespace.
Revert of a241d83e0a.
Bug: T308718
Change-Id: Id08a220e1d6085e2b33f3f6c9d0e3935a4204659
50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Tests\Unit\ResourceLoader;
|
|
|
|
use MediaWiki\ResourceLoader\FilePath;
|
|
use MediaWikiUnitTestCase;
|
|
|
|
/**
|
|
* @covers \MediaWiki\ResourceLoader\FilePath
|
|
*/
|
|
class FilePathTest extends MediaWikiUnitTestCase {
|
|
|
|
public function testConstructor() {
|
|
$path = new FilePath( 'dummy/path', '/local', '/remote' );
|
|
|
|
$this->assertInstanceOf( FilePath::class, $path );
|
|
}
|
|
|
|
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', '', '' );
|
|
|
|
// 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() );
|
|
}
|
|
}
|