Skip to content

Commit

Permalink
Fix OutputNotEscaped errors in tests; restore output of debug informa…
Browse files Browse the repository at this point in the history
…tion via assertion message
  • Loading branch information
westonruter committed Apr 26, 2018
1 parent 62f19c1 commit f2e422f
Showing 1 changed file with 11 additions and 57 deletions.
68 changes: 11 additions & 57 deletions tests/amp-tag-and-attribute-sanitizer-private-methods-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,7 @@ public function test_validate_attr_spec_rules( $data, $expected ) {

$got = $this->invoke_method( $sanitizer, $data['func_name'], array( $node, $data['attribute_name'], $attr_spec_rule ) );

if ( $expected != $got ) {
printf( 'using source: %s' . PHP_EOL, $source );
}

$this->assertEquals( $expected, $got );
$this->assertEquals( $expected, $got, sprintf( "using source: %s\n%s", $source, wp_json_encode( $data ) ) );
}

public function get_is_allowed_attribute_data() {
Expand Down Expand Up @@ -565,11 +561,7 @@ public function test_is_allowed_attribute( $data, $expected ) {

$got = $this->invoke_method( $sanitizer, $data['func_name'], array( $data['attribute_name'], $attr_spec_list ) );

if ( $expected != $got ) {
printf( 'using source: %s' . PHP_EOL, $source );
}

$this->assertEquals( $expected, $got );
$this->assertEquals( $expected, $got, sprintf( "using source: %s\n%s", $source, wp_json_encode( $data ) ) );
}

public function get_remove_node_data() {
Expand Down Expand Up @@ -660,12 +652,7 @@ public function test_remove_node( $data, $expected ) {

$got = AMP_DOM_Utils::get_content_from_dom( $dom );

if ( $expected != $got ) {
printf( 'using source: %s' . PHP_EOL, $data['source'] );
printf( 'got = %s' .PHP_EOL, $got );
}

$this->assertEquals( $expected, $got );
$this->assertEquals( $expected, $got, sprintf( "using source: %s\n%s", $data['source'], wp_json_encode( $data ) ) );
}


Expand Down Expand Up @@ -800,12 +787,7 @@ public function test_replace_node_with_children( $data, $expected ) {
$got = AMP_DOM_Utils::get_content_from_dom( $dom );
$got = preg_replace( '/(?<=>)\s+(?=<)/', '', $got );

if ( $expected != $got ) {
printf( 'using source: %s' . PHP_EOL, $data['source'] );
printf( 'got = %s' .PHP_EOL, $got );
}

$this->assertEquals( $expected, $got );
$this->assertEquals( $expected, $got, sprintf( "using source: %s\n%s", $data['source'], wp_json_encode( $data ) ) );
}

public function get_ancestor_with_tag_name_data() {
Expand Down Expand Up @@ -861,11 +843,7 @@ public function test_get_ancestor_with_tag_name( $data, $expected ) {

$got = $this->invoke_method( $sanitizer, 'get_ancestor_with_tag_name', array( $node, $data['ancestor_tag_name'] ) );

if ( $ancestor_node != $got ) {
printf( 'using source: %s' . PHP_EOL, $data['source'] );
}

$this->assertEquals( $ancestor_node, $got );
$this->assertEquals( $ancestor_node, $got, sprintf( "using source: %s\n%s", $data['source'], wp_json_encode( $data ) ) );
}

public function get_validate_attr_spec_list_for_node_data() {
Expand Down Expand Up @@ -1066,11 +1044,7 @@ public function test_validate_attr_spec_list_for_node( $data, $expected ) {

$got = $this->invoke_method( $sanitizer, 'validate_attr_spec_list_for_node', array( $node, $data['attr_spec_list'] ) );

if ( $expected != $got ) {
printf( 'using source: %s' . PHP_EOL, $data['source'] );
}

$this->assertEquals( $expected, $got );
$this->assertEquals( $expected, $got, sprintf( "using source: %s\n%s", $data['source'], wp_json_encode( $data ) ) );
}

public function get_check_attr_spec_rule_value_data() {
Expand Down Expand Up @@ -1192,11 +1166,7 @@ public function test_check_attr_spec_rule_value( $data, $expected ) {

$got = $this->invoke_method( $sanitizer, 'check_attr_spec_rule_value', array( $node, $data['attr_name'], $data['attr_spec_rule'] ) );

if ( $expected != $got ) {
printf( 'using source: %s' . PHP_EOL, $data['source'] );
}

$this->assertEquals( $expected, $got );
$this->assertEquals( $expected, $got, sprintf( "using source: %s\n%s", $data['source'], wp_json_encode( $data ) ) );
}

public function get_check_attr_spec_rule_value_casei_data() {
Expand Down Expand Up @@ -1343,11 +1313,7 @@ public function test_check_attr_spec_rule_value_casei( $data, $expected ) {

$got = $this->invoke_method( $sanitizer, 'check_attr_spec_rule_value_casei', array( $node, $data['attr_name'], $data['attr_spec_rule'] ) );

if ( $expected != $got ) {
printf( 'using source: %s' . PHP_EOL, $data['source'] );
}

$this->assertEquals( $expected, $got );
$this->assertEquals( $expected, $got, sprintf( "using source: %s\n%s", $data['source'], wp_json_encode( $data ) ) );
}

public function get_check_attr_spec_rule_blacklisted_value_regex() {
Expand Down Expand Up @@ -1436,11 +1402,7 @@ public function test_check_attr_spec_rule_blacklisted_value_regex( $data, $expec

$got = $this->invoke_method( $sanitizer, 'check_attr_spec_rule_blacklisted_value_regex', array( $node, $data['attr_name'], $data['attr_spec_rule'] ) );

if ( $expected != $got ) {
printf( 'using source: %s' . PHP_EOL, $data['source'] );
}

$this->assertEquals( $expected, $got );
$this->assertEquals( $expected, $got, sprintf( "using source: %s\n%s", $data['source'], wp_json_encode( $data ) ) );
}

public function get_check_attr_spec_rule_allowed_protocol() {
Expand Down Expand Up @@ -1570,11 +1532,7 @@ public function test_check_attr_spec_rule_allowed_protocol( $data, $expected ) {

$got = $this->invoke_method( $sanitizer, 'check_attr_spec_rule_allowed_protocol', array( $node, $data['attr_name'], $data['attr_spec_rule'] ) );

if ( $expected != $got ) {
printf( 'using source: %s' . PHP_EOL, $data['source'] );
}

$this->assertEquals( $expected, $got );
$this->assertEquals( $expected, $got, sprintf( "using source: %s\n%s", $data['source'], wp_json_encode( $data ) ) );
}

public function get_check_attr_spec_rule_disallowed_relative() {
Expand Down Expand Up @@ -1718,11 +1676,7 @@ public function test_check_attr_spec_rule_disallowed_relative( $data, $expected

$got = $this->invoke_method( $sanitizer, 'check_attr_spec_rule_disallowed_relative', array( $node, $data['attr_name'], $data['attr_spec_rule'] ) );

if ( $expected != $got ) {
printf( 'using source: %s' . PHP_EOL, $data['source'] );
}

$this->assertEquals( $expected, $got );
$this->assertEquals( $expected, $got, sprintf( "using source: %s\n%s", $data['source'], wp_json_encode( $data ) ) );
}

/**
Expand Down

0 comments on commit f2e422f

Please sign in to comment.