mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-04 10:39:08 +00:00
4efd72a879
Additionally, renamed couple options for better readability. Bug: T221012 Change-Id: Ia347a60d469fba8f35afa7c70aa806a46271dccd
70 lines
1.8 KiB
PHP
70 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Tests\MediaWiki\Minerva;
|
|
|
|
use MediaWiki\Minerva\SkinOptions;
|
|
|
|
/**
|
|
* Class SkinMinervaTest
|
|
* @package Tests\MediaWiki\Minerva
|
|
* @group MinervaNeue
|
|
* @coversDefaultClass \MediaWiki\Minerva\SkinOptions
|
|
*/
|
|
class SkinOptionsTest extends \MediaWikiUnitTestCase {
|
|
|
|
/**
|
|
* @covers ::get
|
|
* @covers ::getAll
|
|
* @covers ::setMultiple
|
|
*/
|
|
public function testSettersAndGetters() {
|
|
$options = new SkinOptions();
|
|
$defaultValue = $options->get( SkinOptions::AMC_MODE );
|
|
$options->setMultiple( [ SkinOptions::AMC_MODE => !$defaultValue ] );
|
|
|
|
$allOptions = $options->getAll();
|
|
|
|
$this->assertEquals( !$defaultValue, $options->get( SkinOptions::AMC_MODE ) );
|
|
$this->assertArrayHasKey( SkinOptions::AMC_MODE, $allOptions );
|
|
$this->assertEquals( !$defaultValue, $allOptions[ SkinOptions::AMC_MODE ] );
|
|
}
|
|
|
|
/**
|
|
* @covers ::hasSkinOptions
|
|
*/
|
|
public function testHasSkinOptions() {
|
|
$options = new SkinOptions();
|
|
// set AMC_MODE to true just in case someone decides to set everything to false
|
|
// sometime in the future.
|
|
$options->setMultiple( [ SkinOptions::AMC_MODE => true ] );
|
|
$this->assertTrue( $options->hasSkinOptions() );
|
|
$options->setMultiple( [ SkinOptions::BACK_TO_TOP => true ] );
|
|
$this->assertTrue( $options->hasSkinOptions() );
|
|
$options->setMultiple( [
|
|
SkinOptions::AMC_MODE => false,
|
|
SkinOptions::BACK_TO_TOP => false
|
|
] );
|
|
$this->assertFalse( $options->hasSkinOptions() );
|
|
}
|
|
|
|
/**
|
|
* @covers ::get
|
|
* @expectedException \OutOfBoundsException
|
|
*/
|
|
public function testGettingUnknownKeyShouldThrowException() {
|
|
$options = new SkinOptions();
|
|
$options->get( 'non_existing_key' );
|
|
}
|
|
|
|
/**
|
|
* @covers ::get
|
|
* @expectedException \OutOfBoundsException
|
|
*/
|
|
public function testSettingUnknownKeyShouldThrowException() {
|
|
$options = new SkinOptions();
|
|
$options->setMultiple( [
|
|
'non_existing_key' => 1
|
|
] );
|
|
}
|
|
}
|