2019-04-10 21:43:50 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\MediaWiki\Minerva;
|
|
|
|
|
|
|
|
use MediaWiki\Minerva\SkinOptions;
|
2019-10-20 02:26:08 +00:00
|
|
|
use OutOfBoundsException;
|
2019-04-10 21:43:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class SkinMinervaTest
|
|
|
|
* @package Tests\MediaWiki\Minerva
|
|
|
|
* @group MinervaNeue
|
|
|
|
* @coversDefaultClass \MediaWiki\Minerva\SkinOptions
|
|
|
|
*/
|
2019-07-01 19:53:01 +00:00
|
|
|
class SkinOptionsTest extends \MediaWikiUnitTestCase {
|
2019-04-10 21:43:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::get
|
|
|
|
* @covers ::getAll
|
|
|
|
* @covers ::setMultiple
|
|
|
|
*/
|
|
|
|
public function testSettersAndGetters() {
|
|
|
|
$options = new SkinOptions();
|
2019-08-22 20:31:31 +00:00
|
|
|
$defaultValue = $options->get( SkinOptions::BETA_MODE );
|
|
|
|
$options->setMultiple( [ SkinOptions::BETA_MODE => !$defaultValue ] );
|
2019-04-10 21:43:50 +00:00
|
|
|
|
|
|
|
$allOptions = $options->getAll();
|
|
|
|
|
2019-08-22 20:31:31 +00:00
|
|
|
$this->assertEquals( !$defaultValue, $options->get( SkinOptions::BETA_MODE ) );
|
|
|
|
$this->assertArrayHasKey( SkinOptions::BETA_MODE, $allOptions );
|
|
|
|
$this->assertEquals( !$defaultValue, $allOptions[ SkinOptions::BETA_MODE ] );
|
2019-04-10 21:43:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::hasSkinOptions
|
|
|
|
*/
|
|
|
|
public function testHasSkinOptions() {
|
|
|
|
$options = new SkinOptions();
|
|
|
|
$this->assertTrue( $options->hasSkinOptions() );
|
|
|
|
$options->setMultiple( [
|
2019-07-30 00:24:23 +00:00
|
|
|
SkinOptions::TALK_AT_TOP => false,
|
|
|
|
SkinOptions::HISTORY_IN_PAGE_ACTIONS => false,
|
|
|
|
SkinOptions::TOOLBAR_SUBMENU => false,
|
2019-08-22 20:31:31 +00:00
|
|
|
SkinOptions::MAIN_MENU_EXPANDED => false,
|
|
|
|
SkinOptions::PERSONAL_MENU => false,
|
2019-04-10 21:43:50 +00:00
|
|
|
] );
|
|
|
|
$this->assertFalse( $options->hasSkinOptions() );
|
|
|
|
}
|
2019-07-31 20:47:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::get
|
|
|
|
*/
|
|
|
|
public function testGettingUnknownKeyShouldThrowException() {
|
|
|
|
$options = new SkinOptions();
|
2019-10-20 02:26:08 +00:00
|
|
|
$this->expectException( OutOfBoundsException::class );
|
2019-07-31 20:47:27 +00:00
|
|
|
$options->get( 'non_existing_key' );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::get
|
2020-01-26 19:26:31 +00:00
|
|
|
*/
|
2019-07-31 20:47:27 +00:00
|
|
|
public function testSettingUnknownKeyShouldThrowException() {
|
|
|
|
$options = new SkinOptions();
|
2019-10-20 02:26:08 +00:00
|
|
|
$this->expectException( OutOfBoundsException::class );
|
2019-07-31 20:47:27 +00:00
|
|
|
$options->setMultiple( [
|
|
|
|
'non_existing_key' => 1
|
|
|
|
] );
|
|
|
|
}
|
2019-04-10 21:43:50 +00:00
|
|
|
}
|