wiki.techinc.nl/tests/phpunit/unit/includes/Html/FormOptionsInitializationTest.php
Umherirrender 790ae736c1 tests: Move test cases from /includes/ into sub folder
Follow move of the tested class
Most moves are part of T321882

Change-Id: I74ab45d6a5331dcb2ff0b65dc2cc7c6315146646
2023-09-13 00:09:05 +02:00

71 lines
1.4 KiB
PHP

<?php
use MediaWiki\Html\FormOptions;
use Wikimedia\TestingAccessWrapper;
/**
* Test class for FormOptions initialization
* Ensure the FormOptions::add() does what we want it to do.
*
* Copyright © 2011, Antoine Musso
*
* @author Antoine Musso
*/
class FormOptionsInitializationTest extends \MediaWikiUnitTestCase {
/**
* @var FormOptions
*/
protected $object;
/**
* A new fresh and empty FormOptions object to test initialization
* with.
*/
protected function setUp(): void {
parent::setUp();
$this->object = TestingAccessWrapper::newFromObject( new FormOptions() );
}
/**
* @covers MediaWiki\Html\FormOptions::add
*/
public function testAddStringOption() {
$this->object->add( 'foo', 'string value' );
$this->assertEquals(
[
'foo' => [
'default' => 'string value',
'consumed' => false,
'type' => FormOptions::STRING,
'value' => null,
]
],
$this->object->options
);
}
/**
* @covers MediaWiki\Html\FormOptions::add
*/
public function testAddIntegers() {
$this->object->add( 'one', 1 );
$this->object->add( 'negone', -1 );
$this->assertEquals(
[
'negone' => [
'default' => -1,
'value' => null,
'consumed' => false,
'type' => FormOptions::INT,
],
'one' => [
'default' => 1,
'value' => null,
'consumed' => false,
'type' => FormOptions::INT,
]
],
$this->object->options
);
}
}