MediaWiki REL1_31
FormOptionsInitializationTest.php
Go to the documentation of this file.
1<?php
17 public function getOptions() {
18 return $this->options;
19 }
20}
21
34 protected $object;
35
40 protected function setUp() {
41 parent::setUp();
42 $this->object = new FormOptionsExposed();
43 }
44
48 public function testAddStringOption() {
49 $this->object->add( 'foo', 'string value' );
50 $this->assertEquals(
51 [
52 'foo' => [
53 'default' => 'string value',
54 'consumed' => false,
55 'type' => FormOptions::STRING,
56 'value' => null,
57 ]
58 ],
59 $this->object->getOptions()
60 );
61 }
62
66 public function testAddIntegers() {
67 $this->object->add( 'one', 1 );
68 $this->object->add( 'negone', -1 );
69 $this->assertEquals(
70 [
71 'negone' => [
72 'default' => -1,
73 'value' => null,
74 'consumed' => false,
75 'type' => FormOptions::INT,
76 ],
77 'one' => [
78 'default' => 1,
79 'value' => null,
80 'consumed' => false,
81 'type' => FormOptions::INT,
82 ]
83 ],
84 $this->object->getOptions()
85 );
86 }
87}
This file host two test case classes for the MediaWiki FormOptions class:
Test class for FormOptions initialization Ensure the FormOptions::add() does what we want it to do.
setUp()
A new fresh and empty FormOptions object to test initialization with.
Helper class to keep track of options when mixing links and form elements.
const STRING
String type, maps guessType() to WebRequest::getText()
$options
Map of known option names to information about them.
const INT
Integer type, maps guessType() to WebRequest::getInt()