Skip to content

Commit

Permalink
Fix tests, !== ! == ===
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsnell committed Aug 21, 2024
1 parent 40f4967 commit 4c652ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/wp-includes/html-api/class-wp-html-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,9 @@ public static function create_fragment( $html, $context = '<body>', $encoding =
}

$context_node = self::parse_context_element( $context );
var_dump( $context_node );
if ( null === $context_node ) {
_doing_it_wrong(
__FUNCTION__,
__METHOD__,
__( 'The context argument must be an HTML start tag.' ),
'6.7.0'
);
Expand All @@ -320,7 +319,7 @@ public static function create_fragment( $html, $context = '<body>', $encoding =

if ( self::is_void( $context_node[0] ) ) {
_doing_it_wrong(
__FUNCTION__,
__METHOD__,
__( 'The context argument may not specify a void element.' ),
'6.7.0'
);
Expand All @@ -329,7 +328,7 @@ public static function create_fragment( $html, $context = '<body>', $encoding =

if ( in_array( $context_node[0], array( 'IFRAME', 'NOEMBED', 'NOFRAMES', 'SCRIPT', 'STYLE', 'TEXTAREA', 'TITLE', 'XMP' ), true ) ) {
_doing_it_wrong(
__FUNCTION__,
__METHOD__,
__( 'The context argument may not specify a self-contained element.' ),
'6.7.0'
);
Expand Down Expand Up @@ -387,7 +386,7 @@ public static function create_fragment( $html, $context = '<body>', $encoding =
* @return array|null Element name and associative array of attributes if parsed, otherwise NULL.
*/
private static function parse_context_element( $context = '<body>' ): ?array {
if ( '<body>' !== $context ) {
if ( '<body>' === $context ) {
return array( 'BODY', array() );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class Tests_HtmlApi_WpHtmlProcessorFragmentParsing extends WP_UnitTestCase {
*
* @dataProvider data_invalid_fragment_contexts
*
* @expectedIncorrectUsage WP_HTML_Processor::create_fragment
*
* @param string $context Invalid context node for fragment parser.
*/
public function test_rejects_invalid_fragment_contexts( string $context ) {
Expand Down

0 comments on commit 4c652ad

Please sign in to comment.