MediaWiki REL1_30
XmlSelectTest.php
Go to the documentation of this file.
1<?php
2
7
11 protected $select;
12
13 protected function setUp() {
14 parent::setUp();
15 $this->select = new XmlSelect();
16 }
17
18 protected function tearDown() {
19 parent::tearDown();
20 $this->select = null;
21 }
22
27 $this->assertEquals( '<select></select>', $this->select->getHTML() );
28 }
29
35 public function testConstructParameters( $name, $id, $default, $expected ) {
36 $this->select = new XmlSelect( $name, $id, $default );
37 $this->assertEquals( $expected, $this->select->getHTML() );
38 }
39
48 public static function provideConstructionParameters() {
49 return [
55 # $name $id $default
56 [ false, false, false, '<select></select>' ],
57 [ false, false, 'foo', '<select></select>' ],
58 [ false, 'id', 'foo', '<select id="id"></select>' ],
59 [ false, 'id', false, '<select id="id"></select>' ],
60 [ 'name', 'id', false, '<select name="name" id="id"></select>' ],
61 [ 'name', 'id', 'foo', '<select name="name" id="id"></select>' ],
62 [ 'name', false, 'foo', '<select name="name"></select>' ],
63 [ 'name', false, false, '<select name="name"></select>' ],
64 ];
65 }
66
70 public function testAddOption() {
71 $this->select->addOption( 'foo' );
72 $this->assertEquals(
73 '<select><option value="foo">foo</option></select>',
74 $this->select->getHTML()
75 );
76 }
77
81 public function testAddOptionWithDefault() {
82 $this->select->addOption( 'foo', true );
83 $this->assertEquals(
84 '<select><option value="1">foo</option></select>',
85 $this->select->getHTML()
86 );
87 }
88
92 public function testAddOptionWithFalse() {
93 $this->select->addOption( 'foo', false );
94 $this->assertEquals(
95 '<select><option value="foo">foo</option></select>',
96 $this->select->getHTML()
97 );
98 }
99
103 public function testAddOptionWithValueZero() {
104 $this->select->addOption( 'foo', 0 );
105 $this->assertEquals(
106 '<select><option value="0">foo</option></select>',
107 $this->select->getHTML()
108 );
109 }
110
114 public function testSetDefault() {
115 $this->select->setDefault( 'bar1' );
116 $this->select->addOption( 'foo1' );
117 $this->select->addOption( 'bar1' );
118 $this->select->addOption( 'foo2' );
119 $this->assertEquals(
120 '<select><option value="foo1">foo1</option>' . "\n" .
121 '<option value="bar1" selected="">bar1</option>' . "\n" .
122 '<option value="foo2">foo2</option></select>', $this->select->getHTML() );
123 }
124
132 $this->select->addOption( 'foo1' );
133 $this->select->addOption( 'bar1' );
134 $this->select->addOption( 'foo2' );
135 $this->select->setDefault( 'bar1' ); # setting default after adding options
136 $this->assertEquals(
137 '<select><option value="foo1">foo1</option>' . "\n" .
138 '<option value="bar1" selected="">bar1</option>' . "\n" .
139 '<option value="foo2">foo2</option></select>', $this->select->getHTML() );
140 }
141
146 public function testGetAttributes() {
147 # create some attributes
148 $this->select->setAttribute( 'dummy', 0x777 );
149 $this->select->setAttribute( 'string', 'euro €' );
150 $this->select->setAttribute( 1911, 'razor' );
151
152 # verify we can retrieve them
153 $this->assertEquals(
154 $this->select->getAttribute( 'dummy' ),
155 0x777
156 );
157 $this->assertEquals(
158 $this->select->getAttribute( 'string' ),
159 'euro €'
160 );
161 $this->assertEquals(
162 $this->select->getAttribute( 1911 ),
163 'razor'
164 );
165
166 # inexistent keys should give us 'null'
167 $this->assertEquals(
168 $this->select->getAttribute( 'I DO NOT EXIT' ),
169 null
170 );
171
172 # verify string / integer
173 $this->assertEquals(
174 $this->select->getAttribute( '1911' ),
175 'razor'
176 );
177 $this->assertEquals(
178 $this->select->getAttribute( 'dummy' ),
179 0x777
180 );
181 }
182}
testAddOption()
XmlSelect::addOption.
testSetDefault()
XmlSelect::setDefault.
testConstructParameters( $name, $id, $default, $expected)
Parameters are $name (false), $id (false), $default (false) provideConstructionParameters XmlSelect::...
static provideConstructionParameters()
Provide parameters for testConstructParameters() which use three parameters:
testGetAttributes()
XmlSelect::setAttribute XmlSelect::getAttribute.
testAddOptionWithValueZero()
XmlSelect::addOption.
testConstructWithoutParameters()
XmlSelect::__construct.
XmlSelect $select
testAddOptionWithFalse()
XmlSelect::addOption.
testSetDefaultAfterAddingOptions()
Adding default later on should set the correct selection or raise an exception.
testAddOptionWithDefault()
XmlSelect::addOption.
Class for generating HTML <select> or <datalist> elements.
Definition XmlSelect.php:26
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like select() and insert() are usually more convenient. They take care of things like table prefixes and escaping for you. If you really need to make your own SQL
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing options(say) and put it in one place. Instead of having little title-reversing if-blocks spread all over the codebase in showAnArticle
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had 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 similarly to how extensions are installed You can then make that skin the default by adding
Definition skin.txt:68