Add doc-typehints to class properties found by the PropertyDocumentation sniff to improve the documentation. Once the sniff is enabled it avoids that new code is missing type declarations. This is focused on documentation and does not change code. Change-Id: Ifc27750207edc09e94af030d882b6f1a5369cf98
64 lines
1.8 KiB
PHP
64 lines
1.8 KiB
PHP
<?php
|
|
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
/**
|
|
* @covers \AutoLoader
|
|
*/
|
|
class AutoLoaderTest extends MediaWikiIntegrationTestCase {
|
|
|
|
/** @var string[] */
|
|
private $oldPsr4;
|
|
/** @var string[] */
|
|
private $oldClassFiles;
|
|
|
|
protected function setUp(): void {
|
|
parent::setUp();
|
|
|
|
$this->mergeMwGlobalArrayValue( 'wgAutoloadLocalClasses', [
|
|
'TestAutoloadedLocalClass' =>
|
|
__DIR__ . '/../data/autoloader/TestAutoloadedLocalClass.php',
|
|
] );
|
|
$this->mergeMwGlobalArrayValue( 'wgAutoloadClasses', [
|
|
'TestAutoloadedClass' => __DIR__ . '/../data/autoloader/TestAutoloadedClass.php',
|
|
] );
|
|
|
|
$access = TestingAccessWrapper::newFromClass( AutoLoader::class );
|
|
$this->oldPsr4 = $access->psr4Namespaces;
|
|
$this->oldClassFiles = $access->classFiles;
|
|
AutoLoader::registerNamespaces( [
|
|
'Test\\MediaWiki\\AutoLoader\\' => __DIR__ . '/../data/autoloader/psr4'
|
|
] );
|
|
AutoLoader::registerClasses( [
|
|
'TestAnotherAutoloadedClass' => __DIR__ . '/../data/autoloader/TestAnotherAutoloadedClass.php',
|
|
] );
|
|
}
|
|
|
|
protected function tearDown(): void {
|
|
$access = TestingAccessWrapper::newFromClass( AutoLoader::class );
|
|
$access->psr4Namespaces = $this->oldPsr4;
|
|
$access->classFiles = $this->oldClassFiles;
|
|
parent::tearDown();
|
|
}
|
|
|
|
public function testFind() {
|
|
$path = __DIR__ . '/../data/autoloader/TestAutoloadedLocalClass.php';
|
|
$this->assertSame( $path, AutoLoader::find( TestAutoloadedLocalClass::class ) );
|
|
}
|
|
|
|
public function testCoreClass() {
|
|
$this->assertTrue( class_exists( 'TestAutoloadedLocalClass' ) );
|
|
}
|
|
|
|
public function testExtensionClass() {
|
|
$this->assertTrue( class_exists( 'TestAnotherAutoloadedClass' ) );
|
|
}
|
|
|
|
public function testLegacyExtensionClass() {
|
|
$this->assertTrue( class_exists( 'TestAutoloadedClass' ) );
|
|
}
|
|
|
|
public function testPsr4() {
|
|
$this->assertTrue( class_exists( 'Test\\MediaWiki\\AutoLoader\\TestFooBar' ) );
|
|
}
|
|
}
|