Add examples of depends
authorMark A. Hershberger <mah@users.mediawiki.org>
Sat, 23 Oct 2010 17:08:03 +0000 (17:08 +0000)
committerMark A. Hershberger <mah@users.mediawiki.org>
Sat, 23 Oct 2010 17:08:03 +0000 (17:08 +0000)
maintenance/tests/phpunit/includes/SampleTest.php

index b670778..ee91ec4 100644 (file)
@@ -41,11 +41,36 @@ class TestSample extends PHPUnit_Framework_TestCase {
        /**
         * @dataProvider provideTitles()
         */
-       public function testCreation($titleName, $ns, $text) {
+       public function testTitleCreation($titleName, $ns, $text) {
                $title = Title::newFromText($titleName, $ns);
                $this->assertEquals($text, "$title", "see if '$titleName' matches '$text'");
        }
 
+       public function testInitialCreation() {
+               $title = Title::newMainPage();
+               $this->assertEquals("Main Page", "$title", "Test initial creation of a title");
+
+               return $title;
+       }
+
+       /**
+        * Instead of putting a bunch of tests in a single test method,
+        * you should put only one or two tests in each test method.  This
+        * way, the test method names can remain descriptive.
+        *
+        * If you want to make tests depend on data created in another
+        * method, you can create dependencies feed whatever you return
+        * from the dependant method (e.g. testInitialCreation in this
+        * example) as arguments to the next method (e.g. $title in
+        * testTitleDepends is whatever testInitialCreatiion returned.)
+        */
+       /**
+        * @depends testInitialCreation
+        */
+       public function testTitleDepends( $title ) {
+               $this->assertTrue( $title->isLocal() );
+       }
+
        /**
         * @expectedException MWException object
         *