Skip to content

Commit

Permalink
Add test for amp_print_schemaorg_metadata()
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Dec 7, 2020
1 parent f5c31c2 commit 769546f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/php/test-amp-helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1728,6 +1728,27 @@ static function( $meta ) use ( $self ) {
$this->assertEquals( $metadata['publisher']['logo']['url'], amp_get_publisher_logo() );
}

/**
* Test amp_print_schemaorg_metadata().
*
* @covers ::amp_print_schemaorg_metadata()
*/
public function test_amp_print_schemaorg_metadata() {
add_filter( 'amp_schemaorg_metadata', '__return_empty_array' );
$output = get_echo( 'amp_print_schemaorg_metadata' );
$this->assertEmpty( $output );

remove_filter( 'amp_schemaorg_metadata', '__return_empty_array' );
add_filter(
'amp_schemaorg_metadata',
static function () {
return [ 'foo' => 'bar' ];
}
);
$output = trim( get_echo( 'amp_print_schemaorg_metadata' ) );
$this->assertSame( '<script type="application/ld+json">{"foo":"bar"}</script>', $output );
}

/**
* Test amp_add_admin_bar_view_link()
*
Expand Down

0 comments on commit 769546f

Please sign in to comment.