3 class TestSample
extends PHPUnit_Framework_TestCase
{
6 * Anything that needs to happen before your tests should go here.
12 * Anything cleanup you need to do should go here.
17 function testEqual() {
18 $title = Title
::newFromText("text");
19 $this->assertEquals("Text", $title->__toString(), "Title creation");
20 $this->assertEquals("Text", "Text", "Automatic string conversion");
22 $title = Title
::newFromText("text", NS_MEDIA
);
23 $this->assertEquals("Media:Text", $title->__toString(), "Title creation with namespace");
28 * If you want to run a the same test with a variety of data. use a data provider.
29 * See: http://www.phpunit.de/manual/3.4/en/writing-tests-for-phpunit.html
31 public function provideTitles() {
33 array( 'Text', NS_MEDIA
, 'Media:Text' ),
34 array( 'Text', null, 'Text' ),
35 array( 'Text', NS_USER
, 'User:Text' ),
36 array( 'Text', NS_USER
, 'Blah' )
41 * @dataProvider provideTitles()
43 public function testCreation($titleName, $ns, $text) {
44 $title = Title
::newFromText($titleName, $ns);
45 $this->assertEquals($text, "$title", "see if '$titleName' matches '$text'");
49 * @expectedException MWException object
51 * Above comment tells PHPUnit to expect an exception of the
52 * MWException class containing the string "object" in the
55 function testException() {
56 $title = Title
::newFromText(new Title("test"));