r75265 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75264‎ | r75265 | r75266 >
Date:16:41, 23 October 2010
Author:mah
Status:resolved
Tags:
Comment:
Example data provider
Modified paths:
  • /trunk/phase3/maintenance/tests/phpunit/includes/SampleTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/phpunit/includes/SampleTest.php
@@ -2,9 +2,18 @@
33
44 class TestSample extends PHPUnit_Framework_TestCase {
55
 6+ /**
 7+ * Anything that needs to happen before your tests should go here.
 8+ */
69 function setUp() {
710 }
811
 12+ /**
 13+ * Anything cleanup you need to do should go here.
 14+ */
 15+ function tearDown() {
 16+ }
 17+
918 function testEqual() {
1019 $title = Title::newFromText("text");
1120 $this->assertEquals("Text", $title->__toString(), "Title creation");
@@ -16,6 +25,27 @@
1726 }
1827
1928 /**
 29+ * If you want to run a the same test with a variety of data. use a data provider.
 30+ * See: http://www.phpunit.de/manual/3.4/en/writing-tests-for-phpunit.html
 31+ */
 32+ public function provideTitles() {
 33+ return array(
 34+ array( 'Text', NS_MEDIA, 'Media:Text' ),
 35+ array( 'Text', null, 'Text' ),
 36+ array( 'Text', NS_USER, 'User:Text' ),
 37+ array( 'Text', NS_USER, 'Blah' )
 38+ );
 39+ }
 40+
 41+ /**
 42+ * @dataProvider provideTitles()
 43+ */
 44+ public function testCreation($titleName, $ns, $text) {
 45+ $title = Title::newFromText($titleName, $ns);
 46+ $this->assertEquals($text, "$title", "see if '$titleName' matches '$text'");
 47+ }
 48+
 49+ /**
2050 * @expectedException MWException object
2151 *
2252 * Above comment tells PHPUnit to expect an exception of the

Follow-up revisions

RevisionCommit summaryAuthorDate
r75580No wonder that the check -added in r75265- Blah == User:Text never succeeded....platonides20:48, 27 October 2010

Status & tagging log