Skip to content

Commit e469162

Browse files
committed
test: Add unit test for HTML entities decoding in RSS title output
1 parent 71c1ca0 commit e469162

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/phpunit/tests/widgets/wpWidgetRss.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,47 @@ public function mocked_rss_response() {
116116
'filename' => null,
117117
);
118118
}
119+
120+
/**
121+
* @ticket 63611
122+
* @covers wp_widget_rss_output
123+
*/
124+
public function test_rss_title_html_entities_decoded() {
125+
$mock_item = $this->getMockBuilder( 'SimplePie_Item' )
126+
->disableOriginalConstructor()
127+
->getMock();
128+
129+
$mock_item->method( 'get_title' )
130+
->willReturn( 'Title with <em>HTML entities</em>' );
131+
132+
$mock_item->method( 'get_link' )
133+
->willReturn( 'https://example.com' );
134+
135+
$mock_item->method( 'get_description' )
136+
->willReturn( 'Description' );
137+
138+
$mock_item->method( 'get_date' )
139+
->willReturn( false );
140+
141+
$mock_item->method( 'get_author' )
142+
->willReturn( false );
143+
144+
$mock_rss = $this->getMockBuilder( 'SimplePie' )
145+
->disableOriginalConstructor()
146+
->getMock();
147+
148+
$mock_rss->method( 'get_item_quantity' )
149+
->willReturn( 1 );
150+
151+
$mock_rss->method( 'get_items' )
152+
->willReturn( array( $mock_item ) );
153+
154+
ob_start();
155+
wp_widget_rss_output( $mock_rss );
156+
$output = ob_get_clean();
157+
158+
$this->assertStringContainsString( 'Title with HTML entities', $output );
159+
$this->assertStringNotContainsString( '<em>', $output );
160+
$this->assertStringNotContainsString( '</em>', $output );
161+
}
119162
}

0 commit comments

Comments
 (0)