Skip to content

Commit 5194644

Browse files
SergeyBiryukovarcangelini
authored andcommitted
Tests: Expand @covers tags for WP_Embed tests.
Includes removing the `external-http` group for a `WP_Embed::run_shortcode()` test which does not perform any HTTP requests. Follow-up to [50448], [62223], [62228]. See #64225. git-svn-id: https://develop.svn.wordpress.org/trunk@62229 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 6b90b77 commit 5194644

File tree

1 file changed

+63
-2
lines changed

1 file changed

+63
-2
lines changed

tests/phpunit/tests/oembed/WpEmbed.php

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* @group oembed
55
*
6-
* @covers WP_Embed
6+
* @coversDefaultClass WP_Embed
77
*/
88
class Tests_WP_Embed extends WP_UnitTestCase {
99
/**
@@ -24,11 +24,17 @@ public function _pre_oembed_result_callback() {
2424
return '<b>Embedded content</b>';
2525
}
2626

27+
/**
28+
* @covers ::maybe_run_ajax_cache
29+
*/
2730
public function test_maybe_run_ajax_cache_should_return_nothing_if_there_is_no_post() {
2831
$this->expectOutputString( '' );
2932
$this->wp_embed->maybe_run_ajax_cache();
3033
}
3134

35+
/**
36+
* @covers ::maybe_run_ajax_cache
37+
*/
3238
public function test_maybe_run_ajax_cache_should_return_nothing_if_there_is_no_message() {
3339
$GLOBALS['post'] = self::factory()->post->create_and_get(
3440
array(
@@ -42,6 +48,9 @@ public function test_maybe_run_ajax_cache_should_return_nothing_if_there_is_no_m
4248
unset( $GLOBALS['post'] );
4349
}
4450

51+
/**
52+
* @covers ::maybe_run_ajax_cache
53+
*/
4554
public function test_maybe_run_ajax_cache_should_return_javascript() {
4655
$GLOBALS['post'] = self::factory()->post->create_and_get(
4756
array(
@@ -59,6 +68,9 @@ public function test_maybe_run_ajax_cache_should_return_javascript() {
5968
$this->assertStringContainsString( $url, $actual );
6069
}
6170

71+
/**
72+
* @covers ::wp_maybe_load_embeds
73+
*/
6274
public function test_wp_maybe_load_embeds() {
6375
$this->assertSameSets( array( 10, 9999 ), array_keys( $GLOBALS['wp_embed']->handlers ) );
6476
$this->assertSameSets(
@@ -76,6 +88,9 @@ public function test_wp_maybe_load_embeds() {
7688
);
7789
}
7890

91+
/**
92+
* @covers ::wp_embed_register_handler
93+
*/
7994
public function test_wp_embed_register_handler() {
8095
$handle = __FUNCTION__;
8196
$regex = '#https?://example\.com/embed/([^/]+)#i';
@@ -94,6 +109,9 @@ public function test_wp_embed_register_handler() {
94109
$this->assertContains( $expected, $actual );
95110
}
96111

112+
/**
113+
* @covers ::wp_embed_unregister_handler
114+
*/
97115
public function test_wp_embed_unregister_handler() {
98116
$this->assertArrayHasKey( 'youtube_embed_url', $GLOBALS['wp_embed']->handlers[10] );
99117

@@ -109,6 +127,8 @@ public function test_wp_embed_unregister_handler() {
109127

110128
/**
111129
* @group external-http
130+
*
131+
* @covers ::autoembed
112132
*/
113133
public function test_autoembed_should_do_nothing_without_matching_handler() {
114134
$content = "\nhttp://example.com/embed/foo\n";
@@ -119,6 +139,8 @@ public function test_autoembed_should_do_nothing_without_matching_handler() {
119139

120140
/**
121141
* @group external-http
142+
*
143+
* @covers ::autoembed
122144
*/
123145
public function test_autoembed_should_return_modified_content() {
124146
$handle = __FUNCTION__;
@@ -135,6 +157,9 @@ public function test_autoembed_should_return_modified_content() {
135157
$this->assertSame( "\nEmbedded http://example.com/embed/foo\n", $actual );
136158
}
137159

160+
/**
161+
* @covers ::delete_oembed_caches
162+
*/
138163
public function test_delete_oembed_caches() {
139164
$post_id = self::factory()->post->create();
140165

@@ -148,20 +173,29 @@ public function test_delete_oembed_caches() {
148173
$this->assertSame( array(), get_post_meta( $post_id, '_oembed_baz' ) );
149174
}
150175

176+
/**
177+
* @covers ::cache_oembed
178+
*/
151179
public function test_cache_oembed_invalid_post_type() {
152180
$post_id = self::factory()->post->create( array( 'post_type' => 'nav_menu_item' ) );
153181

154182
$this->wp_embed->cache_oembed( $post_id );
155183
$this->assertNotSame( $post_id, $this->wp_embed->post_ID );
156184
}
157185

186+
/**
187+
* @covers ::cache_oembed
188+
*/
158189
public function test_cache_oembed_empty_content() {
159190
$post_id = self::factory()->post->create( array( 'post_content' => '' ) );
160191

161192
$this->wp_embed->cache_oembed( $post_id );
162193
$this->assertNotSame( $post_id, $this->wp_embed->post_ID );
163194
}
164195

196+
/**
197+
* @covers ::cache_oembed
198+
*/
165199
public function test_cache_oembed_for_post() {
166200
$url = 'https://example.com/';
167201
$expected = '<b>Embedded content</b>';
@@ -180,6 +214,9 @@ public function test_cache_oembed_for_post() {
180214
$this->assertNotEmpty( get_post_meta( $post_id, $cachekey_time, true ) );
181215
}
182216

217+
/**
218+
* @covers ::shortcode
219+
*/
183220
public function test_shortcode_should_get_cached_data_from_post_meta_for_known_post() {
184221
global $post;
185222

@@ -207,6 +244,9 @@ public function test_shortcode_should_get_cached_data_from_post_meta_for_known_p
207244
$this->assertSame( $expected, $cached );
208245
}
209246

247+
/**
248+
* @covers ::shortcode
249+
*/
210250
public function test_shortcode_should_get_cached_failure_from_post_meta_for_known_post() {
211251
global $post;
212252

@@ -241,6 +281,8 @@ public function test_shortcode_should_get_cached_failure_from_post_meta_for_know
241281

242282
/**
243283
* @ticket 34115
284+
*
285+
* @covers ::shortcode
244286
*/
245287
public function test_shortcode_should_cache_data_in_custom_post() {
246288
$url = 'https://example.com/';
@@ -267,6 +309,8 @@ public function test_shortcode_should_cache_data_in_custom_post() {
267309

268310
/**
269311
* @ticket 34115
312+
*
313+
* @covers ::shortcode
270314
*/
271315
public function test_shortcode_should_cache_failure_in_custom_post() {
272316
$url = 'https://example.com/';
@@ -295,6 +339,8 @@ public function test_shortcode_should_cache_failure_in_custom_post() {
295339
* Test that parsing an embed shortcode should cause oembed_cache to be updated.
296340
*
297341
* @ticket 42310
342+
*
343+
* @covers ::shortcode
298344
*/
299345
public function test_shortcode_should_update_custom_post() {
300346
add_filter( 'oembed_ttl', '__return_zero' );
@@ -327,6 +373,8 @@ public function test_shortcode_should_update_custom_post() {
327373

328374
/**
329375
* @group external-http
376+
*
377+
* @covers ::shortcode
330378
*/
331379
public function test_shortcode_should_get_url_from_src_attribute() {
332380
$url = 'http://example.com/embed/foo';
@@ -337,13 +385,17 @@ public function test_shortcode_should_get_url_from_src_attribute() {
337385

338386
/**
339387
* @group external-http
388+
*
389+
* @covers ::shortcode
340390
*/
341391
public function test_shortcode_should_return_empty_string_for_missing_url() {
342392
$this->assertEmpty( $this->wp_embed->shortcode( array() ) );
343393
}
344394

345395
/**
346396
* @group external-http
397+
*
398+
* @covers ::shortcode
347399
*/
348400
public function test_shortcode_should_make_link_for_unknown_url() {
349401
$url = 'http://example.com/embed/foo';
@@ -353,26 +405,35 @@ public function test_shortcode_should_make_link_for_unknown_url() {
353405
}
354406

355407
/**
356-
* @group external-http
408+
* @covers ::run_shortcode
357409
*/
358410
public function test_run_shortcode_url_only() {
359411
$url = 'http://example.com/embed/foo';
360412
$actual = $this->wp_embed->run_shortcode( '[embed]' . $url . '[/embed]' );
361413
$this->assertSame( '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>', $actual );
362414
}
363415

416+
/**
417+
* @covers ::maybe_make_link
418+
*/
364419
public function test_maybe_make_link() {
365420
$url = 'http://example.com/embed/foo';
366421
$actual = $this->wp_embed->maybe_make_link( $url );
367422

368423
$this->assertSame( '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>', $actual );
369424
}
370425

426+
/**
427+
* @covers ::maybe_make_link
428+
*/
371429
public function test_maybe_make_link_return_false_on_fail() {
372430
$this->wp_embed->return_false_on_fail = true;
373431
$this->assertFalse( $this->wp_embed->maybe_make_link( 'http://example.com/' ) );
374432
}
375433

434+
/**
435+
* @covers ::maybe_make_link
436+
*/
376437
public function test_maybe_make_link_do_not_link_if_unknown() {
377438
$url = 'http://example.com/';
378439

0 commit comments

Comments
 (0)