MediaWiki  1.23.2
FormOptionsInitializationTest.php
Go to the documentation of this file.
1 <?php
17  public function getOptions() {
18  return $this->options;
19  }
20 }
21 
36  protected $object;
37 
42  protected function setUp() {
43  parent::setUp();
44  $this->object = new FormOptionsExposed();
45  }
46 
50  public function testAddStringOption() {
51  $this->object->add( 'foo', 'string value' );
52  $this->assertEquals(
53  array(
54  'foo' => array(
55  'default' => 'string value',
56  'consumed' => false,
57  'type' => FormOptions::STRING,
58  'value' => null,
59  )
60  ),
61  $this->object->getOptions()
62  );
63  }
64 
68  public function testAddIntegers() {
69  $this->object->add( 'one', 1 );
70  $this->object->add( 'negone', -1 );
71  $this->assertEquals(
72  array(
73  'negone' => array(
74  'default' => -1,
75  'value' => null,
76  'consumed' => false,
77  'type' => FormOptions::INT,
78  ),
79  'one' => array(
80  'default' => 1,
81  'value' => null,
82  'consumed' => false,
83  'type' => FormOptions::INT,
84  )
85  ),
86  $this->object->getOptions()
87  );
88  }
89 }
object
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object
Definition: globals.txt:25
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
FormOptionsInitializationTest\setUp
setUp()
A new fresh and empty FormOptions object to test initialization with.
Definition: FormOptionsInitializationTest.php:41
FormOptionsInitializationTest\testAddIntegers
testAddIntegers()
@covers FormOptionsExposed::add
Definition: FormOptionsInitializationTest.php:67
FormOptionsExposed\getOptions
getOptions()
Definition: FormOptionsInitializationTest.php:17
FormOptionsInitializationTest
Test class for FormOptions initialization Ensure the FormOptions::add() does what we want it to do.
Definition: FormOptionsInitializationTest.php:32
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
FormOptionsInitializationTest\$object
FormOptions $object
Definition: FormOptionsInitializationTest.php:35
FormOptions\$options
$options
Map of known option names to information about them.
Definition: FormOptions.php:67
FormOptions\STRING
const STRING
String type, maps guessType() to WebRequest::getText()
Definition: FormOptions.php:43
FormOptionsExposed
This file host two test case classes for the MediaWiki FormOptions class:
Definition: FormOptionsInitializationTest.php:16
FormOptions\INT
const INT
Integer type, maps guessType() to WebRequest::getInt()
Definition: FormOptions.php:45
FormOptionsInitializationTest\testAddStringOption
testAddStringOption()
@covers FormOptionsExposed::add
Definition: FormOptionsInitializationTest.php:49
FormOptions
Helper class to keep track of options when mixing links and form elements.
Definition: FormOptions.php:35