1 | <?php |
---|
2 | /** |
---|
3 | * Tests the `fetch_feed` function. |
---|
4 | * |
---|
5 | * @package WordPress |
---|
6 | * @subpackage UnitTests |
---|
7 | * @since 6.7.0 |
---|
8 | * |
---|
9 | * @group feed |
---|
10 | */ |
---|
11 | class Tests_Feed_fetchFeed extends WP_UnitTestCase { |
---|
12 | |
---|
13 | public function set_up() { |
---|
14 | parent::set_up(); |
---|
15 | |
---|
16 | add_filter( 'pre_http_request', array( $this, 'mocked_rss_response' ) ); |
---|
17 | } |
---|
18 | |
---|
19 | /** |
---|
20 | * @ticket 62354 |
---|
21 | */ |
---|
22 | public function test_empty_charset_does_not_trigger_fatal_error() { |
---|
23 | add_filter( 'pre_option_blog_charset', '__return_empty_string', 20 ); |
---|
24 | |
---|
25 | $feed = fetch_feed( 'https://wordpress.org/news/feed/' ); |
---|
26 | } |
---|
27 | |
---|
28 | public function mocked_rss_response() { |
---|
29 | $single_value_headers = array( |
---|
30 | 'Content-Type' => 'application/rss+xml; charset=UTF-8', |
---|
31 | 'link' => '<https://wordpress.org/news/wp-json/>; rel="https://api.w.org/"', |
---|
32 | ); |
---|
33 | |
---|
34 | return array( |
---|
35 | 'headers' => new WpOrg\Requests\Utility\CaseInsensitiveDictionary( $single_value_headers ), |
---|
36 | 'body' => file_get_contents( DIR_TESTDATA . '/feed/wordpress-org-news.xml' ), |
---|
37 | 'response' => array( |
---|
38 | 'code' => 200, |
---|
39 | 'message' => 'OK', |
---|
40 | ), |
---|
41 | 'cookies' => array(), |
---|
42 | 'filename' => null, |
---|
43 | ); |
---|
44 | } |
---|
45 | } |
---|