Skip to content

Commit 950b42f

Browse files
committed
Improving Unit Tests
1 parent bafd51b commit 950b42f

File tree

3 files changed

+17
-49
lines changed

3 files changed

+17
-49
lines changed

src/wp-includes/widgets.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1644,7 +1644,7 @@ function wp_widget_rss_output( $rss, $args = array() ) {
16441644
}
16451645
$link = esc_url( strip_tags( $link ) );
16461646

1647-
$title = esc_html( trim( strip_tags( $item->get_title() ) ) );
1647+
$title = esc_html( trim( strip_tags( html_entity_decode( $item->get_title() ) ) ) );
16481648
if ( empty( $title ) ) {
16491649
$title = __( 'Untitled' );
16501650
}

tests/phpunit/data/feed/wordpress-org-news.xml

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -854,57 +854,20 @@
854854

855855
<post-id xmlns="com-wordpress:feed-additions:1">9225</post-id> </item>
856856
<item>
857-
<title>WordPress 5.5.3 Maintenance Release</title>
858-
<link>https://wordpress.org/news/2020/10/wordpress-5-5-3-maintenance-release/</link>
857+
<title>Title with &lt;em&gt;HTML entities&lt;/em&gt;</title>
858+
<link>https://wordpress.org/news/2020/10/mock-html-entities/</link>
859859

