Skip to content

Commit

Permalink
Merge pull request #1034 from Automattic/add/test-coverage
Browse files Browse the repository at this point in the history
Add test coverage for AMP_Theme_Support
  • Loading branch information
westonruter committed Apr 3, 2018
2 parents 49f5928 + 71b83fc commit dc51778
Show file tree
Hide file tree
Showing 6 changed files with 634 additions and 188 deletions.
10 changes: 4 additions & 6 deletions includes/class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,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 @@ -244,7 +242,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 @@ -601,7 +599,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 ) {
$amp_walker = new AMP_Comment_Walker();
$args['walker'] = $amp_walker;
return $args;
Expand Down Expand Up @@ -950,7 +948,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' ) ) {
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

0 comments on commit dc51778

Please sign in to comment.