Make WordPress Core


Ignore:
Timestamp:
09/20/2017 07:44:13 PM (7 years ago)
Author:
westonruter
Message:

Widgets: Omit attributes from an Image widget's link when they are empty.

Props subrataemfluence, Nenad Obradovic, westonruter.
See #39993.
Fixes #41919.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/widgets/media-image-widget.php

    r40674 r41549  
    394394        $link = '<a href="' . wp_get_attachment_url( $attachment_id ) . '"';
    395395        $this->assertContains( $link, $output );
    396         $link .= ' class=""';
    397         $this->assertContains( $link, $output );
    398         $link .= ' rel=""';
    399         $this->assertContains( $link, $output );
    400         $link .= ' target=""';
    401         $this->assertContains( $link, $output );
     396        $this->assertTrue( (bool) preg_match( '#<a href.*?>#', $output, $matches ) );
     397        $this->assertNotContains( ' class="', $matches[0] );
     398        $this->assertNotContains( ' rel="', $matches[0] );
     399        $this->assertNotContains( ' target="', $matches[0] );
    402400
    403401        ob_start();
     
    414412        $this->assertContains( 'class="custom-link-class"', $output );
    415413        $this->assertContains( 'rel="attachment"', $output );
    416         $this->assertContains( 'target=""', $output );
     414        $this->assertNotContains( 'target=""', $output );
    417415
    418416        ob_start();
Note: See TracChangeset for help on using the changeset viewer.