From: Max Semenik Date: Mon, 29 Mar 2010 14:30:42 +0000 (+0000) Subject: Started tests for Message class, fixed one bug found by them X-Git-Tag: 1.31.0-rc.0~37316 X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28?a=commitdiff_plain;h=3b1a10c0c6fad7f5420b4bf30be2d30f018016b4;p=lhc%2Fweb%2Fwiklou.git Started tests for Message class, fixed one bug found by them --- diff --git a/includes/Message.php b/includes/Message.php index 5ab41a7734..2ec07fae8c 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -277,7 +277,7 @@ class Message { * @return Bool: true if it is and false if not. */ public function exists() { - return $this->fetchMessage() === false; + return $this->fetchMessage() !== false; } public static function rawParam( $value ) { diff --git a/maintenance/tests/MessageTest.php b/maintenance/tests/MessageTest.php new file mode 100644 index 0000000000..9adba37216 --- /dev/null +++ b/maintenance/tests/MessageTest.php @@ -0,0 +1,19 @@ +assertTrue( Message::key( 'mainpage' )->exists() ); + $this->assertTrue( Message::key( 'mainpage' )->params( array() )->exists() ); + $this->assertTrue( Message::key( 'mainpage' )->rawParams( 'foo', 123 )->exists() ); + $this->assertFalse( Message::key( 'i-dont-exist-evar' )->exists() ); + $this->assertFalse( Message::key( 'i-dont-exist-evar' )->params( array() )->exists() ); + $this->assertFalse( Message::key( 'i-dont-exist-evar' )->rawParams( 'foo', 123 )->exists() ); + } + + function testKey() { + $this->assertType( 'Message', Message::key( 'mainpage' ) ); + $this->assertType( 'Message', Message::key( 'i-dont-exist-evar' ) ); + $this->assertEquals( 'Main Page', Message::key( 'mainpage' )->text() ); + $this->assertEquals( '<i-dont-exist-evar>', Message::key( 'i-dont-exist-evar' )->text() ); + } +} \ No newline at end of file