wiki.techinc.nl/tests/phpunit/unit/includes/resourceloader/ResourceLoaderFilePathTest.php
Lucas Werkmeister (WMDE) a241d83e0a Revert "ResourceLoader namespace"
This reverts commit e08ea8ccb9.

Reason for revert: Breaks Phan in extensions, and as far as I’m aware,
this change isn’t urgently needed for anything, so the simplest fix is
to revert it again for now. After PHP 7.4 it should be safer to try this
again (we hopefully won’t need the two “hack” classes by then).

Bug: T308443
Change-Id: Iff3318cbf97a67f821f78e60da62a583f63e389e
2022-05-16 14:43:33 +00:00

45 lines
1.6 KiB
PHP

<?php
/**
* @covers ResourceLoaderFilePath
*/
class ResourceLoaderFilePathTest extends MediaWikiUnitTestCase {
public function testConstructor() {
$path = new ResourceLoaderFilePath( 'dummy/path', '/local', '/remote' );
$this->assertInstanceOf( ResourceLoaderFilePath::class, $path );
}
public function testGetterSimple() {
$path = new ResourceLoaderFilePath( '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 ResourceLoaderFilePath( '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 ResourceLoaderFilePath( '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() );
}
}