1 | <?php |
||
2 | |||
3 | /** |
||
4 | * Provides test methods for commenting functionality. |
||
5 | */ |
||
6 | class CommentTest extends TWFY_Database_TestCase |
||
7 | { |
||
8 | |||
9 | /** |
||
10 | * Loads the comments testing fixture. |
||
11 | */ |
||
12 | public function getDataSet() |
||
13 | { |
||
14 | return $this->createMySQLXMLDataSet(dirname(__FILE__).'/_fixtures/comment.xml'); |
||
0 ignored issues
–
show
|
|||
15 | } |
||
16 | |||
17 | /** |
||
18 | * Ensures the database is prepared and the comment class is included for every test. |
||
19 | */ |
||
20 | public function setUp(): void { |
||
21 | |||
22 | parent::setUp(); |
||
23 | |||
24 | include_once('www/includes/easyparliament/comment.php'); |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * Makes sure the body of the test comment is returned correctly, testing HTML cleaning. |
||
29 | */ |
||
30 | public function testHTMLCleaningGetBody() |
||
31 | { |
||
32 | $comment = new COMMENT(1); |
||
33 | $this->assertEquals($comment->body(), "This is a test comment, including https://www.theyworkforyou.com <a href=\"https://www.theyworkforyou.com\">links</a>, email addresses like [email protected], <b>bold</b>, <i>italics</i>, and stray < brackets to ensure they're rendered correctly. |
||
34 | |||
35 | It also spans multiple lines."); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Makes sure a comment is correctly rendered, testing HTML cleaning. |
||
40 | */ |
||
41 | public function testHTMLCleaningPrepareCommentForDisplay() |
||
42 | { |
||
43 | $comment = new COMMENT(1); |
||
44 | $this->assertEquals(prepare_comment_for_display($comment->body()), "This is a test comment, including <a href=\"https://www.theyworkforyou.com\" rel=\"nofollow\">https://www.theyworkforyou.com</a> <a href=\"https://www.theyworkforyou.com\">links</a>, email addresses like <a href=\"mailto:[email protected]\">[email protected]</a>, <b>bold</b>, <i>italics</i>, and stray < brackets to ensure they're rendered correctly.<br> |
||
45 | <br> |
||
46 | It also spans multiple lines."); |
||
47 | } |
||
48 | |||
49 | public function testCommentWithVeryLongLink() |
||
50 | { |
||
51 | $comment = new COMMENT(2); |
||
52 | $this->assertEquals(prepare_comment_for_display($comment->body()), |
||
53 | '<a href="https://www.theyworkforyou.example.org/this/is/a/coment/with/a/very/long/URL/that/contains/http://something/as/it/is/an/archive" rel="nofollow">https://www.theyworkforyou.example.org/this/is/a/coment/with...</a>'); |
||
54 | } |
||
55 | |||
56 | public function testHTMLCleaningOfAngleBrackets() { |
||
57 | $text = 'Is 2 < 3?'; |
||
58 | |||
59 | $this->assertEquals('Is 2 < 3?', filter_user_input( $text, 'comment' ) ); |
||
60 | } |
||
61 | |||
62 | public function testHTMLCleaningWithNonASCIIChars() |
||
63 | { |
||
64 | // this file is UTF-8 but odd comments are sent up looking like Windows-1252 so we need the |
||
65 | // input text to be encoded thus otherwise the output is different |
||
66 | $text = "This is a curly ’ apostrophe. Is 2 < 3 ø ø € ’ « ö à"; |
||
67 | |||
68 | $this->assertEquals("This is a curly ’ apostrophe. Is 2 < 3 ø ø € ’ « ö à", prepare_comment_for_display($text)); |
||
69 | } |
||
70 | |||
71 | } |
||
72 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.