From: Mark A. Hershberger Date: Sat, 23 Oct 2010 17:08:03 +0000 (+0000) Subject: Add examples of depends X-Git-Tag: 1.31.0-rc.0~34354 X-Git-Url: http://git.cyclocoop.org/data/%7B%24admin_url%7Dconfig?a=commitdiff_plain;h=e7579741851d8705020446ee576dc31e529e9d4b;p=lhc%2Fweb%2Fwiklou.git Add examples of depends --- diff --git a/maintenance/tests/phpunit/includes/SampleTest.php b/maintenance/tests/phpunit/includes/SampleTest.php index b6707788c5..ee91ec4f43 100644 --- a/maintenance/tests/phpunit/includes/SampleTest.php +++ b/maintenance/tests/phpunit/includes/SampleTest.php @@ -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 *