r81581 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81580‎ | r81581 | r81582 >
Date:23:41, 5 February 2011
Author:hashar
Status:ok
Tags:
Comment:
Tests for XmlSelect::addOption()

PHPUnit seems to only accept one class per test file. This patch move the
XmlSelect class to a new file.

It also add some assertions for XmlSelect::addOption(). Please review them
carefully! Although the assertions are fine:
OK (5 tests, 5 assertions)

I am not sure they are the expected behaviour.
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/XmlSelectTest.php (added) (history)
  • /trunk/phase3/tests/phpunit/includes/XmlTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/XmlTest.php
@@ -173,7 +173,3 @@
174174 );
175175 }
176176 }
177 -
178 -// TODO
179 -class XmlSelectTest extends MediaWikiTestCase {
180 -}
Index: trunk/phase3/tests/phpunit/includes/XmlSelectTest.php
@@ -0,0 +1,40 @@
 2+<?php
 3+
 4+// TODO
 5+class XmlSelectTest extends MediaWikiTestCase {
 6+ protected $select;
 7+
 8+ protected function setUp() {
 9+ $this->select = new XmlSelect();
 10+ }
 11+ protected function tearDown() {
 12+ $this->select = null;
 13+ }
 14+
 15+ ### START OF TESTS ###
 16+
 17+ public function testConstructWithoutParameters() {
 18+ $this->assertEquals( '<select></select>', $this->select->getHTML() );
 19+ }
 20+
 21+ # Begin XmlSelect::addOption() similar to Xml::option
 22+ public function testAddOption() {
 23+ $this->select->addOption( 'foo' );
 24+ $this->assertEquals( '<select><option value="foo">foo</option></select>', $this->select->getHTML() );
 25+ }
 26+
 27+ public function testAddOptionWithDefault() {
 28+ $this->select->addOption( 'foo', true );
 29+ $this->assertEquals( '<select><option value="1">foo</option></select>', $this->select->getHTML() );
 30+ }
 31+ public function testAddOptionWithFalse() {
 32+ $this->select->addOption( 'foo', false );
 33+ $this->assertEquals( '<select><option value="foo">foo</option></select>', $this->select->getHTML() );
 34+ }
 35+ public function testAddOptionWithValueZero() {
 36+ $this->select->addOption( 'foo', 0 );
 37+ $this->assertEquals( '<select><option value="0">foo</option></select>', $this->select->getHTML() );
 38+ }
 39+ # End XmlSelect::addOption() similar to Xml::option
 40+
 41+}
Property changes on: trunk/phase3/tests/phpunit/includes/XmlSelectTest.php
___________________________________________________________________
Added: svn:eol-style
142 + native

Status & tagging log