2021-12-08 20:04:09 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MediaWiki\Tests\Unit\Settings\Source;
|
|
|
|
|
|
|
|
|
|
use MediaWiki\Settings\SettingsBuilderException;
|
|
|
|
|
use MediaWiki\Settings\Source\PhpSettingsSource;
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
|
|
/**
|
2021-12-17 18:13:17 +00:00
|
|
|
* @covers \MediaWiki\Settings\Source\PhpSettingsSource
|
2021-12-08 20:04:09 +00:00
|
|
|
*/
|
|
|
|
|
class PhpSettingsSourceTest extends TestCase {
|
|
|
|
|
public function testLoad() {
|
|
|
|
|
$source = new PhpSettingsSource( __DIR__ . '/fixtures/strategies.php' );
|
|
|
|
|
$this->assertSame( [], $source->load() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testLoadInvalidPhpSource() {
|
|
|
|
|
$this->expectException( SettingsBuilderException::class );
|
|
|
|
|
|
|
|
|
|
$source = new PhpSettingsSource( __DIR__ . '/fixtures/bad-strategies.php' );
|
|
|
|
|
$source->load();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testLoadFileNotArray() {
|
|
|
|
|
$this->expectException( SettingsBuilderException::class );
|
|
|
|
|
|
|
|
|
|
// Let this just be an empty string.
|
|
|
|
|
$source = new PhpSettingsSource( __DIR__ . '/fixtures/strategies-bad-structure.php' );
|
|
|
|
|
$source->load();
|
|
|
|
|
}
|
|
|
|
|
}
|