mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebfb764
commit 8ac92e5
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* Tests the `fetch_feed` function. | ||
* | ||
* @package WordPress | ||
* @subpackage UnitTests | ||
* @since 6.7.0 | ||
* | ||
* @group feed | ||
*/ | ||
class Tests_Feed_fetchFeed extends WP_UnitTestCase { | ||
|
||
public function set_up() { | ||
parent::set_up(); | ||
|
||
add_filter( 'pre_http_request', array( $this, 'mocked_rss_response' ) ); | ||
} | ||
|
||
/** | ||
* @ticket 62354 | ||
*/ | ||
public function test_empty_charset_does_not_trigger_fatal_error() { | ||
add_filter( 'pre_option_blog_charset', '__return_empty_string', 20 ); | ||
|
||
$feed = fetch_feed( 'https://wordpress.org/news/feed/' ); | ||
} | ||
|
||
public function mocked_rss_response() { | ||
$single_value_headers = array( | ||
'Content-Type' => 'application/rss+xml; charset=UTF-8', | ||
'link' => '<https://wordpress.org/news/wp-json/>; rel="https://api.w.org/"', | ||
); | ||
|
||
return array( | ||
'headers' => new WpOrg\Requests\Utility\CaseInsensitiveDictionary( $single_value_headers ), | ||
'body' => file_get_contents( DIR_TESTDATA . '/feed/wordpress-org-news.xml' ), | ||
'response' => array( | ||
'code' => 200, | ||
'message' => 'OK', | ||
), | ||
'cookies' => array(), | ||
'filename' => null, | ||
); | ||
} | ||
} |