Index: trunk/phase3/tests/phpunit/includes/XmlJsTest.php |
— | — | @@ -0,0 +1,9 @@ |
| 2 | +<?php |
| 3 | +class XmlJs extends PHPUnit_Framework_TestCase { |
| 4 | + public function testConstruction() { |
| 5 | + $obj = new XmlJsCode( null ); |
| 6 | + $this->assertNull( $obj->value ); |
| 7 | + $obj = new XmlJsCode( '' ); |
| 8 | + $this->assertSame( $obj->value, '' ); |
| 9 | + } |
| 10 | +} |
Property changes on: trunk/phase3/tests/phpunit/includes/XmlJsTest.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 11 | + native |
Index: trunk/phase3/tests/phpunit/includes/XmlSelectTest.php |
— | — | @@ -17,12 +17,48 @@ |
18 | 18 | $this->assertEquals( '<select></select>', $this->select->getHTML() ); |
19 | 19 | } |
20 | 20 | |
| 21 | + /** |
| 22 | + * Parameters are $name (false), $id (false), $default (false) |
| 23 | + * @dataProvider provideConstructionParameters |
| 24 | + */ |
| 25 | + public function testConstructParameters( $name, $id, $default, $expected ) { |
| 26 | + $this->select = new XmlSelect( $name, $id, $default ); |
| 27 | + $this->assertEquals( $expected, $this->select->getHTML() ); |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * Provide parameters for testConstructParameters() which use three |
| 32 | + * parameters: |
| 33 | + * - $name (default: false) |
| 34 | + * - $id (default: false) |
| 35 | + * - $default (default: false) |
| 36 | + * Provides a fourth parameters representing the expected HTML output |
| 37 | + * |
| 38 | + */ |
| 39 | + public function provideConstructionParameters() { |
| 40 | + return array( |
| 41 | + /** |
| 42 | + * Values are set following a 3-bit Gray code where two successive |
| 43 | + * values differ by only one value. |
| 44 | + * See http://en.wikipedia.org/wiki/Gray_code |
| 45 | + */ |
| 46 | + # $name $id $default |
| 47 | + array( false , false, false, '<select></select>' ), |
| 48 | + array( false , false, 'foo', '<select></select>' ), |
| 49 | + array( false , 'id' , 'foo', '<select id="id"></select>' ), |
| 50 | + array( false , 'id' , false, '<select id="id"></select>' ), |
| 51 | + array( 'name', 'id' , false, '<select name="name" id="id"></select>' ), |
| 52 | + array( 'name', 'id' , 'foo', '<select name="name" id="id"></select>' ), |
| 53 | + array( 'name', false, 'foo', '<select name="name"></select>' ), |
| 54 | + array( 'name', false, false, '<select name="name"></select>' ), |
| 55 | + ); |
| 56 | + } |
| 57 | + |
21 | 58 | # Begin XmlSelect::addOption() similar to Xml::option |
22 | 59 | public function testAddOption() { |
23 | 60 | $this->select->addOption( 'foo' ); |
24 | 61 | $this->assertEquals( '<select><option value="foo">foo</option></select>', $this->select->getHTML() ); |
25 | 62 | } |
26 | | - |
27 | 63 | public function testAddOptionWithDefault() { |
28 | 64 | $this->select->addOption( 'foo', true ); |
29 | 65 | $this->assertEquals( '<select><option value="1">foo</option></select>', $this->select->getHTML() ); |
— | — | @@ -37,4 +73,33 @@ |
38 | 74 | } |
39 | 75 | # End XmlSelect::addOption() similar to Xml::option |
40 | 76 | |
| 77 | + public function testSetDefault() { |
| 78 | + $this->select->setDefault( 'bar1' ); |
| 79 | + $this->select->addOption( 'foo1' ); |
| 80 | + $this->select->addOption( 'bar1' ); |
| 81 | + $this->select->addOption( 'foo2' ); |
| 82 | + $this->assertEquals( |
| 83 | +'<select><option value="foo1">foo1</option> |
| 84 | +<option value="bar1" selected="selected">bar1</option> |
| 85 | +<option value="foo2">foo2</option></select>', $this->select->getHTML() ); |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * Adding default later on should set the correct selection or |
| 90 | + * raise an exception. |
| 91 | + * To handle this, we need to render the options in getHtml() |
| 92 | + */ |
| 93 | + public function testSetDefaultAfterAddingOptions() { |
| 94 | + $this->markTestSkipped( 'XmlSelect::setDefault() need to apply to previously added options'); |
| 95 | + |
| 96 | + $this->select->addOption( 'foo1' ); |
| 97 | + $this->select->addOption( 'bar1' ); |
| 98 | + $this->select->addOption( 'foo2' ); |
| 99 | + $this->select->setDefault( 'bar1' ); # setting default after adding options |
| 100 | + $this->assertEquals( |
| 101 | +'<select><option value="foo1">foo1</option> |
| 102 | +<option value="bar1" selected="selected">bar1</option> |
| 103 | +<option value="foo2">foo2</option></select>', $this->select->getHTML() ); |
| 104 | + } |
| 105 | + |
41 | 106 | } |
Index: trunk/phase3/tests/phpunit/includes/GlobalTest.php |
— | — | @@ -17,6 +17,30 @@ |
18 | 18 | $wgReadOnlyFile = $this->originals['wgReadOnlyFile']; |
19 | 19 | } |
20 | 20 | |
| 21 | + /** @dataProvider provideForWfArrayDiff2 */ |
| 22 | + public function testWfArrayDiff2( $a, $b, $expected ) { |
| 23 | + $this->assertEquals( |
| 24 | + wfArrayDiff2( $a, $b), $expected |
| 25 | + ); |
| 26 | + } |
| 27 | + |
| 28 | + // @todo Provide more tests |
| 29 | + public function provideForWfArrayDiff2() { |
| 30 | + // $a $b $expected |
| 31 | + return array( |
| 32 | + array( |
| 33 | + array( 'a', 'b'), |
| 34 | + array( 'a', 'b'), |
| 35 | + array(), |
| 36 | + ), |
| 37 | + array( |
| 38 | + array( array( 'a'), array( 'a', 'b', 'c' )), |
| 39 | + array( array( 'a'), array( 'a', 'b' )), |
| 40 | + array( 1 => array( 'a', 'b', 'c' ) ), |
| 41 | + ), |
| 42 | + ); |
| 43 | + } |
| 44 | + |
21 | 45 | function testRandom() { |
22 | 46 | # This could hypothetically fail, but it shouldn't ;) |
23 | 47 | $this->assertFalse( |
Index: trunk/phase3/tests/phpunit/includes/MediaWikiTest.php |
— | — | @@ -0,0 +1,182 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Test class for MediaWiki. |
| 5 | + * Generated by PHPUnit on 2011-02-06 at 11:41:23. |
| 6 | + */ |
| 7 | +class MediaWikiTest extends PHPUnit_Framework_TestCase { |
| 8 | + /** |
| 9 | + * @var MediaWiki |
| 10 | + */ |
| 11 | + protected $object; |
| 12 | + |
| 13 | + protected function setUp() { |
| 14 | + $this->object = new MediaWiki; |
| 15 | + } |
| 16 | + |
| 17 | + protected function tearDown() { |
| 18 | + $this->object = NULL; |
| 19 | + } |
| 20 | + |
| 21 | + /** |
| 22 | + * Test case insentiveness for get / set |
| 23 | + */ |
| 24 | + public function testSetGetValKeyInsentiveness() { |
| 25 | + |
| 26 | + // set with lower case key |
| 27 | + $value = 'SomeValue'; |
| 28 | + $this->object->setVal( 'foobar', $value ); |
| 29 | + |
| 30 | + $this->assertEquals( |
| 31 | + $this->object->getVal( 'foobar' ), 'SomeValue', |
| 32 | + 'lower case key set, getting lower case key' |
| 33 | + ); |
| 34 | + $this->assertEquals( |
| 35 | + $this->object->getVal( 'FOOBAR' ), 'SomeValue', |
| 36 | + 'lower case key set, getting upper case key' |
| 37 | + ); |
| 38 | + |
| 39 | + // set with Mixed case key |
| 40 | + $value = 'SomeValue2'; |
| 41 | + $this->object->setVal( 'FooBar', $value ); |
| 42 | + |
| 43 | + $this->assertEquals( |
| 44 | + $this->object->getVal( 'foobar' ), 'SomeValue2', |
| 45 | + 'mixed case key set, getting lower case key' |
| 46 | + ); |
| 47 | + $this->assertEquals( |
| 48 | + $this->object->getVal( 'FOOBAR' ), 'SomeValue2', |
| 49 | + 'mixed case key set, getting upper case key' |
| 50 | + ); |
| 51 | + } |
| 52 | + |
| 53 | + public function testGetValWithDefault() { |
| 54 | + $this->assertEmpty( |
| 55 | + $this->object->getVal( 'NonExistent' ), |
| 56 | + 'Non existent key return empty string' |
| 57 | + ); |
| 58 | + $this->assertEquals( |
| 59 | + $this->object->getVal( 'NonExistent2', 'Default Value' ), 'Default Value', |
| 60 | + 'Non existent key with default given, should give default' |
| 61 | + ); |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * @todo Implement testPerformRequestForTitle(). |
| 66 | + */ |
| 67 | + public function testPerformRequestForTitle() { |
| 68 | + // Remove the following lines when you implement this test. |
| 69 | + $this->markTestIncomplete( |
| 70 | + 'This test has not been implemented yet.' |
| 71 | + ); |
| 72 | + } |
| 73 | + |
| 74 | + /** |
| 75 | + * @todo Implement testCheckMaxLag(). |
| 76 | + */ |
| 77 | + public function testCheckMaxLag() { |
| 78 | + // Remove the following lines when you implement this test. |
| 79 | + $this->markTestIncomplete( |
| 80 | + 'This test has not been implemented yet.' |
| 81 | + ); |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * @todo Implement testCheckInitialQueries(). |
| 86 | + */ |
| 87 | + public function testCheckInitialQueries() { |
| 88 | + // Remove the following lines when you implement this test. |
| 89 | + $this->markTestIncomplete( |
| 90 | + 'This test has not been implemented yet.' |
| 91 | + ); |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * @todo Implement testPreliminaryChecks(). |
| 96 | + */ |
| 97 | + public function testPreliminaryChecks() { |
| 98 | + // Remove the following lines when you implement this test. |
| 99 | + $this->markTestIncomplete( |
| 100 | + 'This test has not been implemented yet.' |
| 101 | + ); |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * @todo Implement testHandleSpecialCases(). |
| 106 | + */ |
| 107 | + public function testHandleSpecialCases() { |
| 108 | + // Remove the following lines when you implement this test. |
| 109 | + $this->markTestIncomplete( |
| 110 | + 'This test has not been implemented yet.' |
| 111 | + ); |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * @todo Implement testArticleFromTitle(). |
| 116 | + */ |
| 117 | + public function testArticleFromTitle() { |
| 118 | + // Remove the following lines when you implement this test. |
| 119 | + $this->markTestIncomplete( |
| 120 | + 'This test has not been implemented yet.' |
| 121 | + ); |
| 122 | + } |
| 123 | + |
| 124 | + /** |
| 125 | + * @todo Implement testGetAction(). |
| 126 | + */ |
| 127 | + public function testGetAction() { |
| 128 | + // Remove the following lines when you implement this test. |
| 129 | + $this->markTestIncomplete( |
| 130 | + 'This test has not been implemented yet.' |
| 131 | + ); |
| 132 | + } |
| 133 | + |
| 134 | + /** |
| 135 | + * @todo Implement testInitializeArticle(). |
| 136 | + */ |
| 137 | + public function testInitializeArticle() { |
| 138 | + // Remove the following lines when you implement this test. |
| 139 | + $this->markTestIncomplete( |
| 140 | + 'This test has not been implemented yet.' |
| 141 | + ); |
| 142 | + } |
| 143 | + |
| 144 | + /** |
| 145 | + * @todo Implement testFinalCleanup(). |
| 146 | + */ |
| 147 | + public function testFinalCleanup() { |
| 148 | + // Remove the following lines when you implement this test. |
| 149 | + $this->markTestIncomplete( |
| 150 | + 'This test has not been implemented yet.' |
| 151 | + ); |
| 152 | + } |
| 153 | + |
| 154 | + /** |
| 155 | + * @todo Implement testDoJobs(). |
| 156 | + */ |
| 157 | + public function testDoJobs() { |
| 158 | + // Remove the following lines when you implement this test. |
| 159 | + $this->markTestIncomplete( |
| 160 | + 'This test has not been implemented yet.' |
| 161 | + ); |
| 162 | + } |
| 163 | + |
| 164 | + /** |
| 165 | + * @todo Implement testRestInPeace(). |
| 166 | + */ |
| 167 | + public function testRestInPeace() { |
| 168 | + // Remove the following lines when you implement this test. |
| 169 | + $this->markTestIncomplete( |
| 170 | + 'This test has not been implemented yet.' |
| 171 | + ); |
| 172 | + } |
| 173 | + |
| 174 | + /** |
| 175 | + * @todo Implement testPerformAction(). |
| 176 | + */ |
| 177 | + public function testPerformAction() { |
| 178 | + // Remove the following lines when you implement this test. |
| 179 | + $this->markTestIncomplete( |
| 180 | + 'This test has not been implemented yet.' |
| 181 | + ); |
| 182 | + } |
| 183 | +} |
Property changes on: trunk/phase3/tests/phpunit/includes/MediaWikiTest.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 184 | + native |