Changeset 41724
- Timestamp:
- 10/04/2017 02:49:19 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r41383 r41724 1579 1579 $style = ''; 1580 1580 if ( $caption_width ) { 1581 $style = 'style=" width: ' . (int) $caption_width . 'px" ';1581 $style = 'style="max-width: ' . (int) $caption_width . 'px" '; 1582 1582 } 1583 1583 -
trunk/tests/phpunit/tests/media.php
r41693 r41724 29 29 parent::setUp(); 30 30 $this->caption = 'A simple caption.'; 31 $this->alternate_caption = 'Alternate caption.'; 31 32 $this->html_content = <<<CAP 32 33 A <strong class='classy'>bolded</strong> <em>caption</em> with a <a href="#">link</a>. … … 52 53 } 53 54 54 function test_img_caption_shortcode_with_bad_attr() { 55 $result = img_caption_shortcode( array(), 'content' ); 56 $this->assertEquals( 'content', 'content' ); 55 /** 56 * @ticket 33981 57 */ 58 function test_img_caption_shortcode_with_empty_params_but_content() { 59 $result = img_caption_shortcode( array(), $this->caption ); 60 $this->assertEquals( $this->caption, $result ); 61 } 62 63 /** 64 * @ticket 33981 65 */ 66 function test_img_caption_shortcode_short_circuit_filter() { 67 add_filter( 'img_caption_shortcode', array( $this, '_return_alt_caption' ) ); 68 69 $result = img_caption_shortcode( array(), $this->caption ); 70 $this->assertEquals( $this->alternate_caption, $result ); 71 } 72 73 /** 74 * Filter used in test_img_caption_shortcode_short_circuit_filter() 75 */ 76 function _return_alt_caption() { 77 return $this->alternate_caption; 78 } 79 80 /** 81 * @ticket 33981 82 */ 83 function test_img_caption_shortcode_empty_width() { 84 $result = img_caption_shortcode( 85 array( 86 'width' => 0, 87 ), 88 $this->caption 89 ); 90 $this->assertEquals( $this->caption, $result ); 91 } 92 93 /** 94 * @ticket 33981 95 */ 96 function test_img_caption_shortcode_empty_caption() { 97 $result = img_caption_shortcode( 98 array( 99 'caption' => '', 100 ) 101 ); 102 $this->assertNull( $result ); 103 } 104 105 /** 106 * @ticket 33981 107 */ 108 function test_img_caption_shortcode_empty_caption_and_content() { 109 $result = img_caption_shortcode( 110 array( 111 'caption' => '', 112 ), 113 $this->caption 114 ); 115 $this->assertEquals( $this->caption, $result ); 57 116 } 58 117 … … 67 126 68 127 if ( current_theme_supports( 'html5', 'caption' ) ) { 69 $this->assertEquals( 1, preg_match_all( "/ width: 20/", $result, $_r ) );128 $this->assertEquals( 1, preg_match_all( "/max-width: 20/", $result, $_r ) ); 70 129 } else { 71 $this->assertEquals( 1, preg_match_all( "/ width: 30/", $result, $_r ) );130 $this->assertEquals( 1, preg_match_all( "/max-width: 30/", $result, $_r ) ); 72 131 } 73 132 } … … 85 144 $this->assertEquals( 1, preg_match_all( '/id="myId"/', $result, $_r ) ); 86 145 $this->assertEquals( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) ); 146 } 147 148 function test_img_caption_shortcode_with_old_format_and_class() { 149 $result = img_caption_shortcode( 150 array( 151 'width' => 20, 152 'class' => 'some-class another-class', 153 'caption' => $this->caption, 154 ) 155 ); 156 $this->assertEquals( 1, preg_match_all( '/wp-caption alignnone some-class another-class/', $result, $_r ) ); 157 87 158 } 88 159 -
trunk/tests/phpunit/tests/shortcode.php
r41026 r41724 478 478 array( 479 479 '[caption caption="test" width="2"]<div>hello</div>[/caption]', 480 '<div style=" width: 12px" class="wp-caption alignnone"><div>hello</div><p class="wp-caption-text">test</p></div>',480 '<div style="max-width: 12px" class="wp-caption alignnone"><div>hello</div><p class="wp-caption-text">test</p></div>', 481 481 ), 482 482 array(
Note: See TracChangeset
for help on using the changeset viewer.