Changeset 42343 for trunk/tests/phpunit/tests/oembed/WpEmbed.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/oembed/WpEmbed.php
r42009 r42343 23 23 24 24 public function test_maybe_run_ajax_cache_should_return_nothing_if_there_is_no_post() { 25 $this->expectOutputString( '');25 $this->expectOutputString( '' ); 26 26 $this->wp_embed->maybe_run_ajax_cache(); 27 27 } 28 28 29 29 public function test_maybe_run_ajax_cache_should_return_nothing_if_there_is_no_message() { 30 $GLOBALS['post'] = $this->factory()->post->create_and_get( array( 31 'post_title' => 'Hello World', 32 ) ); 33 34 $this->expectOutputString(''); 30 $GLOBALS['post'] = $this->factory()->post->create_and_get( 31 array( 32 'post_title' => 'Hello World', 33 ) 34 ); 35 36 $this->expectOutputString( '' ); 35 37 36 38 $this->wp_embed->maybe_run_ajax_cache(); … … 39 41 40 42 public function test_maybe_run_ajax_cache_should_return_javascript() { 41 $GLOBALS['post'] = $this->factory()->post->create_and_get( array( 42 'post_title' => 'Hello World', 43 ) ); 43 $GLOBALS['post'] = $this->factory()->post->create_and_get( 44 array( 45 'post_title' => 'Hello World', 46 ) 47 ); 44 48 $_GET['message'] = 'foo'; 45 49 … … 55 59 public function test_wp_maybe_load_embeds() { 56 60 $this->assertEqualSets( array( 10, 9999 ), array_keys( $GLOBALS['wp_embed']->handlers ) ); 57 $this->assertEqualSets( array( 58 'youtube_embed_url', 59 ), array_keys( $GLOBALS['wp_embed']->handlers[10] ) ); 60 $this->assertEqualSets( array( 61 'audio', 62 'video', 63 ), array_keys( $GLOBALS['wp_embed']->handlers[9999] ) ); 61 $this->assertEqualSets( 62 array( 63 'youtube_embed_url', 64 ), array_keys( $GLOBALS['wp_embed']->handlers[10] ) 65 ); 66 $this->assertEqualSets( 67 array( 68 'audio', 69 'video', 70 ), array_keys( $GLOBALS['wp_embed']->handlers[9999] ) 71 ); 64 72 } 65 73 … … 165 173 global $post; 166 174 167 $post = $this->factory()->post->create_and_get();168 $url 169 $expected 170 $key_suffix 171 $cachekey 175 $post = $this->factory()->post->create_and_get(); 176 $url = 'https://example.com/'; 177 $expected = '<b>Embedded content</b>'; 178 $key_suffix = md5( $url . serialize( wp_embed_defaults( $url ) ) ); 179 $cachekey = '_oembed_' . $key_suffix; 172 180 173 181 add_post_meta( $post->ID, $cachekey, $expected ); … … 192 200 global $post; 193 201 194 $post = $this->factory()->post->create_and_get();195 $url 196 $expected 197 $key_suffix 198 $cachekey 199 $cachekey_time 202 $post = $this->factory()->post->create_and_get(); 203 $url = 'https://example.com/'; 204 $expected = '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>'; 205 $key_suffix = md5( $url . serialize( wp_embed_defaults( $url ) ) ); 206 $cachekey = '_oembed_' . $key_suffix; 207 $cachekey_time = '_oembed_time_' . $key_suffix; 200 208 201 209 add_post_meta( $post->ID, $cachekey, '{{unknown}}' ); … … 209 217 $actual_2 = $this->wp_embed->shortcode( array(), $url ); 210 218 211 $cached = get_post_meta( $post->ID, $cachekey, true );219 $cached = get_post_meta( $post->ID, $cachekey, true ); 212 220 $cached_time = get_post_meta( $post->ID, $cachekey_time, true ); 213 221 … … 234 242 235 243 $oembed_post_id = $this->wp_embed->find_oembed_post_id( $key_suffix ); 236 $post_content = get_post( $oembed_post_id )->post_content;244 $post_content = get_post( $oembed_post_id )->post_content; 237 245 238 246 // Result should be cached. … … 260 268 261 269 $oembed_post_id = $this->wp_embed->find_oembed_post_id( $key_suffix ); 262 $post_content = get_post( $oembed_post_id )->post_content;270 $post_content = get_post( $oembed_post_id )->post_content; 263 271 264 272 // Result should be cached. … … 293 301 $this->assertSame( '{{unknown}}', get_post( $oembed_post_id )->post_content ); 294 302 295 $previous_usecache = $this->wp_embed->usecache;303 $previous_usecache = $this->wp_embed->usecache; 296 304 $this->wp_embed->usecache = false; 297 305
Note: See TracChangeset
for help on using the changeset viewer.