-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test coverage for AMP_Theme_Support #1034
Conversation
f76184c
to
3c1f03d
Compare
02a2088
to
af899c2
Compare
…ed (and fail) for unknown reason See xwp/wp-dev-lib#270
af899c2
to
97dcdf1
Compare
Test init() and redirect_canonical_amp(). @todo continue with these, and consider a better way to test redirect_canonical_amp(). That uses wp_safe_redirect, which throws an error.
is_customize_preview_iframe() and register_paired_hooks().
Test add_hooks, send_header(), and register_content_embed_handlers().
Test methods related to AMP templates, and get_current_canonical_url().
Test 2 methods: get_comment_form_state_id() and filter_comment_form_defaults().
There's a check for is_customize_preview() around add_action(). But the callback dequeue_customize_preview_scripts() has its own check for is_customize_preview_iframe(). And that has a check for is_customize_preview(). So this ensures that the body of the callback never runs. Maybe I misread the intent of this, though. This also adds unit tests.
These variables are only used once, so they can simply be passed to the array.
There's already a phpcs:disable at the top of the method. And a phpcs:enable at the bottom.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some Minor Points
Hi @DavidCramer,
Good work on these tests. Could you please address these minor points?
@@ -631,7 +629,7 @@ public static function register_content_embed_handlers() { | |||
* @param array $args the args for the comments list.. | |||
* @return array Args to return. | |||
*/ | |||
public static function amp_set_comments_walker( $args ) { | |||
public static function set_comments_walker( $args ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this method's name is now different from that in the add_action() call:
add_filter( 'wp_list_comments_args', array( __CLASS__, 'amp_set_comments_walker' ), PHP_INT_MAX );
@@ -999,7 +997,7 @@ public static function start_output_buffering() { | |||
* Sites with New Relic will need to specially configure New Relic for AMP: | |||
* https://docs.newrelic.com/docs/browser/new-relic-browser/installation/monitor-amp-pages-new-relic-browser | |||
*/ | |||
if ( extension_loaded( 'newrelic' ) ) { | |||
if ( function_exists( 'newrelic_disable_autorum' ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea to make testing easier.
* @covers AMP_Theme_Support::start_output_buffering() | ||
*/ | ||
public function test_start_output_buffering() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please review this empty line?
* @covers AMP_Theme_Support::finish_output_buffering() | ||
*/ | ||
public function test_finish_output_buffering() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please remove this empty line, and the empty line at the bottom of the function, before the closing }
? And please do the same for test_filter_customize_partial_render()
.
There was a minor conflict in: test-class-amp-theme-support.php. Retain both edits.
Before, merging in 0.7, there was an amp-default <link>. But test_validate_non_amp_theme() also output that. And that stored the script in $wp_styles->done. So it wasn't output again, and the test failed. So reset $wp_styles, so it gets re-instantiated.
Request For Review Hi @westonruter, @DavidCramer's and your commits passed my review. But it'd be great to have you review my commits, if you have time. This commit is the only substantive change to a non-test file. Thanks, and have a great weekend! |
Fixes #868.