r64339 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64338‎ | r64339 | r64340 >
Date:14:30, 29 March 2010
Author:maxsem
Status:ok
Tags:
Comment:
Started tests for Message class, fixed one bug found by them
Modified paths:
  • /trunk/phase3/includes/Message.php (modified) (history)
  • /trunk/phase3/maintenance/tests/MessageTest.php (added) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/MessageTest.php
@@ -0,0 +1,19 @@
 2+<?php
 3+
 4+class MessageTest extends PHPUnit_Framework_TestCase {
 5+ function testExists() {
 6+ $this->assertTrue( Message::key( 'mainpage' )->exists() );
 7+ $this->assertTrue( Message::key( 'mainpage' )->params( array() )->exists() );
 8+ $this->assertTrue( Message::key( 'mainpage' )->rawParams( 'foo', 123 )->exists() );
 9+ $this->assertFalse( Message::key( 'i-dont-exist-evar' )->exists() );
 10+ $this->assertFalse( Message::key( 'i-dont-exist-evar' )->params( array() )->exists() );
 11+ $this->assertFalse( Message::key( 'i-dont-exist-evar' )->rawParams( 'foo', 123 )->exists() );
 12+ }
 13+
 14+ function testKey() {
 15+ $this->assertType( 'Message', Message::key( 'mainpage' ) );
 16+ $this->assertType( 'Message', Message::key( 'i-dont-exist-evar' ) );
 17+ $this->assertEquals( 'Main Page', Message::key( 'mainpage' )->text() );
 18+ $this->assertEquals( '&lt;i-dont-exist-evar&gt;', Message::key( 'i-dont-exist-evar' )->text() );
 19+ }
 20+}
\ No newline at end of file
Property changes on: trunk/phase3/maintenance/tests/MessageTest.php
___________________________________________________________________
Name: svn:eol-style
121 + native
Index: trunk/phase3/includes/Message.php
@@ -277,7 +277,7 @@
278278 * @return Bool: true if it is and false if not.
279279 */
280280 public function exists() {
281 - return $this->fetchMessage() === false;
 281+ return $this->fetchMessage() !== false;
282282 }
283283
284284 public static function rawParam( $value ) {

Status & tagging log