@@ -111,7 +111,7 @@ public function test__conversion( $url, $expected ) {
111111 $ dom = AMP_DOM_Utils::get_dom_from_content ( $ content );
112112 $ embed ->sanitize_raw_embeds ( $ dom );
113113 $ content = AMP_DOM_Utils::get_content_from_dom ( $ dom );
114- $ this ->assertEqualMarkup ( $ expected , $ content );
114+ $ this ->assertEqualMarkup ( $ expected , $ this -> maybe_replace_embed_urls ( $ content ) );
115115
116116 if ( $ url && function_exists ( 'do_blocks ' ) ) {
117117 $ embed_block = "<!-- wp:embed { \"url \": \"{$ url }\", \"type \": \"rich \", \"providerNameSlug \": \"tumblr \", \"responsive \":true} --> \n<figure class= \"wp-block-embed is-type-rich is-provider-tumblr wp-block-embed-tumblr \"><div class= \"wp-block-embed__wrapper \"> \n{$ url }\n</div></figure> \n<!-- /wp:embed --> " ;
@@ -122,23 +122,40 @@ public function test__conversion( $url, $expected ) {
122122
123123 $ this ->assertEqualMarkup (
124124 '<figure class="wp-block-embed is-type-rich is-provider-tumblr wp-block-embed-tumblr"><div class="wp-block-embed__wrapper"> ' . $ expected . '</div></figure> ' ,
125- $ content
125+ $ this -> maybe_replace_embed_urls ( $ content )
126126 );
127127 }
128128
129129 // Check with no filters applied.
130130 $ dom = AMP_DOM_Utils::get_dom_from_content ( ( new WP_Embed () )->shortcode ( [], $ url ) );
131131 $ embed ->sanitize_raw_embeds ( $ dom );
132132 $ content = AMP_DOM_Utils::get_content_from_dom ( $ dom );
133- $ this ->assertEqualMarkup ( $ expected , $ content );
133+ $ this ->assertEqualMarkup ( $ expected , $ this -> maybe_replace_embed_urls ( $ content ) );
134134
135135 // Check with no filters applied and with the script pre-remoevd.
136136 $ content = ( new WP_Embed () )->shortcode ( [], $ url );
137137 $ content = preg_replace ( '#<script.+?</script># ' , '' , $ content );
138138 $ dom = AMP_DOM_Utils::get_dom_from_content ( $ content );
139139 $ embed ->sanitize_raw_embeds ( $ dom );
140140 $ content = AMP_DOM_Utils::get_content_from_dom ( $ dom );
141- $ this ->assertEqualMarkup ( $ expected , $ content );
141+ $ this ->assertEqualMarkup ( $ expected , $ this ->maybe_replace_embed_urls ( $ content ) );
142+ }
143+
144+ /**
145+ * Replace new embeds URLs with old ones.
146+ *
147+ * @param string $content Content.
148+ *
149+ * @return string Content.
150+ */
151+ private function maybe_replace_embed_urls ( $ content ) {
152+ // Replace new embeds url to old ones to maintain consistency.
153+ $ content = str_replace ( 'https://embed.tumblr.com/embed/post/t:-iO5APHPiXyOXM0LJ2Zeqg/92003045635/v2 ' , 'https://embed.tumblr.com/embed/post/2JT2XTaiTxO08wh21dqQrw/92003045635 ' , $ content );
154+ $ content = str_replace ( 'https://www.tumblr.com/ifpaintingscouldtext/92003045635/grant-wood-american-gothic-1930 ' , 'https://ifpaintingscouldtext.tumblr.com/post/92003045635/grant-wood-american-gothic-1930 ' , $ content );
155+ $ content = str_replace ( 'https://embed.tumblr.com/embed/post/t:F33OkAxLKX6A89MkL0LO6g/184736320764/v2 ' , 'https://embed.tumblr.com/embed/post/O6_eRR6K-z9QGTzdU5HrhQ/184736320764 ' , $ content );
156+ $ content = str_replace ( 'https://www.tumblr.com/teded/184736320764/how-do-vaccines-work ' , 'https://teded.tumblr.com/post/184736320764/how-do-vaccines-work ' , $ content );
157+
158+ return $ content ;
142159 }
143160
144161 /**
0 commit comments