Added release notes for 'ContentHandler::runLegacyHooks' removal
[mediawiki.git] / tests / phpunit / includes / FormOptionsInitializationTest.php
blob0c853e0833e0160c45e14f5cb745d7f5c9af909d
1 <?php
2 /**
3 * This file host two test case classes for the MediaWiki FormOptions class:
4 * - FormOptionsInitializationTest : tests initialization of the class.
5 * - FormOptionsTest : tests methods an on instance
7 * The split let us take advantage of setting up a fixture for the methods
8 * tests.
9 */
11 /**
12 * Dummy class to makes FormOptions::$options public.
13 * Used by FormOptionsInitializationTest which need to verify the $options
14 * array is correctly set through the FormOptions::add() function.
16 class FormOptionsExposed extends FormOptions {
17 public function getOptions() {
18 return $this->options;
22 /**
23 * Test class for FormOptions initialization
24 * Ensure the FormOptions::add() does what we want it to do.
26 * Copyright © 2011, Antoine Musso
28 * @author Antoine Musso
30 class FormOptionsInitializationTest extends MediaWikiTestCase {
31 /**
32 * @var FormOptions
34 protected $object;
36 /**
37 * A new fresh and empty FormOptions object to test initialization
38 * with.
40 protected function setUp() {
41 parent::setUp();
42 $this->object = new FormOptionsExposed();
45 /**
46 * @covers FormOptionsExposed::add
48 public function testAddStringOption() {
49 $this->object->add( 'foo', 'string value' );
50 $this->assertEquals(
52 'foo' => [
53 'default' => 'string value',
54 'consumed' => false,
55 'type' => FormOptions::STRING,
56 'value' => null,
59 $this->object->getOptions()
63 /**
64 * @covers FormOptionsExposed::add
66 public function testAddIntegers() {
67 $this->object->add( 'one', 1 );
68 $this->object->add( 'negone', -1 );
69 $this->assertEquals(
71 'negone' => [
72 'default' => -1,
73 'value' => null,
74 'consumed' => false,
75 'type' => FormOptions::INT,
77 'one' => [
78 'default' => 1,
79 'value' => null,
80 'consumed' => false,
81 'type' => FormOptions::INT,
84 $this->object->getOptions()