Skip to content
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

Merged
merged 23 commits into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ce66658
Fix phpunit warnings regarding use of @cover fornon-existing class or…
westonruter Mar 22, 2018
1fe5527
Add stubs for missing tests; re-order tests to mirror order in theme …
westonruter Mar 22, 2018
7232ab5
Remove needless amp prefix from set_comments_walker method
westonruter Mar 22, 2018
b3c6402
Add test for AMP_Theme_Support::set_comments_walker()
westonruter Mar 24, 2018
97dcdf1
Skip printing paths-scope because it causes push builds to be truncat…
westonruter Mar 26, 2018
4c17c67
Add 2 PHPUnit tests for AMP_Theme_Support.
Mar 27, 2018
4d70aa9
Test 2 more methods in AMP_Theme_Support.
Mar 27, 2018
ac6cac1
Test 3 more methods in AMP_Theme_Support.
Mar 27, 2018
92ada3b
Test 3 more methods in AMP_Theme_Support.
Mar 28, 2018
93bf043
Add comment form-related PHPUnit tests.
Mar 28, 2018
7c704ae
Remove the conditional around the add_action for preview scripts.
Mar 28, 2018
f90c40a
Remove test for renamed method, as test already exists.
DavidCramer Mar 28, 2018
912ea33
Test start and finish output buffers.
DavidCramer Mar 28, 2018
e4dedbb
Add test for partial render and flesh out buffer tests.
DavidCramer Mar 28, 2018
ce68491
Correct assertion on has_action for shutdown
DavidCramer Mar 28, 2018
9caf29b
use function_exists instead of extension_loaded to simplify testing.
DavidCramer Mar 28, 2018
cdb6bba
define newrelic_disable_autorum to allow testing
DavidCramer Mar 28, 2018
1b75fae
more coverage for intercept_post_request_redirect
DavidCramer Mar 28, 2018
2540e86
Remove extra variable declarations.
Mar 28, 2018
86f13fb
Remove extra phpcs:ignore comments.
Mar 28, 2018
b365e00
Address issues from CR
DavidCramer Mar 29, 2018
9e87ea6
Merge in 0.7, resolve conflicts.
Mar 30, 2018
71b83fc
Fix a failed unit test by setting $wp_styles to null.
Mar 31, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions includes/class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,7 @@ public static function add_hooks() {
add_action( 'wp_head', 'amp_add_generator_metadata', 20 );

add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ) );
if ( is_customize_preview() ) {
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'dequeue_customize_preview_scripts' ), 1000 );
}
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'dequeue_customize_preview_scripts' ), 1000 );
add_filter( 'customize_partial_render', array( __CLASS__, 'filter_customize_partial_render' ) );

add_action( 'wp_footer', 'amp_print_analytics' );
Expand All @@ -245,7 +243,7 @@ public static function add_hooks() {
add_action( 'template_redirect', array( __CLASS__, 'start_output_buffering' ), 0 );

// Commenting hooks.
add_filter( 'wp_list_comments_args', array( __CLASS__, 'amp_set_comments_walker' ), PHP_INT_MAX );
add_filter( 'wp_list_comments_args', array( __CLASS__, 'set_comments_walker' ), PHP_INT_MAX );
add_filter( 'comment_form_defaults', array( __CLASS__, 'filter_comment_form_defaults' ) );
add_filter( 'comment_reply_link', array( __CLASS__, 'filter_comment_reply_link' ), 10, 4 );
add_filter( 'cancel_comment_reply_link', array( __CLASS__, 'filter_cancel_comment_reply_link' ), 10, 3 );
Expand Down Expand Up @@ -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 ) {
Copy link
Contributor

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 );

$amp_walker = new AMP_Comment_Walker();
$args['walker'] = $amp_walker;
// Add reverse order here as well, in case theme overrides it.
Expand Down Expand Up @@ -983,7 +981,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' ) ) {
Copy link
Contributor

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.

newrelic_disable_autorum();
}

Expand Down
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<directory suffix=".php">./</directory>
<exclude>
<directory suffix=".php">dev-lib</directory>
<directory suffix=".php">svn</directory>
<directory suffix=".php">node_modules</directory>
<directory suffix=".php">tests</directory>
<directory suffix=".php">vendor</directory>
Expand Down
4 changes: 2 additions & 2 deletions tests/test-amp-analytics-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function test_two_analytics_components_added() {
/**
* Test amp_get_analytics()
*
* @covers amp_get_analytics()
* @covers \amp_get_analytics()
*/
public function test_amp_get_analytics() {
$this->insert_one_option(
Expand All @@ -243,7 +243,7 @@ public function test_amp_get_analytics() {
/**
* Test amp_print_analytics()
*
* @covers amp_print_analytics()
* @covers \amp_print_analytics()
*/
public function test_amp_print_analytics() {
$this->insert_one_option(
Expand Down
14 changes: 7 additions & 7 deletions tests/test-amp-helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function return_example_url( $url, $post_id ) {
/**
* Test amp_get_slug().
*
* @covers amp_get_slug()
* @covers \amp_get_slug()
*/
public function test_amp_get_slug() {
$this->assertSame( 'amp', amp_get_slug() );
Expand Down Expand Up @@ -181,8 +181,8 @@ public function capture_filter_call( $value ) {
/**
* Test script registering.
*
* @covers amp_register_default_scripts()
* @covers amp_filter_script_loader_tag()
* @covers \amp_register_default_scripts()
* @covers \amp_filter_script_loader_tag()
* @global WP_Scripts $wp_scripts
*/
public function test_script_registering() {
Expand Down Expand Up @@ -223,7 +223,7 @@ public function test_script_registering() {
/**
* Test amp_get_content_embed_handlers().
*
* @covers amp_get_content_embed_handlers()
* @covers \amp_get_content_embed_handlers()
*/
public function test_amp_get_content_embed_handlers() {
$post = $this->factory()->post->create_and_get();
Expand All @@ -249,7 +249,7 @@ public function test_amp_get_content_embed_handlers() {
/**
* Test deprecated $post param for amp_get_content_embed_handlers().
*
* @covers amp_get_content_embed_handlers()
* @covers \amp_get_content_embed_handlers()
*/
public function test_amp_get_content_embed_handlers_deprecated_param() {
$post = $this->factory()->post->create_and_get();
Expand All @@ -261,7 +261,7 @@ public function test_amp_get_content_embed_handlers_deprecated_param() {
/**
* Test amp_get_content_sanitizers().
*
* @covers amp_get_content_sanitizers()
* @covers \amp_get_content_sanitizers()
*/
public function test_amp_get_content_sanitizers() {
$post = $this->factory()->post->create_and_get();
Expand Down Expand Up @@ -299,7 +299,7 @@ public function test_amp_get_content_sanitizers() {
/**
* Test deprecated $post param for amp_get_content_sanitizers().
*
* @covers amp_get_content_sanitizers()
* @covers \amp_get_content_sanitizers()
*/
public function test_amp_get_content_sanitizers_deprecated_param() {
$post = $this->factory()->post->create_and_get();
Expand Down
2 changes: 1 addition & 1 deletion tests/test-amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function tearDown() {
/**
* Test amp_is_canonical().
*
* @covers amp_is_canonical()
* @covers \amp_is_canonical()
*/
public function test_amp_is_canonical() {
remove_theme_support( 'amp' );
Expand Down
Loading