From ddd8f91a5b167f55e68b1f2da730f8b1c1e62029 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sat, 5 Feb 2011 23:41:29 +0000 Subject: [PATCH] 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. --- tests/phpunit/includes/XmlSelectTest.php | 40 ++++++++++++++++++++++++ tests/phpunit/includes/XmlTest.php | 4 --- 2 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 tests/phpunit/includes/XmlSelectTest.php diff --git a/tests/phpunit/includes/XmlSelectTest.php b/tests/phpunit/includes/XmlSelectTest.php new file mode 100644 index 0000000000..a4b0f8f1ce --- /dev/null +++ b/tests/phpunit/includes/XmlSelectTest.php @@ -0,0 +1,40 @@ +select = new XmlSelect(); + } + protected function tearDown() { + $this->select = null; + } + + ### START OF TESTS ### + + public function testConstructWithoutParameters() { + $this->assertEquals( '', $this->select->getHTML() ); + } + + # Begin XmlSelect::addOption() similar to Xml::option + public function testAddOption() { + $this->select->addOption( 'foo' ); + $this->assertEquals( '', $this->select->getHTML() ); + } + + public function testAddOptionWithDefault() { + $this->select->addOption( 'foo', true ); + $this->assertEquals( '', $this->select->getHTML() ); + } + public function testAddOptionWithFalse() { + $this->select->addOption( 'foo', false ); + $this->assertEquals( '', $this->select->getHTML() ); + } + public function testAddOptionWithValueZero() { + $this->select->addOption( 'foo', 0 ); + $this->assertEquals( '', $this->select->getHTML() ); + } + # End XmlSelect::addOption() similar to Xml::option + +} diff --git a/tests/phpunit/includes/XmlTest.php b/tests/phpunit/includes/XmlTest.php index e2f59abb84..4f38a37eb6 100644 --- a/tests/phpunit/includes/XmlTest.php +++ b/tests/phpunit/includes/XmlTest.php @@ -173,7 +173,3 @@ class XmlTest extends MediaWikiTestCase { ); } } - -// TODO -class XmlSelectTest extends MediaWikiTestCase { -} -- 2.20.1