wiki.techinc.nl/tests/phpunit/unit/includes/ResourceLoader/FilePathTest.php
Tim Starling e08ea8ccb9 ResourceLoader namespace
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader and
ResourceLoaderContext.

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.

Change-Id: I92998ae6a82e0b935c13e02a183e7c324fa410a3
2022-05-16 14:41:27 +10:00

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() );
}
}