Debian Codegraph @

tests/phpunit/unit/includes/CommentFormatter/CommentItemTest.php

raw symbols SCIP
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @since 1.42
20 */
21
22 namespace MediaWiki\Tests\Unit\CommentFormatter;
23
24 use MediaWiki\CommentFormatter\CommentItem;
25 use MediaWiki\Linker\LinkTarget;
26 use MediaWikiUnitTestCase;
27
28 /**
29 * @group CommentFormatter
30 * @covers \MediaWiki\CommentFormatter\CommentItem
31 */
32 class CommentItemTest extends MediaWikiUnitTestCase {
33
34 /**
35 * Test the constructor of the CommentItem class.
36 */
37 public function testConstruct() {
38 // Create a new CommentItem object
39 $comment = new CommentItem( 'foo' );
40 // Verify the comment property is set to 'foo'
41 $this->assertSame( 'foo', $comment->comment );
42 }
43
44 /**
45 * Test the selfLinkTarget method of the CommentItem class.
46 */
47 public function testSelfLinkTarget() {
48 // Create a new CommentItem object
49 $comment = new CommentItem( 'foo' );
50 // Create a mock LinkTarget object
51 $target = $this->createMock( LinkTarget::class );
52 // Set the selfLinkTarget to the mock LinkTarget object
53 $comment->selfLinkTarget( $target );
54 // Verify the selfLinkTarget property is set to the mock LinkTarget object
55 $this->assertSame( $target, $comment->selfLinkTarget );
56 }
57
58 /**
59 * Test the samePage method of the CommentItem class.
60 */
61 public function testSamePage() {
62 // Create a new CommentItem object
63 $comment = new CommentItem( 'foo' );
64 // Verify the samePage property is true
65 $this->assertTrue( $comment->samePage()->samePage );
66
67 $this->assertInstanceOf( CommentItem::class, $comment->samePage() );
68
69 $this->assertFalse( $comment->samePage( false )->samePage );
70
71 $this->assertTrue( $comment->samePage( true )->samePage );
72 }
73
74 /**
75 * Test the wikiId method of the CommentItem class with various values.
76 */
77 public function testWikiId() {
78 // Create a new CommentItem object
79 $comment = new CommentItem( 'foo' );
80 // Set the wikiId to 'bar'
81 $comment->wikiId( 'bar' );
82 // Verify the wikiId property is set to 'bar'
83 $this->assertSame( 'bar', $comment->wikiId );
84 // Set the wikiId to false
85 $comment->wikiId( false );
86 // Verify the wikiId property is false
87 $this->assertFalse( $comment->wikiId );
88 // Set the wikiId to null
89 $comment->wikiId( null );
90 // Verify the wikiId property is null
91 $this->assertNull( $comment->wikiId );
92 }
93 }