Chris@0: vocabulary = $this->createVocabulary(); Chris@0: Chris@0: // RDF mapping - term bundle. Chris@0: rdf_get_mapping('taxonomy_term', $this->vocabulary->id()) Chris@0: ->setBundleMapping(['types' => ['skos:Concept']]) Chris@0: ->setFieldMapping('name', [ Chris@0: 'properties' => ['rdfs:label', 'skos:prefLabel'], Chris@0: ]) Chris@0: ->save(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Creates a random term and ensures the RDF output is correct. Chris@0: */ Chris@0: public function testTaxonomyTermRdfaAttributes() { Chris@0: $term = $this->createTerm($this->vocabulary); Chris@18: $term_uri = $term->toUrl('canonical', ['absolute' => TRUE])->toString(); Chris@0: Chris@0: // Parses the term's page and checks that the RDF output is correct. Chris@0: $parser = new \EasyRdf_Parser_Rdfa(); Chris@0: $graph = new \EasyRdf_Graph(); Chris@18: $base_uri = Url::fromRoute('', [], ['absolute' => TRUE])->toString(); Chris@0: $parser->parse($graph, $this->drupalGet('taxonomy/term/' . $term->id()), 'rdfa', $base_uri); Chris@0: Chris@0: // Inspects RDF graph output. Chris@0: // Term type. Chris@0: $expected_value = [ Chris@0: 'type' => 'uri', Chris@0: 'value' => 'http://www.w3.org/2004/02/skos/core#Concept', Chris@0: ]; Chris@0: $this->assertTrue($graph->hasProperty($term_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Term type found in RDF output (skos:Concept).'); Chris@0: // Term label. Chris@0: $expected_value = [ Chris@0: 'type' => 'literal', Chris@0: 'value' => $term->getName(), Chris@0: 'lang' => 'en', Chris@0: ]; Chris@0: $this->assertTrue($graph->hasProperty($term_uri, 'http://www.w3.org/2000/01/rdf-schema#label', $expected_value), 'Term label found in RDF output (rdfs:label).'); Chris@0: // Term label. Chris@0: $expected_value = [ Chris@0: 'type' => 'literal', Chris@0: 'value' => $term->getName(), Chris@0: 'lang' => 'en', Chris@0: ]; Chris@0: $this->assertTrue($graph->hasProperty($term_uri, 'http://www.w3.org/2004/02/skos/core#prefLabel', $expected_value), 'Term label found in RDF output (skos:prefLabel).'); Chris@0: Chris@0: // @todo Add test for term description once it is a field: Chris@0: // https://www.drupal.org/node/569434. Chris@0: } Chris@0: Chris@0: }