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', null, 'Text' ),
36 array( 'Text', NS_USER
, 'User:Text' ),
37 array( 'Text', NS_USER
, 'Blah' )
42 * @dataProvider provideTitles()
44 public function testCreation($titleName, $ns, $text) {
45 $title = Title
::newFromText($titleName, $ns);
46 $this->assertEquals($text, "$title", "see if '$titleName' matches '$text'");
50 * @expectedException MWException object
52 * Above comment tells PHPUnit to expect an exception of the
53 * MWException class containing the string "object" in the
56 function testException() {
57 $title = Title
::newFromText(new Title("test"));