--- /dev/null
+<?php
+/**
+ * Test class for MediaWiki.
+ * Generated by PHPUnit on 2011-02-06 at 11:41:23.
+ */
+class MediaWikiTest extends PHPUnit_Framework_TestCase {
+ /**
+ * @var MediaWiki
+ */
+ protected $object;
+
+ protected function setUp() {
+ $this->object = new MediaWiki;
+ }
+
+ protected function tearDown() {
+ $this->object = NULL;
+ }
+
+ /**
+ * Test case insentiveness for get / set
+ */
+ public function testSetGetValKeyInsentiveness() {
+
+ // set with lower case key
+ $value = 'SomeValue';
+ $this->object->setVal( 'foobar', $value );
+
+ $this->assertEquals(
+ $this->object->getVal( 'foobar' ), 'SomeValue',
+ 'lower case key set, getting lower case key'
+ );
+ $this->assertEquals(
+ $this->object->getVal( 'FOOBAR' ), 'SomeValue',
+ 'lower case key set, getting upper case key'
+ );
+
+ // set with Mixed case key
+ $value = 'SomeValue2';
+ $this->object->setVal( 'FooBar', $value );
+
+ $this->assertEquals(
+ $this->object->getVal( 'foobar' ), 'SomeValue2',
+ 'mixed case key set, getting lower case key'
+ );
+ $this->assertEquals(
+ $this->object->getVal( 'FOOBAR' ), 'SomeValue2',
+ 'mixed case key set, getting upper case key'
+ );
+ }
+
+ public function testGetValWithDefault() {
+ $this->assertEmpty(
+ $this->object->getVal( 'NonExistent' ),
+ 'Non existent key return empty string'
+ );
+ $this->assertEquals(
+ $this->object->getVal( 'NonExistent2', 'Default Value' ), 'Default Value',
+ 'Non existent key with default given, should give default'
+ );
+ }
+
+ /**
+ * @todo Implement testPerformRequestForTitle().
+ */
+ public function testPerformRequestForTitle() {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testCheckMaxLag().
+ */
+ public function testCheckMaxLag() {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testCheckInitialQueries().
+ */
+ public function testCheckInitialQueries() {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testPreliminaryChecks().
+ */
+ public function testPreliminaryChecks() {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testHandleSpecialCases().
+ */
+ public function testHandleSpecialCases() {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testArticleFromTitle().
+ */
+ public function testArticleFromTitle() {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testGetAction().
+ */
+ public function testGetAction() {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testInitializeArticle().
+ */
+ public function testInitializeArticle() {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testFinalCleanup().
+ */
+ public function testFinalCleanup() {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testDoJobs().
+ */
+ public function testDoJobs() {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testRestInPeace().
+ */
+ public function testRestInPeace() {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testPerformAction().
+ */
+ public function testPerformAction() {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+}
$this->assertEquals( '<select></select>', $this->select->getHTML() );
}
+ /**
+ * Parameters are $name (false), $id (false), $default (false)
+ * @dataProvider provideConstructionParameters
+ */
+ public function testConstructParameters( $name, $id, $default, $expected ) {
+ $this->select = new XmlSelect( $name, $id, $default );
+ $this->assertEquals( $expected, $this->select->getHTML() );
+ }
+
+ /**
+ * Provide parameters for testConstructParameters() which use three
+ * parameters:
+ * - $name (default: false)
+ * - $id (default: false)
+ * - $default (default: false)
+ * Provides a fourth parameters representing the expected HTML output
+ *
+ */
+ public function provideConstructionParameters() {
+ return array(
+ /**
+ * Values are set following a 3-bit Gray code where two successive
+ * values differ by only one value.
+ * See http://en.wikipedia.org/wiki/Gray_code
+ */
+ # $name $id $default
+ array( false , false, false, '<select></select>' ),
+ array( false , false, 'foo', '<select></select>' ),
+ array( false , 'id' , 'foo', '<select id="id"></select>' ),
+ array( false , 'id' , false, '<select id="id"></select>' ),
+ array( 'name', 'id' , false, '<select name="name" id="id"></select>' ),
+ array( 'name', 'id' , 'foo', '<select name="name" id="id"></select>' ),
+ array( 'name', false, 'foo', '<select name="name"></select>' ),
+ array( 'name', false, false, '<select name="name"></select>' ),
+ );
+ }
+
# Begin XmlSelect::addOption() similar to Xml::option
public function testAddOption() {
$this->select->addOption( 'foo' );
$this->assertEquals( '<select><option value="foo">foo</option></select>', $this->select->getHTML() );
}
-
public function testAddOptionWithDefault() {
$this->select->addOption( 'foo', true );
$this->assertEquals( '<select><option value="1">foo</option></select>', $this->select->getHTML() );
}
# End XmlSelect::addOption() similar to Xml::option
+ public function testSetDefault() {
+ $this->select->setDefault( 'bar1' );
+ $this->select->addOption( 'foo1' );
+ $this->select->addOption( 'bar1' );
+ $this->select->addOption( 'foo2' );
+ $this->assertEquals(
+'<select><option value="foo1">foo1</option>
+<option value="bar1" selected="selected">bar1</option>
+<option value="foo2">foo2</option></select>', $this->select->getHTML() );
+ }
+
+ /**
+ * Adding default later on should set the correct selection or
+ * raise an exception.
+ * To handle this, we need to render the options in getHtml()
+ */
+ public function testSetDefaultAfterAddingOptions() {
+ $this->markTestSkipped( 'XmlSelect::setDefault() need to apply to previously added options');
+
+ $this->select->addOption( 'foo1' );
+ $this->select->addOption( 'bar1' );
+ $this->select->addOption( 'foo2' );
+ $this->select->setDefault( 'bar1' ); # setting default after adding options
+ $this->assertEquals(
+'<select><option value="foo1">foo1</option>
+<option value="bar1" selected="selected">bar1</option>
+<option value="foo2">foo2</option></select>', $this->select->getHTML() );
+ }
+
}