You are here

protected function RdfParsingTrait::hasRdfProperty in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/rdf/tests/src/Traits/RdfParsingTrait.php \Drupal\Tests\rdf\Traits\RdfParsingTrait::hasRdfProperty()
  2. 9 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:

Return value

bool TRUE if the property exists with the given value.

Throws

\EasyRdf\Exception

1 call to RdfParsingTrait::hasRdfProperty()
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\Traits

Code

protected function hasRdfProperty($html, $base_uri, $resource, $property, array $value) {
  $parser = new Rdfa();
  $graph = new Graph();
  $parser
    ->parse($graph, $html, 'rdfa', $base_uri);
  return $graph
    ->hasProperty($resource, $property, $value);
}