Make WordPress Core

Changeset 52396


Ignore:
Timestamp:
12/21/2021 12:10:26 AM (22 months ago)
Author:
hellofromTonya
Message:

General: Fix 'rel' argument in Tests_Functions_wpListBookmarks test datasets.

wp_list_bookmarks() arguments include 'link_rel', but not 'rel'. This commit fixes this argument in the test datasets. It also adds an expected 'rel=""' result check, i.e. instead of only checking for 'noopener'.

Follow-up to [52395].

Props davidbinda.
Fixes #53839.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/bookmark/wpListBookmarks.php

    r52061 r52396  
    1616     * @ticket 53839
    1717     *
    18      * @param array $args The arguments to create the bookmark.
     18     * @param array $args      The arguments to create the bookmark.
     19     * @param string $expected Expected string to test.
    1920     */
    20     public function test_wp_list_bookmarks_adds_noopener( $args ) {
    21         $bookmark = self::factory()->bookmark->create( $args );
    22         $this->assertStringContainsString( 'noopener', wp_list_bookmarks( 'echo=0' ) );
     21    public function test_wp_list_bookmarks_adds_noopener( $args, $expected ) {
     22        self::factory()->bookmark->create( $args );
     23        $this->assertStringContainsString( $expected, wp_list_bookmarks( 'echo=0' ) );
    2324    }
    2425
     
    3132        return array(
    3233            'target as "_blank"'                         => array(
    33                 'args' => array(
     34                'args'     => array(
    3435                    'link_name'   => 'With _blank',
    3536                    'link_url'    => 'https://www.wordpress.org',
    3637                    'link_target' => '_blank',
    3738                ),
     39                'expected' => 'rel="noopener"',
    3840            ),
    3941            'target as "_blank" and a link relationship' => array(
    40                 'args' => array(
     42                'args'     => array(
    4143                    'link_name'   => 'With _blank and a link relationship',
    4244                    'link_url'    => 'https://www.wordpress.org',
    4345                    'link_target' => '_blank',
    44                     'rel'         => 'me',
     46                    'link_rel'    => 'me',
    4547                ),
     48                'expected' => 'rel="me noopener"',
    4649            ),
    4750            'target as "_top"'                           => array(
    48                 'args' => array(
     51                'args'     => array(
    4952                    'link_name'   => 'With _top',
    5053                    'link_url'    => 'https://www.wordpress.org',
    5154                    'link_target' => '_top',
    5255                ),
     56                'expected' => 'rel="noopener"',
    5357            ),
    5458            'target as "_top" and a link relationship'   => array(
    55                 'args' => array(
     59                'args'     => array(
    5660                    'link_name'   => 'With _top and a link relationship',
    5761                    'link_url'    => 'https://www.wordpress.org',
    5862                    'link_target' => '_top',
    59                     'rel'         => 'me',
     63                    'link_rel'    => 'me',
    6064                ),
     65                'expected' => 'rel="me noopener"',
    6166            ),
    6267        );
     
    7378     */
    7479    public function test_wp_list_bookmarks_does_not_add_noopener( $args ) {
    75         $bookmark = self::factory()->bookmark->create( $args );
     80        self::factory()->bookmark->create( $args );
    7681        $this->assertStringNotContainsString( 'noopener', wp_list_bookmarks( 'echo=0' ) );
    7782    }
     
    96101                    'link_url'    => 'https://www.wordpress.org',
    97102                    'link_target' => '_none',
    98                     'rel'         => 'me',
     103                    'link_rel'    => 'me',
    99104                ),
    100105            ),
Note: See TracChangeset for help on using the changeset viewer.