r75273 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75272‎ | r75273 | r75274 >
Date:17:08, 23 October 2010
Author:mah
Status:ok
Tags:
Comment:
Add examples of depends
Modified paths:
  • /trunk/phase3/maintenance/tests/phpunit/includes/SampleTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/phpunit/includes/SampleTest.php
@@ -41,12 +41,37 @@
4242 /**
4343 * @dataProvider provideTitles()
4444 */
45 - public function testCreation($titleName, $ns, $text) {
 45+ public function testTitleCreation($titleName, $ns, $text) {
4646 $title = Title::newFromText($titleName, $ns);
4747 $this->assertEquals($text, "$title", "see if '$titleName' matches '$text'");
4848 }
4949
 50+ public function testInitialCreation() {
 51+ $title = Title::newMainPage();
 52+ $this->assertEquals("Main Page", "$title", "Test initial creation of a title");
 53+
 54+ return $title;
 55+ }
 56+
5057 /**
 58+ * Instead of putting a bunch of tests in a single test method,
 59+ * you should put only one or two tests in each test method. This
 60+ * way, the test method names can remain descriptive.
 61+ *
 62+ * If you want to make tests depend on data created in another
 63+ * method, you can create dependencies feed whatever you return
 64+ * from the dependant method (e.g. testInitialCreation in this
 65+ * example) as arguments to the next method (e.g. $title in
 66+ * testTitleDepends is whatever testInitialCreatiion returned.)
 67+ */
 68+ /**
 69+ * @depends testInitialCreation
 70+ */
 71+ public function testTitleDepends( $title ) {
 72+ $this->assertTrue( $title->isLocal() );
 73+ }
 74+
 75+ /**
5176 * @expectedException MWException object
5277 *
5378 * Above comment tells PHPUnit to expect an exception of the

Status & tagging log