Skip to content

Commit ccb5eda

Browse files
committed
Fix tests after on changes to Schema.org metadata inclusion
1 parent 02ace15 commit ccb5eda

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

tests/php/test-class-amp-schema-org-metadata.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,21 @@ public function get_schema_script_data() {
5555
* @param int $expected Expected count of valid JSON+LD schema.
5656
*/
5757
public function test_transform( $json, $expected ) {
58-
$html = '<html><head><script type="application/ld+json">%s</script></head><body>Test</body></html>';
59-
$dom = Document::fromHtml( sprintf( $html, $json ), Options::DEFAULTS );
60-
$transformer = new AmpSchemaOrgMetadata( new AmpSchemaOrgMetadataConfiguration() );
61-
$errors = new ErrorCollection();
58+
$html = '<html><head><script type="application/ld+json">%s</script></head><body>Test</body></html>';
59+
$dom = Document::fromHtml( sprintf( $html, $json ), Options::DEFAULTS );
60+
$configuration = new AmpSchemaOrgMetadataConfiguration(
61+
[
62+
AmpSchemaOrgMetadataConfiguration::METADATA => [
63+
'@context' => 'http://schema.org',
64+
'publisher' => [
65+
'@type' => 'Organization',
66+
'name' => 'Acme',
67+
],
68+
],
69+
]
70+
);
71+
$transformer = new AmpSchemaOrgMetadata( $configuration );
72+
$errors = new ErrorCollection();
6273
$transformer->transform( $dom, $errors );
6374
$this->assertEquals( $expected, substr_count( $dom->saveHTML(), 'schema.org' ) );
6475
}
@@ -69,8 +80,6 @@ public function test_transform( $json, $expected ) {
6980
* @covers ::transform
7081
*/
7182
public function test_empty_metadata_configuration() {
72-
add_filter( 'amp_schemaorg_metadata', '__return_empty_array' );
73-
7483
$dom = new Document();
7584
$transformer = new AmpSchemaOrgMetadata( new AmpSchemaOrgMetadataConfiguration() );
7685
$transformer->transform( $dom, new ErrorCollection() );

tests/php/test-class-amp-theme-support.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1982,7 +1982,7 @@ public function test_prepare_response_throwing_exception() {
19821982
);
19831983

19841984
add_filter(
1985-
'amp_schemaorg_metadata',
1985+
'amp_enable_optimizer',
19861986
static function () {
19871987
throw new RuntimeException( 'FAILURE', 42 );
19881988
}

0 commit comments

Comments
 (0)