Skip to content

Commit d0b3e7a

Browse files
authored
Merge pull request #4289 from ampproject/fix/4175-code-coverage
Improve code coverage
2 parents 3b764c0 + 4d3f0ab commit d0b3e7a

23 files changed

+473
-47
lines changed

includes/admin/class-amp-customizer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ public function print_controls_templates() {
325325
/**
326326
* Whether the Customizer is AMP. This is always true since the AMP Customizer has been merged with the main Customizer.
327327
*
328+
* @codeCoverageIgnore
328329
* @deprecated 0.6
329330
* @return bool
330331
*/

includes/amp-frontend-actions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/**
33
* Callbacks for adding AMP-related things to the main theme.
44
*
5+
* @codeCoverageIgnore
56
* @deprecated Function in this file has been moved to amp-helper-functions.php.
67
* @package AMP
78
*/

includes/class-amp-comment-walker.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/**
33
* Class AMP_Comment_Walker
44
*
5+
* @codeCoverageIgnore
56
* @deprecated 1.1.0 This functionality was moved to AMP_Comments_Sanitizer
67
* @package AMP
78
*/

includes/class-amp-post-type-support.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class AMP_Post_Type_Support {
2222
* Get post types that plugin supports out of the box (which cannot be disabled).
2323
*
2424
* @deprecated
25+
* @codeCoverageIgnore
2526
* @return string[] Post types.
2627
*/
2728
public static function get_builtin_supported_post_types() {

includes/class-amp-theme-support.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ static function () {
216216
* @since 1.0
217217
* @see AMP_Theme_Support::read_theme_support()
218218
* @see AMP_Theme_Support::get_support_mode()
219+
* @codeCoverageIgnore
219220
* @deprecated Use AMP_Theme_Support::get_support_mode_added_via_option().
220221
*
221222
* @return bool Support added via option.
@@ -1233,6 +1234,7 @@ public static function register_content_embed_handlers() {
12331234
/**
12341235
* Add the comments template placeholder marker
12351236
*
1237+
* @codeCoverageIgnore
12361238
* @deprecated 1.1.0 This functionality was moved to AMP_Comments_Sanitizer
12371239
*
12381240
* @param array $args the args for the comments list.

includes/deprecated.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* Load classes.
1010
*
1111
* @since 0.2
12+
* @codeCoverageIgnore
1213
* @deprecated As of 0.6 since autoloading is now employed.
1314
*/
1415
function amp_load_classes() {
@@ -21,6 +22,7 @@ function amp_load_classes() {
2122
* If the request is for an AMP page and this is in 'canonical mode,' redirect to the non-AMP page.
2223
* It won't need this plugin's template system, nor the frontend actions like the 'rel' link.
2324
*
25+
* @codeCoverageIgnore
2426
* @deprecated This function is not used when 'amp' theme support is added.
2527
* @global WP_Query $wp_query
2628
* @since 0.2
@@ -85,6 +87,7 @@ function amp_maybe_add_actions() {
8587
* Add post template actions.
8688
*
8789
* @since 0.2
90+
* @codeCoverageIgnore
8891
* @deprecated This function is not used when 'amp' theme support is added.
8992
*/
9093
function amp_add_post_template_actions() {
@@ -98,6 +101,7 @@ function amp_add_post_template_actions() {
98101
*
99102
* @since 0.2
100103
* @since 1.0 The amp_render() function is called at template_redirect action priority 11 instead of priority 10.
104+
* @codeCoverageIgnore
101105
* @deprecated This function is not used when 'amp' theme support is added.
102106
*/
103107
function amp_prepare_render() {
@@ -109,6 +113,7 @@ function amp_prepare_render() {
109113
* Render AMP for queried post.
110114
*
111115
* @since 0.1
116+
* @codeCoverageIgnore
112117
* @deprecated This function is not used when 'amp' theme support is added.
113118
*/
114119
function amp_render() {
@@ -126,6 +131,7 @@ function amp_render() {
126131
* Render AMP post template.
127132
*
128133
* @since 0.5
134+
* @codeCoverageIgnore
129135
* @deprecated Rendering a post is now handled by AMP_Theme_Support.
130136
*
131137
* @param WP_Post|int $post Post.
@@ -181,6 +187,7 @@ function amp_render_post( $post ) {
181187
/**
182188
* Print scripts.
183189
*
190+
* @codeCoverageIgnore
184191
* @deprecated Scripts are now automatically added.
185192
* @see amp_register_default_scripts()
186193
* @see amp_filter_script_loader_tag()
@@ -203,6 +210,7 @@ function amp_post_template_add_scripts( $amp_template ) {
203210
/**
204211
* Print boilerplate CSS.
205212
*
213+
* @codeCoverageIgnore
206214
* @deprecated Boilerplate is now automatically added.
207215
* @since 0.3
208216
* @see amp_get_boilerplate_code()
@@ -215,6 +223,7 @@ function amp_post_template_add_boilerplate_css() {
215223
/**
216224
* Print Schema.org metadata.
217225
*
226+
* @codeCoverageIgnore
218227
* @deprecated Since 0.7
219228
*/
220229
function amp_post_template_add_schemaorg_metadata() {
@@ -228,6 +237,7 @@ function amp_post_template_add_schemaorg_metadata() {
228237
* This function must be invoked only once through the 'wp_loaded' action.
229238
*
230239
* @since 0.6
240+
* @codeCoverageIgnore
231241
* @deprecated Since 1.5.0, as admin class bootstrapping is moved to amp_bootstrap_admin().
232242
*/
233243
function amp_post_meta_box() {
@@ -238,6 +248,7 @@ function amp_post_meta_box() {
238248
* Bootstrap the AMP admin pointer class.
239249
*
240250
* @since 1.0
251+
* @codeCoverageIgnore
241252
* @deprecated Since 1.5.0, as admin class bootstrapping is moved to amp_bootstrap_admin().
242253
*/
243254
function amp_admin_pointer() {

includes/embeds/class-amp-soundcloud-embed.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function unregister_embed() {
3838
*
3939
* @see \WP_Embed::shortcode()
4040
*
41+
* @codeCoverageIgnore
4142
* @deprecated Core's oEmbed handler is now used instead, with embed_oembed_html filter used to convert to AMP.
4243
* @param array $matches URL pattern matches.
4344
* @param array $attr Shortcode attributes.

includes/sanitizers/class-amp-base-sanitizer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ public function get_scripts() {
174174
* Return array of values that would be valid as an HTML `style` attribute.
175175
*
176176
* @since 0.4
177+
* @codeCoverageIgnore
177178
* @deprecated As of 1.0, use get_stylesheets().
178179
*
179180
* @return array[][] Mapping of CSS selectors to arrays of properties.
@@ -203,6 +204,7 @@ public function get_stylesheets() {
203204
/**
204205
* Get HTML body as DOMElement from Dom\Document received by the constructor.
205206
*
207+
* @codeCoverageIgnore
206208
* @deprecated Use $this->dom->body instead.
207209
* @return DOMElement The body element.
208210
*/

includes/sanitizers/class-amp-blacklist-sanitizer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#html-tags
1313
*
1414
* @since 0.5 This has been replaced by AMP_Tag_And_Attribute_Sanitizer but is kept around for back-compat.
15+
* @codeCoverageIgnore
1516
* @deprecated
1617
*/
1718
class AMP_Blacklist_Sanitizer extends AMP_Base_Sanitizer {

includes/sanitizers/class-amp-core-theme-sanitizer.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,23 @@ class AMP_Core_Theme_Sanitizer extends AMP_Base_Sanitizer {
4848
'twentyten',
4949
];
5050

51+
/**
52+
* Known modal roles.
53+
*
54+
* @var array
55+
*/
56+
protected static $modal_roles = [
57+
'navigation',
58+
'menu',
59+
'search',
60+
'alert',
61+
'figure',
62+
'form',
63+
'img',
64+
'toolbar',
65+
'tooltip',
66+
];
67+
5168
/**
5269
* Retrieve the config for features needed by a theme.
5370
*
@@ -401,6 +418,7 @@ protected static function get_theme_support_args( $theme ) {
401418
* Get theme config.
402419
*
403420
* @since 1.0
421+
* @codeCoverageIgnore
404422
* @deprecated 1.1
405423
*
406424
* @param string $theme Theme slug.
@@ -1909,10 +1927,10 @@ protected function guess_modal_role( DOMElement $modal ) {
19091927
return 'dialog';
19101928
}
19111929

1912-
$classes = $modal->getAttribute( 'class' );
1930+
$classes = preg_split( '/\s+/', trim( $modal->getAttribute( 'class' ) ) );
19131931

1914-
foreach ( [ 'navigation', 'menu', 'search', 'alert', 'figure', 'form', 'img', 'toolbar', 'tooltip' ] as $role ) {
1915-
if ( false !== strpos( $classes, $role ) ) {
1932+
foreach ( self::$modal_roles as $role ) {
1933+
if ( in_array( $role, $classes, true ) ) {
19161934
return $role;
19171935
}
19181936
}

0 commit comments

Comments
 (0)