Merge "rdbms: avoid LoadBalancer::getConnection waste when using $groups"
[lhc/web/wiklou.git] / tests / phpunit / includes / FormOptionsInitializationTest.php
1 <?php
2
3 use Wikimedia\TestingAccessWrapper;
4
5 /**
6 * Test class for FormOptions initialization
7 * Ensure the FormOptions::add() does what we want it to do.
8 *
9 * Copyright © 2011, Antoine Musso
10 *
11 * @author Antoine Musso
12 */
13 class FormOptionsInitializationTest extends MediaWikiTestCase {
14 /**
15 * @var FormOptions
16 */
17 protected $object;
18
19 /**
20 * A new fresh and empty FormOptions object to test initialization
21 * with.
22 */
23 protected function setUp() {
24 parent::setUp();
25 $this->object = TestingAccessWrapper::newFromObject( new FormOptions() );
26 }
27
28 /**
29 * @covers FormOptions::add
30 */
31 public function testAddStringOption() {
32 $this->object->add( 'foo', 'string value' );
33 $this->assertEquals(
34 [
35 'foo' => [
36 'default' => 'string value',
37 'consumed' => false,
38 'type' => FormOptions::STRING,
39 'value' => null,
40 ]
41 ],
42 $this->object->options
43 );
44 }
45
46 /**
47 * @covers FormOptions::add
48 */
49 public function testAddIntegers() {
50 $this->object->add( 'one', 1 );
51 $this->object->add( 'negone', -1 );
52 $this->assertEquals(
53 [
54 'negone' => [
55 'default' => -1,
56 'value' => null,
57 'consumed' => false,
58 'type' => FormOptions::INT,
59 ],
60 'one' => [
61 'default' => 1,
62 'value' => null,
63 'consumed' => false,
64 'type' => FormOptions::INT,
65 ]
66 ],
67 $this->object->options
68 );
69 }
70 }