Skip to content

Commit

Permalink
Update xpath query in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thelovekesh committed Oct 26, 2022
1 parent e0a6906 commit 6bec836
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/php/test-class-amp-gtag-script-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AMP_GTag_Script_Sanitizer_Test extends TestCase {
*
* @var string
*/
const INLINE_GTAG_EVENT_XPATH = '//@*[ substring(name(), 1, 2) = "on" and name() != "on" and contains(., "gtag(") ]';
const INLINE_GTAG_EVENT_XPATH = '//@*[ starts-with(name(), "on") and name() != "on" and contains(., "gtag(") ]';

/**
* HTML markup with gtag script.
Expand Down Expand Up @@ -112,7 +112,7 @@ public function test_sanitize( $enable_sandboxing, $sandboxing_level, $expect_px

// Inline Gtag events.
$inline_gtag_events = $dom->xpath->query( self::INLINE_GTAG_EVENT_XPATH );
$other_inline_events = $dom->xpath->query( '//@*[ substring(name(), 1, 2) = "on" and name() != "on" and not( contains(., "gtag(") ) ]' );
$other_inline_events = $dom->xpath->query( '//@*[ starts-with(name(), "on") and name() != "on" and not( contains(., "gtag(") ) ]' );

$this->assertCount( 2, $inline_gtag_events );
$this->assertInstanceof( DOMNodeList::class, $inline_gtag_events );
Expand Down

0 comments on commit 6bec836

Please sign in to comment.