test: coverage recording now needs to be explicit
[mediawiki.git] / tests / phpunit / includes / FormOptionsInitializationTest.php
blobfb2304dca1ec9331688200dbc6dc925d97788074
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 * Generated by PHPUnit on 2011-02-28 at 20:46:27.
28 * Copyright © 2011, Antoine Musso
30 * @author Antoine Musso
32 class FormOptionsInitializationTest extends MediaWikiTestCase {
33 /**
34 * @var FormOptions
36 protected $object;
39 /**
40 * A new fresh and empty FormOptions object to test initialization
41 * with.
43 protected function setUp() {
44 parent::setUp();
45 $this->object = new FormOptionsExposed();
48 public function testAddStringOption() {
49 $this->object->add( 'foo', 'string value' );
50 $this->assertEquals(
51 array(
52 'foo' => array(
53 'default' => 'string value',
54 'consumed' => false,
55 'type' => FormOptions::STRING,
56 'value' => null,
59 $this->object->getOptions()
63 public function testAddIntegers() {
64 $this->object->add( 'one', 1 );
65 $this->object->add( 'negone', -1 );
66 $this->assertEquals(
67 array(
68 'negone' => array(
69 'default' => -1,
70 'value' => null,
71 'consumed' => false,
72 'type' => FormOptions::INT,
74 'one' => array(
75 'default' => 1,
76 'value' => null,
77 'consumed' => false,
78 'type' => FormOptions::INT,
81 $this->object->getOptions()