Deprecate Content::getNativeData, add TextContent::getText
[lhc/web/wiklou.git] / tests / phpunit / includes / content / MessageContentTest.php
1 <?php
2
3 /**
4 * @group ContentHandler
5 */
6 class MessageContentTest extends MediaWikiLangTestCase {
7
8 public function testGetHtml() {
9 $msg = new Message( 'about' );
10 $cnt = new MessageContent( $msg );
11
12 $this->assertSame( $msg->parse(), $cnt->getHtml() );
13 }
14
15 public function testGetWikitext() {
16 $msg = new Message( 'about' );
17 $cnt = new MessageContent( $msg );
18
19 $this->assertSame( $msg->text(), $cnt->getWikitext() );
20 }
21
22 public function testGetMessage() {
23 $msg = new Message( 'about' );
24 $cnt = new MessageContent( $msg );
25
26 $this->assertEquals( $msg, $cnt->getMessage() );
27 }
28
29 public function testGetParserOutput() {
30 $msg = new Message( 'about' );
31 $cnt = new MessageContent( $msg );
32
33 $title = Title::makeTitle( NS_MEDIAWIKI, 'about' );
34
35 $this->assertSame( $msg->parse(), $cnt->getParserOutput( $title )->getText() );
36 }
37
38 public function testSerialize() {
39 $msg = new Message( 'about' );
40 $cnt = new MessageContent( $msg );
41
42 $this->assertSame( $msg->plain(), $cnt->serialize() );
43 }
44
45 public function testEquals() {
46 $msg1 = new Message( 'about' );
47 $cnt1 = new MessageContent( $msg1 );
48
49 $msg2 = new Message( 'about' );
50 $cnt2 = new MessageContent( $msg2 );
51
52 $msg3 = new Message( 'faq' );
53 $cnt3 = new MessageContent( $msg3 );
54 $cnt4 = new WikitextContent( $msg3->plain() );
55
56 $this->assertTrue( $cnt1->equals( $cnt2 ) );
57 $this->assertFalse( $cnt1->equals( $cnt3 ) );
58 $this->assertFalse( $cnt1->equals( $cnt4 ) );
59 }
60 }