protected function RdfParsingTrait::hasRdfProperty in Drupal 9
Same name and namespace in other branches
- 8 core/modules/rdf/tests/src/Traits/RdfParsingTrait.php \Drupal\Tests\rdf\Traits\RdfParsingTrait::hasRdfProperty()
- 10 core/modules/rdf/tests/src/Traits/RdfParsingTrait.php \Drupal\Tests\rdf\Traits\RdfParsingTrait::hasRdfProperty()
Checks if a html document contains a resource with a given property value.
Parameters
string $html: The HTML to parse.
string $base_uri: The base URI for the html being parsed.
string $resource: The URI of the resource which should have the given property.
string $property: The property being tested.
array $value: The expected value. This should include the following keys:
- type: one of literal, uri and bnode
- value: the expected value
- datatype: the expected datatype in URI format - e.g.
- lang: language code of the property.
Return value
bool TRUE if the property exists with the given value.
Throws
\EasyRdf\Exception
17 calls to RdfParsingTrait::hasRdfProperty()
- CommentAttributesTest::testCommentReplyOfRdfaMarkup in core/
modules/ rdf/ tests/ src/ Functional/ CommentAttributesTest.php - Tests RDF comment replies.
- CommentAttributesTest::testNumberOfCommentsRdfaMarkup in core/
modules/ rdf/ tests/ src/ Functional/ CommentAttributesTest.php - Tests the presence of the RDFa markup for the number of comments.
- CommentAttributesTest::_testBasicCommentRdfaMarkup in core/
modules/ rdf/ tests/ src/ Functional/ CommentAttributesTest.php - Helper function for testCommentRdfaMarkup().
- EntityReferenceFieldAttributesTest::testNodeTeaser in core/
modules/ rdf/ tests/ src/ Functional/ EntityReferenceFieldAttributesTest.php - Tests if file fields in teasers have correct resources.
- FieldRdfaTestBase::assertFormatterRdfa in core/
modules/ rdf/ tests/ src/ Kernel/ Field/ FieldRdfaTestBase.php - Helper function to test the formatter's RDFa.
File
- core/
modules/ rdf/ tests/ src/ Traits/ RdfParsingTrait.php, line 39
Class
- RdfParsingTrait
- Defines a trait for parsing RDF properties from HTML.
Namespace
Drupal\Tests\rdf\TraitsCode
protected function hasRdfProperty($html, $base_uri, $resource, $property, array $value) {
$parser = $this
->getInstanceParser();
$graph = $this
->getInstanceGraph();
$parser
->parse($graph, $html, 'rdfa', $base_uri);
return $graph
->hasProperty($resource, $property, $value);
}