- Timestamp:
- 07/19/2021 02:00:11 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/widgets/media-image-widget.php
r49215 r51462 451 451 452 452 // No default title. 453 $this->assert NotContains( 'title="', $output );453 $this->assertStringNotContainsString( 'title="', $output ); 454 454 // Default image classes. 455 $this->assert Contains( 'class="image wp-image-' . $attachment_id, $output );456 $this->assert Contains( 'style="max-width: 100%; height: auto;"', $output );457 $this->assert Contains( 'alt=""', $output );455 $this->assertStringContainsString( 'class="image wp-image-' . $attachment_id, $output ); 456 $this->assertStringContainsString( 'style="max-width: 100%; height: auto;"', $output ); 457 $this->assertStringContainsString( 'alt=""', $output ); 458 458 459 459 ob_start(); … … 472 472 473 473 // Custom image title. 474 $this->assert Contains( 'title="Custom Title"', $output );474 $this->assertStringContainsString( 'title="Custom Title"', $output ); 475 475 // Custom image class. 476 $this->assert Contains( 'class="image wp-image-' . $attachment_id . ' custom-class', $output );477 $this->assert Contains( 'alt="A flower"', $output );478 $this->assert Contains( 'width="100"', $output );479 $this->assert Contains( 'height="100"', $output );476 $this->assertStringContainsString( 'class="image wp-image-' . $attachment_id . ' custom-class', $output ); 477 $this->assertStringContainsString( 'alt="A flower"', $output ); 478 $this->assertStringContainsString( 'width="100"', $output ); 479 $this->assertStringContainsString( 'height="100"', $output ); 480 480 481 481 // Embeded images. … … 494 494 495 495 // Custom image class. 496 $this->assert Contains( 'src="http://example.org/url/to/image.jpg"', $output );496 $this->assertStringContainsString( 'src="http://example.org/url/to/image.jpg"', $output ); 497 497 498 498 // Link settings. … … 507 507 508 508 $link = '<a href="' . wp_get_attachment_url( $attachment_id ) . '"'; 509 $this->assert Contains( $link, $output );509 $this->assertStringContainsString( $link, $output ); 510 510 $this->assertTrue( (bool) preg_match( '#<a href.*?>#', $output, $matches ) ); 511 $this->assert NotContains( ' class="', $matches[0] );512 $this->assert NotContains( ' rel="', $matches[0] );513 $this->assert NotContains( ' target="', $matches[0] );511 $this->assertStringNotContainsString( ' class="', $matches[0] ); 512 $this->assertStringNotContainsString( ' rel="', $matches[0] ); 513 $this->assertStringNotContainsString( ' target="', $matches[0] ); 514 514 515 515 ob_start(); … … 525 525 $output = ob_get_clean(); 526 526 527 $this->assert Contains( '<a href="' . get_attachment_link( $attachment_id ) . '"', $output );528 $this->assert Contains( 'class="custom-link-class"', $output );529 $this->assert Contains( 'rel="attachment"', $output );530 $this->assert NotContains( 'target=""', $output );527 $this->assertStringContainsString( '<a href="' . get_attachment_link( $attachment_id ) . '"', $output ); 528 $this->assertStringContainsString( 'class="custom-link-class"', $output ); 529 $this->assertStringContainsString( 'rel="attachment"', $output ); 530 $this->assertStringNotContainsString( 'target=""', $output ); 531 531 532 532 ob_start(); … … 541 541 $output = ob_get_clean(); 542 542 543 $this->assert Contains( '<a href="https://example.org"', $output );544 $this->assert Contains( 'target="_blank"', $output );545 $this->assert Contains( 'rel="noopener"', $output );543 $this->assertStringContainsString( '<a href="https://example.org"', $output ); 544 $this->assertStringContainsString( 'target="_blank"', $output ); 545 $this->assertStringContainsString( 'rel="noopener"', $output ); 546 546 547 547 // Populate caption in attachment. … … 561 561 ); 562 562 $output = ob_get_clean(); 563 $this->assert NotContains( 'wp-caption', $output );564 $this->assert NotContains( '<p class="wp-caption-text">', $output );563 $this->assertStringNotContainsString( 'wp-caption', $output ); 564 $this->assertStringNotContainsString( '<p class="wp-caption-text">', $output ); 565 565 566 566 // If the caption is explicitly null, then the caption of the underlying attachment will be displayed. … … 573 573 ); 574 574 $output = ob_get_clean(); 575 $this->assert Contains( 'class="wp-caption alignnone"', $output );576 $this->assert Contains( '<p class="wp-caption-text">Default caption</p>', $output );575 $this->assertStringContainsString( 'class="wp-caption alignnone"', $output ); 576 $this->assertStringContainsString( '<p class="wp-caption-text">Default caption</p>', $output ); 577 577 578 578 // If caption is provided, then it will be displayed. … … 585 585 ); 586 586 $output = ob_get_clean(); 587 $this->assert Contains( 'class="wp-caption alignnone"', $output );588 $this->assert Contains( '<p class="wp-caption-text">Custom caption</p>', $output );587 $this->assertStringContainsString( 'class="wp-caption alignnone"', $output ); 588 $this->assertStringContainsString( '<p class="wp-caption-text">Custom caption</p>', $output ); 589 589 590 590 // Attachments with custom sizes can render captions. … … 600 600 ); 601 601 $output = ob_get_clean(); 602 $this->assert Contains( 'style="width: 310px"', $output );603 $this->assert Contains( '<p class="wp-caption-text">Caption for an image with custom size</p>', $output );602 $this->assertStringContainsString( 'style="width: 310px"', $output ); 603 $this->assertStringContainsString( '<p class="wp-caption-text">Caption for an image with custom size</p>', $output ); 604 604 } 605 605 … … 629 629 $output = ob_get_clean(); 630 630 631 $this->assert Contains( '<script type="text/html" id="tmpl-wp-media-widget-image-preview">', $output );631 $this->assertStringContainsString( '<script type="text/html" id="tmpl-wp-media-widget-image-preview">', $output ); 632 632 } 633 633 }
Note: See TracChangeset
for help on using the changeset viewer.