Bug: T192167 Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43 Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
70 lines
1.3 KiB
PHP
70 lines
1.3 KiB
PHP
<?php
|
|
|
|
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 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 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
|
|
);
|
|
}
|
|
}
|