Skip to content

Commit

Permalink
Add test case when no gtag script is present at page
Browse files Browse the repository at this point in the history
  • Loading branch information
thelovekesh committed Oct 26, 2022
1 parent 6bec836 commit 9f945a3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/php/test-class-amp-gtag-script-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,24 @@ public function test_sanitize( $enable_sandboxing, $sandboxing_level, $expect_px
$this->assertFalse( ValidationExemption::is_px_verified_for_node( $other_inline_event ) );
}
}

/**
* Test sanitize when no gtag script is present.
*
* @covers ::sanitize
*/
public function test_sanitize_when_no_gtag_script() {
$markup = '<html><head><script>console.log("Hello world!");</script></head><body><p>Hello world!</p></body></html>';

$dom = new Document();
$dom->loadHTML( $markup );

$sanitizer = new AMP_GTag_Script_Sanitizer( $dom );
$sanitizer->sanitize();

$gtag_scripts = $dom->xpath->query( self::SCRIPT_XPATH );

$this->assertCount( 0, $gtag_scripts );
$this->assertSame( 0, $gtag_scripts->length );
}
}

0 comments on commit 9f945a3

Please sign in to comment.