<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[53558] trunk/tests/phpunit/tests/media.php: Code Modernization: Remove dynamic properties in `Tests_Media`.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/53558">53558</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/53558","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-06-23 15:01:19 +0000 (Thu, 23 Jun 2022)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Code Modernization: Remove dynamic properties in `Tests_Media`.

Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In this particular case, the test class contains a `set_up()` method that sets a group of properties, which are ''used'' by the tests, but never ''changed'' by the tests.

In other words, setting these properties in the `set_up()` is an unnecessary overhead and the properties should be changed to class constants.

Notes:
* As the `$img_html` property, which was previously being set, is not actually used in any of the tests, that property has not been converted to a constant.
* The values which were previously being set using a heredoc, now use a nowdoc (supported since PHP 5.3), as they don't contain any interpolation.
* The use of constant scalar expressions (`IMG_URL`) and constant arrays (`IMG_META`) in class constants is supported since PHP 5.6.

Follow-up to [711/tests], [1260/tests], <a href="https://core.trac.wordpress.org/changeset/34855">[34855]</a>, <a href="https://core.trac.wordpress.org/changeset/41724">[41724]</a>, <a href="https://core.trac.wordpress.org/changeset/53557">[53557]</a>.

Props jrf.
See <a href="https://core.trac.wordpress.org/ticket/56033">#56033</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsmediaphp">trunk/tests/phpunit/tests/media.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestsmediaphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/media.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/media.php       2022-06-23 14:24:08 UTC (rev 53557)
+++ trunk/tests/phpunit/tests/media.php 2022-06-23 15:01:19 UTC (rev 53558)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,6 +5,25 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @group shortcode
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Media extends WP_UnitTestCase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       const CAPTION           = 'A simple caption.';
+       const ALTERNATE_CAPTION = 'Alternate caption.';
+
+       const HTML_CONTENT = <<<'CAP'
+A <strong class='classy'>bolded</strong> <em>caption</em> with a <a href="#">link</a>.
+CAP;
+       const IMG_CONTENT  = <<<'CAP'
+<img src="pic.jpg" id='anId' alt="pic"/>
+CAP;
+
+       const IMG_NAME = 'image.jpg';
+       const IMG_URL  = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . self::IMG_NAME;
+       const IMG_META = array(
+               'width'  => 100,
+               'height' => 100,
+               'sizes'  => '',
+       );
+
</ins><span class="cx" style="display: block; padding: 0 10px">         protected static $large_id;
</span><span class="cx" style="display: block; padding: 0 10px">        protected static $_sizes;
</span><span class="cx" style="display: block; padding: 0 10px">        protected static $large_filename = 'test-image-large.jpg';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -56,26 +75,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                parent::tear_down_after_class();
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function set_up() {
-               parent::set_up();
-               $this->caption           = 'A simple caption.';
-               $this->alternate_caption = 'Alternate caption.';
-               $this->html_content      = <<<CAP
-A <strong class='classy'>bolded</strong> <em>caption</em> with a <a href="#">link</a>.
-CAP;
-               $this->img_content       = <<<CAP
-<img src="pic.jpg" id='anId' alt="pic"/>
-CAP;
-               $this->img_name          = 'image.jpg';
-               $this->img_url           = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $this->img_name;
-               $this->img_html          = '<img src="' . $this->img_url . '"/>';
-               $this->img_meta          = array(
-                       'width'  => 100,
-                       'height' => 100,
-                       'sizes'  => '',
-               );
-       }
-
</del><span class="cx" style="display: block; padding: 0 10px">         public function test_img_caption_shortcode_added() {
</span><span class="cx" style="display: block; padding: 0 10px">                global $shortcode_tags;
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( 'img_caption_shortcode', $shortcode_tags['caption'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -91,8 +90,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 33981
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_img_caption_shortcode_with_empty_params_but_content() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $result = img_caption_shortcode( array(), $this->caption );
-               $this->assertSame( $this->caption, $result );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $result = img_caption_shortcode( array(), self::CAPTION );
+               $this->assertSame( self::CAPTION, $result );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -101,8 +100,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_img_caption_shortcode_short_circuit_filter() {
</span><span class="cx" style="display: block; padding: 0 10px">                add_filter( 'img_caption_shortcode', array( $this, 'return_alt_caption' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $result = img_caption_shortcode( array(), $this->caption );
-               $this->assertSame( $this->alternate_caption, $result );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $result = img_caption_shortcode( array(), self::CAPTION );
+               $this->assertSame( self::ALTERNATE_CAPTION, $result );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -109,7 +108,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * Filter used in test_img_caption_shortcode_short_circuit_filter()
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function return_alt_caption() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                return $this->alternate_caption;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         return self::ALTERNATE_CAPTION;
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -120,9 +119,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                'width' => 0,
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $this->caption
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 self::CAPTION
</ins><span class="cx" style="display: block; padding: 0 10px">                 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertSame( $this->caption, $result );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( self::CAPTION, $result );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -145,9 +144,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                'caption' => '',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $this->caption
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 self::CAPTION
</ins><span class="cx" style="display: block; padding: 0 10px">                 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertSame( $this->caption, $result );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( self::CAPTION, $result );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_img_caption_shortcode_with_old_format() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -154,13 +153,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $result = img_caption_shortcode(
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                'width'   => 20,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'caption' => $this->caption,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'caption' => self::CAPTION,
</ins><span class="cx" style="display: block; padding: 0 10px">                         )
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( 2, preg_match_all( '/wp-caption/', $result, $_r ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( 1, preg_match_all( '/alignnone/', $result, $_r ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertSame( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 1, preg_match_all( '/' . self::CAPTION . '/', $result, $_r ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( current_theme_supports( 'html5', 'caption' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $this->assertSame( 1, preg_match_all( '/width: 20/', $result, $_r ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -173,7 +172,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $result = img_caption_shortcode(
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                'width'   => 20,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'caption' => $this->caption,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'caption' => self::CAPTION,
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'id'      => '"myId',
</span><span class="cx" style="display: block; padding: 0 10px">                                'align'   => '&myAlignment',
</span><span class="cx" style="display: block; padding: 0 10px">                        )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -180,7 +179,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( 1, preg_match_all( '/wp-caption &amp;myAlignment/', $result, $_r ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( 1, preg_match_all( '/id="myId"/', $result, $_r ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertSame( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 1, preg_match_all( '/' . self::CAPTION . '/', $result, $_r ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_img_caption_shortcode_with_old_format_and_class() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -188,7 +187,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                'width'   => 20,
</span><span class="cx" style="display: block; padding: 0 10px">                                'class'   => 'some-class another-class',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'caption' => $this->caption,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'caption' => self::CAPTION,
</ins><span class="cx" style="display: block; padding: 0 10px">                         )
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( 1, preg_match_all( '/wp-caption alignnone some-class another-class/', $result, $_r ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -199,10 +198,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $result   = img_caption_shortcode(
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                'width'   => 20,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'caption' => $this->html_content,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'caption' => self::HTML_CONTENT,
</ins><span class="cx" style="display: block; padding: 0 10px">                         )
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $our_preg = preg_quote( $this->html_content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $our_preg = preg_quote( self::HTML_CONTENT );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( 1, preg_match_all( "~{$our_preg}~", $result, $_r ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -210,10 +209,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_new_img_caption_shortcode_new_format() {
</span><span class="cx" style="display: block; padding: 0 10px">                $result       = img_caption_shortcode(
</span><span class="cx" style="display: block; padding: 0 10px">                        array( 'width' => 20 ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $this->img_content . $this->html_content
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 self::IMG_CONTENT . self::HTML_CONTENT
</ins><span class="cx" style="display: block; padding: 0 10px">                 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $img_preg     = preg_quote( $this->img_content );
-               $content_preg = preg_quote( $this->html_content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $img_preg     = preg_quote( self::IMG_CONTENT );
+               $content_preg = preg_quote( self::HTML_CONTENT );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( 1, preg_match_all( "~{$img_preg}.*wp-caption-text~", $result, $_r ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -220,13 +219,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_new_img_caption_shortcode_new_format_and_linked_image() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $linked_image = "<a href='#'>{$this->img_content}</a>";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $linked_image = "<a href='#'>" . self::IMG_CONTENT . '</a>';
</ins><span class="cx" style="display: block; padding: 0 10px">                 $result       = img_caption_shortcode(
</span><span class="cx" style="display: block; padding: 0 10px">                        array( 'width' => 20 ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $linked_image . $this->html_content
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $linked_image . self::HTML_CONTENT
</ins><span class="cx" style="display: block; padding: 0 10px">                 );
</span><span class="cx" style="display: block; padding: 0 10px">                $img_preg     = preg_quote( $linked_image );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $content_preg = preg_quote( $this->html_content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $content_preg = preg_quote( self::HTML_CONTENT );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( 1, preg_match_all( "~{$img_preg}.*wp-caption-text~", $result, $_r ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -233,13 +232,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_new_img_caption_shortcode_new_format_and_linked_image_with_newline() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $linked_image = "<a href='#'>{$this->img_content}</a>";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $linked_image = "<a href='#'>" . self::IMG_CONTENT . '</a>';
</ins><span class="cx" style="display: block; padding: 0 10px">                 $result       = img_caption_shortcode(
</span><span class="cx" style="display: block; padding: 0 10px">                        array( 'width' => 20 ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $linked_image . "\n\n" . $this->html_content
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $linked_image . "\n\n" . self::HTML_CONTENT
</ins><span class="cx" style="display: block; padding: 0 10px">                 );
</span><span class="cx" style="display: block; padding: 0 10px">                $img_preg     = preg_quote( $linked_image );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $content_preg = preg_quote( $this->html_content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $content_preg = preg_quote( self::HTML_CONTENT );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( 1, preg_match_all( "~{$img_preg}.*wp-caption-text~", $result, $_r ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -254,7 +253,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'width' => 20,
</span><span class="cx" style="display: block; padding: 0 10px">                                'id'    => 'myId',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $this->img_content . $this->html_content
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 self::IMG_CONTENT . self::HTML_CONTENT
</ins><span class="cx" style="display: block; padding: 0 10px">                 );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( 1, preg_match_all( '/aria-describedby="caption-myId"/', $result, $_r ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -494,7 +493,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_get_attached_images() {
</span><span class="cx" style="display: block; padding: 0 10px">                $post_id       = self::factory()->post->create();
</span><span class="cx" style="display: block; padding: 0 10px">                $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $this->img_name,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 self::IMG_NAME,
</ins><span class="cx" style="display: block; padding: 0 10px">                         $post_id,
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -521,7 +520,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        'post_type'      => 'attachment',
</span><span class="cx" style="display: block; padding: 0 10px">                                )
</span><span class="cx" style="display: block; padding: 0 10px">                        );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $metadata      = array_merge( array( 'file' => "image$i.jpg" ), $this->img_meta );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $metadata      = array_merge( array( 'file' => "image$i.jpg" ), self::IMG_META );
</ins><span class="cx" style="display: block; padding: 0 10px">                         wp_update_attachment_metadata( $attachment_id, $metadata );
</span><span class="cx" style="display: block; padding: 0 10px">                        $ids1[]      = $attachment_id;
</span><span class="cx" style="display: block; padding: 0 10px">                        $ids1_srcs[] = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -538,7 +537,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        'post_type'      => 'attachment',
</span><span class="cx" style="display: block; padding: 0 10px">                                )
</span><span class="cx" style="display: block; padding: 0 10px">                        );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $metadata      = array_merge( array( 'file' => "image$i.jpg" ), $this->img_meta );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $metadata      = array_merge( array( 'file' => "image$i.jpg" ), self::IMG_META );
</ins><span class="cx" style="display: block; padding: 0 10px">                         wp_update_attachment_metadata( $attachment_id, $metadata );
</span><span class="cx" style="display: block; padding: 0 10px">                        $ids2[]      = $attachment_id;
</span><span class="cx" style="display: block; padding: 0 10px">                        $ids2_srcs[] = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -572,7 +571,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        'post_type'      => 'attachment',
</span><span class="cx" style="display: block; padding: 0 10px">                                )
</span><span class="cx" style="display: block; padding: 0 10px">                        );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $metadata      = array_merge( array( 'file' => "image$i.jpg" ), $this->img_meta );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $metadata      = array_merge( array( 'file' => "image$i.jpg" ), self::IMG_META );
</ins><span class="cx" style="display: block; padding: 0 10px">                         wp_update_attachment_metadata( $attachment_id, $metadata );
</span><span class="cx" style="display: block; padding: 0 10px">                        $ids1[]      = $attachment_id;
</span><span class="cx" style="display: block; padding: 0 10px">                        $ids1_srcs[] = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -589,7 +588,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        'post_type'      => 'attachment',
</span><span class="cx" style="display: block; padding: 0 10px">                                )
</span><span class="cx" style="display: block; padding: 0 10px">                        );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $metadata      = array_merge( array( 'file' => "image$i.jpg" ), $this->img_meta );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $metadata      = array_merge( array( 'file' => "image$i.jpg" ), self::IMG_META );
</ins><span class="cx" style="display: block; padding: 0 10px">                         wp_update_attachment_metadata( $attachment_id, $metadata );
</span><span class="cx" style="display: block; padding: 0 10px">                        $ids2[]      = $attachment_id;
</span><span class="cx" style="display: block; padding: 0 10px">                        $ids2_srcs[] = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -622,7 +621,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                "image$i.jpg",
</span><span class="cx" style="display: block; padding: 0 10px">                                0
</span><span class="cx" style="display: block; padding: 0 10px">                        );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $metadata      = array_merge( array( 'file' => "image$i.jpg" ), $this->img_meta );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $metadata      = array_merge( array( 'file' => "image$i.jpg" ), self::IMG_META );
</ins><span class="cx" style="display: block; padding: 0 10px">                         wp_update_attachment_metadata( $attachment_id, $metadata );
</span><span class="cx" style="display: block; padding: 0 10px">                        $ids[]      = $attachment_id;
</span><span class="cx" style="display: block; padding: 0 10px">                        $url        = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -660,7 +659,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                "image$i.jpg",
</span><span class="cx" style="display: block; padding: 0 10px">                                0
</span><span class="cx" style="display: block; padding: 0 10px">                        );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $metadata      = array_merge( array( 'file' => "image$i.jpg" ), $this->img_meta );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $metadata      = array_merge( array( 'file' => "image$i.jpg" ), self::IMG_META );
</ins><span class="cx" style="display: block; padding: 0 10px">                         wp_update_attachment_metadata( $attachment_id, $metadata );
</span><span class="cx" style="display: block; padding: 0 10px">                        $ids[]      = $attachment_id;
</span><span class="cx" style="display: block; padding: 0 10px">                        $url        = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -702,7 +701,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        'post_type'      => 'attachment',
</span><span class="cx" style="display: block; padding: 0 10px">                                )
</span><span class="cx" style="display: block; padding: 0 10px">                        );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $metadata      = array_merge( array( 'file' => "image$i.jpg" ), $this->img_meta );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $metadata      = array_merge( array( 'file' => "image$i.jpg" ), self::IMG_META );
</ins><span class="cx" style="display: block; padding: 0 10px">                         wp_update_attachment_metadata( $attachment_id, $metadata );
</span><span class="cx" style="display: block; padding: 0 10px">                        $ids[]      = $attachment_id;
</span><span class="cx" style="display: block; padding: 0 10px">                        $url        = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -745,7 +744,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        'post_type'      => 'attachment',
</span><span class="cx" style="display: block; padding: 0 10px">                                )
</span><span class="cx" style="display: block; padding: 0 10px">                        );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $metadata      = array_merge( array( 'file' => "image$i.jpg" ), $this->img_meta );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $metadata      = array_merge( array( 'file' => "image$i.jpg" ), self::IMG_META );
</ins><span class="cx" style="display: block; padding: 0 10px">                         wp_update_attachment_metadata( $attachment_id, $metadata );
</span><span class="cx" style="display: block; padding: 0 10px">                        $ids[]      = $attachment_id;
</span><span class="cx" style="display: block; padding: 0 10px">                        $url        = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -788,7 +787,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        'post_type'      => 'attachment',
</span><span class="cx" style="display: block; padding: 0 10px">                                )
</span><span class="cx" style="display: block; padding: 0 10px">                        );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $metadata      = array_merge( array( 'file' => "image$i.jpg" ), $this->img_meta );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $metadata      = array_merge( array( 'file' => "image$i.jpg" ), self::IMG_META );
</ins><span class="cx" style="display: block; padding: 0 10px">                         wp_update_attachment_metadata( $attachment_id, $metadata );
</span><span class="cx" style="display: block; padding: 0 10px">                        $ids[]      = $attachment_id;
</span><span class="cx" style="display: block; padding: 0 10px">                        $url        = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1181,7 +1180,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 30346
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_attachment_url_to_postid() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $image_path    = '2014/11/' . $this->img_name;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $image_path    = '2014/11/' . self::IMG_NAME;
</ins><span class="cx" style="display: block; padding: 0 10px">                 $attachment_id = self::factory()->attachment->create_object(
</span><span class="cx" style="display: block; padding: 0 10px">                        $image_path,
</span><span class="cx" style="display: block; padding: 0 10px">                        0,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1199,7 +1198,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 33109
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_attachment_url_to_postid_with_different_scheme() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $image_path    = '2014/11/' . $this->img_name;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $image_path    = '2014/11/' . self::IMG_NAME;
</ins><span class="cx" style="display: block; padding: 0 10px">                 $attachment_id = self::factory()->attachment->create_object(
</span><span class="cx" style="display: block; padding: 0 10px">                        $image_path,
</span><span class="cx" style="display: block; padding: 0 10px">                        0,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1217,7 +1216,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 39768
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_attachment_url_to_postid_should_be_case_sensitive() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $image_path_lower_case    = '2014/11/' . $this->img_name;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $image_path_lower_case    = '2014/11/' . self::IMG_NAME;
</ins><span class="cx" style="display: block; padding: 0 10px">                 $attachment_id_lower_case = self::factory()->attachment->create_object(
</span><span class="cx" style="display: block; padding: 0 10px">                        $image_path_lower_case,
</span><span class="cx" style="display: block; padding: 0 10px">                        0,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1227,7 +1226,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        )
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $image_path_upper_case    = '2014/11/' . ucfirst( $this->img_name );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $image_path_upper_case    = '2014/11/' . ucfirst( self::IMG_NAME );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $attachment_id_upper_case = self::factory()->attachment->create_object(
</span><span class="cx" style="display: block; padding: 0 10px">                        $image_path_upper_case,
</span><span class="cx" style="display: block; padding: 0 10px">                        0,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1242,7 +1241,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_attachment_url_to_postid_filtered() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $image_path    = '2014/11/' . $this->img_name;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $image_path    = '2014/11/' . self::IMG_NAME;
</ins><span class="cx" style="display: block; padding: 0 10px">                 $attachment_id = self::factory()->attachment->create_object(
</span><span class="cx" style="display: block; padding: 0 10px">                        $image_path,
</span><span class="cx" style="display: block; padding: 0 10px">                        0,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1532,7 +1531,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $post_id       = self::factory()->post->create();
</span><span class="cx" style="display: block; padding: 0 10px">                $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $this->img_name,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 self::IMG_NAME,
</ins><span class="cx" style="display: block; padding: 0 10px">                         $post_id,
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1555,7 +1554,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $post_id       = self::factory()->post->create();
</span><span class="cx" style="display: block; padding: 0 10px">                $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $this->img_name,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 self::IMG_NAME,
</ins><span class="cx" style="display: block; padding: 0 10px">                         $post_id,
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1575,7 +1574,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_get_attachment_caption_empty() {
</span><span class="cx" style="display: block; padding: 0 10px">                $post_id       = self::factory()->post->create();
</span><span class="cx" style="display: block; padding: 0 10px">                $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $this->img_name,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 self::IMG_NAME,
</ins><span class="cx" style="display: block; padding: 0 10px">                         $post_id,
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3333,7 +3332,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_image_file_matches_image_meta_invalid_meta() {
</span><span class="cx" style="display: block; padding: 0 10px">                $image_meta = ''; // Attachment is not an image.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $image_src  = $this->img_url;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $image_src  = self::IMG_URL;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertFalse( wp_image_file_matches_image_meta( $image_src, $image_meta ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3343,7 +3342,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_image_file_matches_image_meta_different_meta() {
</span><span class="cx" style="display: block; padding: 0 10px">                $image_meta = wp_get_attachment_metadata( self::$large_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $image_src  = $this->img_url; // Different image.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $image_src  = self::IMG_URL; // Different image.
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertFalse( wp_image_file_matches_image_meta( $image_src, $image_meta ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span></span></pre>
</div>
</div>

</body>
</html>