| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
namespace MediaWiki\Skins\Vector\Tests\Unit\FeatureManagement\Requirements; |
| 24 |
|
| 25 |
use MediaWiki\Config\HashConfig; |
| 26 |
use MediaWiki\Skins\Vector\FeatureManagement\Requirements\DynamicConfigRequirement; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
class DynamicConfigRequirementTest extends \MediaWikiUnitTestCase { |
| 34 |
|
| 35 |
public static function providesBooleanStates(): array { |
| 36 |
return [ [ false ], [ true ] ]; |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public function testItFetchesAndReturnsConfigValue( bool $configValue ) { |
| 44 |
$config = new HashConfig( [ |
| 45 |
'Foo' => $configValue, |
| 46 |
] ); |
| 47 |
|
| 48 |
$requirement = new DynamicConfigRequirement( $config, 'Foo', 'Bar' ); |
| 49 |
|
| 50 |
$this->assertEquals( $requirement->isMet(), $configValue ); |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
public function testItCastsConfigValue() { |
| 57 |
$config = new HashConfig( [ |
| 58 |
'Foo' => new \stdClass(), |
| 59 |
] ); |
| 60 |
|
| 61 |
$requirement = new DynamicConfigRequirement( $config, 'Foo', 'Bar' ); |
| 62 |
|
| 63 |
$this->assertTrue( $requirement->isMet() ); |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
public function testItReturnsName() { |
| 70 |
$requirement = new DynamicConfigRequirement( |
| 71 |
new HashConfig(), |
| 72 |
'Foo', |
| 73 |
'Bar' |
| 74 |
); |
| 75 |
|
| 76 |
$this->assertEquals( 'Bar', $requirement->getName() ); |
| 77 |
} |
| 78 |
} |