Changeset 60415 for trunk/tests/phpunit/tests/media.php
- Timestamp:
- 07/05/2025 06:55:29 PM (7 months ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/media.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/media.php
r60285 r60415 1582 1582 1583 1583 $this->assertSame( $expected, $output ); 1584 } 1585 1586 /** 1587 * @ticket 14110 1588 */ 1589 public function test_wp_get_attachment_image_filter_with_height_width() { 1590 $mock_action = new MockAction(); 1591 add_filter( 'wp_get_attachment_image_attributes', array( $mock_action, 'filter' ) ); 1592 wp_get_attachment_image( self::$large_id ); 1593 $args = $mock_action->get_args(); 1594 $this->assertArrayHasKey( '0', $args, 'First argument should be an array.' ); 1595 $this->assertArrayHasKey( '0', $args[0], 'First argument should be an array.' ); 1596 $this->assertArrayHasKey( 'width', $args[0][0], 'Width should be set.' ); 1597 $this->assertArrayHasKey( 'height', $args[0][0], 'Height should be set.' ); 1598 } 1599 1600 /** 1601 * @ticket 14110 1602 */ 1603 public function test_wp_get_attachment_image_filter_change_height_width() { 1604 add_filter( 1605 'wp_get_attachment_image_attributes', 1606 static function ( $args ) { 1607 $args['height'] = '999'; 1608 $args['width'] = '999'; 1609 return $args; 1610 } 1611 ); 1612 $output = wp_get_attachment_image( self::$large_id ); 1613 $this->assertStringContainsString( 'width="999"', $output, 'Width should be changed.' ); 1614 $this->assertStringContainsString( 'height="999"', $output, 'Height should be changed.' ); 1615 } 1616 1617 /** 1618 * @ticket 14110 1619 */ 1620 public function test_wp_get_attachment_image_filter_unset_height_width() { 1621 add_filter( 1622 'wp_get_attachment_image_attributes', 1623 static function ( $args ) { 1624 unset( $args['height'], $args['width'] ); 1625 return $args; 1626 } 1627 ); 1628 $output = wp_get_attachment_image( self::$large_id ); 1629 $this->assertStringContainsString( 'width="150"', $output, 'Width should not be changed.' ); 1630 $this->assertStringContainsString( 'height="150"', $output, 'Height should not be changed.' ); 1584 1631 } 1585 1632
Note: See TracChangeset
for help on using the changeset viewer.