Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type parser-html to JSONScript to allow assertions on HTML structure (Backport #2540) #2547

Merged
merged 1 commit into from Jul 22, 2017

Conversation

Projects
None yet
2 participants
@s7eph4n
Copy link
Contributor

s7eph4n commented Jul 11, 2017

This PR is made in reference to: #2540

Allows JSONScript test scripts to make assertions on the HTML structure of the parser output.

Rules are described as CSS selectors, e.g.

{
	"type": "parser-html",
	"about": "#0 Basic List format",
	"subject": "Example/0401",
	"assert-output": {
		"to-contain": [
			"p > a[ title='Bar' ] + a[ title='Baz' ] + a[ title='Foo' ] + a[ title='Quok' ]"
		]
	}
}

A requirement on the number of occurrences can be described as well, e.g.

{
        "type": "parser-html",
        "about": "#0 Basic List format",
        "subject": "Example/0401",
        "assert-output": {
                "to-contain": [
                        [ "p > a", 4 ]
                ]
        }
}

Finally the general wellformedness of the HTML can be asserted, although this will not fail for recoverable errors (see http://php.net/manual/en/domdocument.loadhtml.php#refsect1-domdocument.loadhtml-errors).
Example:

{
	"type": "parser-html",
	"about": "#0 Basic List format",
	"subject": "Example/0401",
	"assert-output": {
		"to-be-valid-html": 1
	}
}

This PR includes:

  • Tests (unit/integration)
  • CI build passed

@s7eph4n s7eph4n force-pushed the s7eph4n:2.5.x branch from 7a5ebf1 to 17195d9 Jul 11, 2017

Add type parser-html to JSONScript to allow assertions on HTML struct…
…ure (Backport #2540)

Allows `JSONScript` test scripts to make assertions on the HTML structure of the parser output.

Rules are described as CSS selectors, e.g.

``` json
{
	"type": "parser-html",
	"about": "#0 Basic List format",
	"subject": "Example/0401",
	"assert-output": {
		"to-contain": [
			"p > a[ title='Bar' ] + a[ title='Baz' ] + a[ title='Foo' ] + a[ title='Quok' ]"
		]
	}
}
```

A requirement on the number of occurrences can be described as well, e.g.
``` json
{
        "type": "parser-html",
        "about": "#0 Basic List format",
        "subject": "Example/0401",
        "assert-output": {
                "to-contain": [
                        [ "p > a", 4 ]
                ]
        }
}
```

Finally the general wellformedness of the HTML can be asserted, although this will not fail for recoverable errors (see http://php.net/manual/en/domdocument.loadhtml.php#refsect1-domdocument.loadhtml-errors).
Example:
``` json
{
	"type": "parser-html",
	"about": "#0 Basic List format",
	"subject": "Example/0401",
	"assert-output": {
		"to-be-valid-html": 1
	}
}
```

@s7eph4n s7eph4n force-pushed the s7eph4n:2.5.x branch from 17195d9 to bf9ed0c Jul 11, 2017

@mwjames mwjames merged commit b527e3c into SemanticMediaWiki:2.5.x Jul 22, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.