Make WordPress Core


Ignore:
Timestamp:
10/16/2024 02:17:12 PM (7 weeks ago)
Author:
SergeyBiryukov
Message:

Tests: Correct test class name for rss_enclosure() as per the naming conventions.

Includes:

  • Moving @covers tags to the class-level DocBlock, since this is the only function tested in the class.
  • Adjusting the assertion messages for clarity, as rss_enclosure() does not return anything directly.
  • Using a static closure for improved performance.

Follow-up to [59241].

See #61530.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/feed/rssEnclosure.php

    r59241 r59243  
    22
    33/**
    4  * Test the feed.
     4 * Tests for the rss_enclosure() function.
    55 *
    66 * @group feed
     7 *
     8 * @covers ::rss_enclosure
    79 */
    8 class Tests_rssEnclosure extends WP_UnitTestCase {
     10class Tests_Feed_RssEnclosure extends WP_UnitTestCase {
     11
    912    /**
    1013     * @ticket 58798
    11      *
    12      * @covers ::rss_enclosure
    1314     */
    1415    public function test_rss_enclosure_filter() {
     
    2223        add_filter(
    2324            'rss_enclosure',
    24             function () {
     25            static function () {
    2526                return 'filtered_html_link_tag';
    2627            }
     
    3233    /**
    3334     * @ticket 58798
    34      *
    35      * @covers ::rss_enclosure
    3635     */
    3736    public function test_rss_enclosure_when_global_post_is_empty() {
    38         $this->assertEmpty( get_echo( 'rss_enclosure' ), 'It should return empty when the global post is not set.' );
     37        $this->assertEmpty( get_echo( 'rss_enclosure' ), 'The output should be empty when the global post is not set.' );
    3938    }
    4039
    4140    /**
    4241     * @ticket 58798
    43      *
    44      * @covers ::rss_enclosure
    4542     */
    4643    public function test_rss_enclosure_when_enclosure_meta_field_is_empty() {
     
    4845        $GLOBALS['post'] = $post_id;
    4946
    50         $this->assertEmpty( get_echo( 'rss_enclosure' ), 'The global post does not have the `enclosure` meta field and should return empty. ' );
     47        $this->assertEmpty( get_echo( 'rss_enclosure' ), 'The output should be empty when the global post does not have the `enclosure` meta field.' );
    5148    }
    5249
     
    5552     *
    5653     * @dataProvider data_rss_enclosure_with_multiline_enclosure_string
    57      * @covers ::rss_enclosure
    5854     */
    5955    public function test_rss_enclosure_with_multiline_enclosure_string( $enclosure_data, $enclosure_string ) {
     
    6561        $expected = '<enclosure url="' . $enclosure_data['url'] . '" length="' . $enclosure_data['length'] . '" type="' . $enclosure_data['type'] . '" />' . "\n";
    6662
    67         $this->assertSame( $expected, get_echo( 'rss_enclosure' ), 'It should return a valid enclosure tag. ' );
     63        $this->assertSame( $expected, get_echo( 'rss_enclosure' ), 'The output should be a valid enclosure tag.' );
    6864    }
    6965
     
    7167     * Data provider for valid enclosure string.
    7268     *
    73      * @return array[].
     69     * @return array[]
    7470     */
    7571    public function data_rss_enclosure_with_multiline_enclosure_string() {
     
    114110     *
    115111     * @dataProvider data_rss_enclosure_with_non_valid_enclosure_string
    116      * @covers ::rss_enclosure
    117112     */
    118113    public function test_rss_enclosure_with_non_valid_enclosure_string( $enclosure_string ) {
     
    122117        update_post_meta( $post_id, 'enclosure', $enclosure_string );
    123118
    124         $this->assertEmpty( get_echo( 'rss_enclosure' ), 'It should return empty when the `enclosure` meta field is not saved in a multiline string.' );
     119        $this->assertEmpty( get_echo( 'rss_enclosure' ), 'The output should be empty when the `enclosure` meta field is not saved in a multiline string.' );
    125120    }
    126121
     
    128123     * Data provider for non-valid enclosure string.
    129124     *
    130      * @return array[].
     125     * @return array[]
    131126     */
    132127    public function data_rss_enclosure_with_non_valid_enclosure_string() {
Note: See TracChangeset for help on using the changeset viewer.