860-
<dc:creator><![CDATA[Jake Spurlock]]></dc:creator>
861-
<pubDate>Fri, 30 Oct 2020 20:25:44 +0000</pubDate>
862-
<category><![CDATA[Releases]]></category>
863-
<guid isPermaLink="false">https://wordpress.org/news/?p=9212</guid>
864-
865-
<description><![CDATA[WordPress 5.5.3 is now available.&#160; This maintenance release fixes an issue introduced in WordPress 5.5.2 which makes it impossible to install WordPress on a brand new website that does not have a database connection configured. This release does not affect sites where a database connection is already configured, for example, via one-click installers or an [&#8230;]]]></description>
866-
<content:encoded><![CDATA[
867-
<p>WordPress 5.5.3 is now available.&nbsp;</p>
868-
869-
870-
871-
<p>This maintenance release fixes an issue introduced in WordPress 5.5.2 which makes it impossible to install WordPress on a brand new website that does not have a database connection configured. This release does not affect sites where a database connection is already configured, for example, via one-click installers or an existing <code>wp-config.php</code> file.</p>
872-
873-
874-
875-
<h2>5.5.3-alpha Issue</h2>
876-
877-
878-
879-
<p>Earlier today &#8212; between approximately 15:30 and 16:00 UTC &#8212; the auto-update system for WordPress updated some sites from version 5.5.2 to version 5.5.3-alpha. This auto-update was due to an error in the Updates API caused by the 5.5.3 release preparations (<a href="https://wordpress.org/support/topic/wordpress-5-5-3-alpha-auto-updates/">see more here</a>). The 5.5.3-alpha version at this point was functionally identical to 5.5.2 as no development work had been started on 5.5.3; however, the following changes may have been made to your site:</p>
880-
881-
882-
883-
<ul><li>The default “Twenty” themes installed as part of the pre-release package.</li><li>The “Akismet” plugin installed as part of the pre-release package.</li></ul>
860+
<dc:creator><![CDATA[Mock Author]]></dc:creator>
861+
<pubDate>Mon, 26 Oct 2020 12:00:00 +0000</pubDate>
862+
<category><![CDATA[Mock Category]]></category>
863+
<guid isPermaLink="false">https://wordpress.org/news/?p=9999</guid>
884864

885-
886-
887-
<p>These themes and plugins were not activated and therefore remain non-functional unless you installed them previously. It is safe to delete these features should you prefer not to use them.&nbsp;</p>
888-
889-
890-
891-
<p>If you are not on 5.5.2, or have auto-updates for minor releases disabled, please manually update to the 5.5.3 version by downloading WordPress 5.5.3 or visiting Dashboard → Updates and click “Update Now.”</p>
892-
893-
894-
895-
<p>For more technical details of the issue, we’ve <a href="https://make.wordpress.org/core/2020/10/30/wordpress-5-5-3-release-some-technical-details/">posted on our Core Development blog</a>.</p>
896-
897-
898-
899-
<h2>Thanks and props!</h2>
900-
901-
902-
903-
<p>Thanks to those who contributed to the 5.5.3 release: <a href='https://profiles.wordpress.org/audrasjb/' class='mention'><span class='mentions-prefix'>@</span>audrasjb</a>, <a href='https://profiles.wordpress.org/barry/' class='mention'><span class='mentions-prefix'>@</span>barry</a>, <a href='https://profiles.wordpress.org/chanthaboune/' class='mention'><span class='mentions-prefix'>@</span>chanthaboune</a>, <a href='https://profiles.wordpress.org/cbringmann/' class='mention'><span class='mentions-prefix'>@</span>cbringmann</a>, <a href='https://profiles.wordpress.org/clorith/' class='mention'><span class='mentions-prefix'>@</span>clorith</a>, <a href='https://profiles.wordpress.org/davidbaumwald/' class='mention'><span class='mentions-prefix'>@</span>davidbaumwald</a>, <a href='https://profiles.wordpress.org/desrosj/' class='mention'><span class='mentions-prefix'>@</span>desrosj</a>, <a href='https://profiles.wordpress.org/hellofromtonya/' class='mention'><span class='mentions-prefix'>@</span>hellofromtonya</a>, <a href='https://profiles.wordpress.org/jeffpaul/' class='mention'><span class='mentions-prefix'>@</span>jeffpaul</a>, <a href='https://profiles.wordpress.org/johnbillion/' class='mention'><span class='mentions-prefix'>@</span>johnbillion</a>, <a href='https://profiles.wordpress.org/garubi/' class='mention'><span class='mentions-prefix'>@</span>garubi</a>, <a href='https://profiles.wordpress.org/metalandcoffee/' class='mention'><span class='mentions-prefix'>@</span>metalandcoffee</a>, <a href='https://profiles.wordpress.org/mukesh27/' class='mention'><span class='mentions-prefix'>@</span>mukesh27</a>, <a href='https://profiles.wordpress.org/otto42/' class='mention'><span class='mentions-prefix'>@</span>otto42</a>, <a href='https://profiles.wordpress.org/punitsoftac/' class='mention'><span class='mentions-prefix'>@</span>punitsoftac</a>, <a href='https://profiles.wordpress.org/sergeybiryukov/' class='mention'><span class='mentions-prefix'>@</span>sergeybiryukov</a>, <a href='https://profiles.wordpress.org/whyisjake/' class='mention'><span class='mentions-prefix'>@</span>whyisjake</a>, and <a href='https://profiles.wordpress.org/xknown/' class='mention'><span class='mentions-prefix'>@</span>xknown</a>.</p>
865+
<description><![CDATA[Mock description for item with HTML entities in the title.]]></description>
866+
<content:encoded><![CDATA[
867+
<p>This mock entry validates handling of HTML entities within item titles.</p>
904868
]]></content:encoded>
905869

906870

907-
908-
<post-id xmlns="com-wordpress:feed-additions:1">9212</post-id> </item>
871+
<post-id xmlns="com-wordpress:feed-additions:1">9999</post-id> </item>
909872
</channel>
910873
</rss>

tests/phpunit/tests/widgets/wpWidgetRss.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function data_url_unhappy_path() {
5858

5959
/**
6060
* @ticket 53278
61+
* @ticket 63611
6162
* @covers WP_Widget_RSS::widget
6263
* @dataProvider data_url_happy_path
6364
*
@@ -92,10 +93,14 @@ public function test_url_happy_path( $url, $expected ) {
9293

9394
public function data_url_happy_path() {
9495
return array(
95-
'when url is given' => array(
96+
'when url is given' => array(
9697
'url' => 'https://wordpress.org/news/feed/',
9798
'<section id="widget_rss-5" class="widget widget_rss"><h2><a class="rsswidget rss-widget-feed" href="https://wordpress.org/news/feed/">',
9899
),
100+
'when title has special HTML Entities' => array(
101+
'url' => 'https://wordpress.org/news/feed/',
102+
'Title with HTML entities',
103+
),
99104
);
100105
}
101106

0 commit comments

Comments
 (0)