Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/rdf/tests/src/Functional/EntityReferenceFieldAttributesTest.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
1 <?php | 1 <?php |
2 | 2 |
3 namespace Drupal\Tests\rdf\Functional; | 3 namespace Drupal\Tests\rdf\Functional; |
4 | 4 |
5 use Drupal\Core\Url; | |
5 use Drupal\Core\Field\FieldStorageDefinitionInterface; | 6 use Drupal\Core\Field\FieldStorageDefinitionInterface; |
6 use Drupal\Tests\taxonomy\Functional\TaxonomyTestBase; | 7 use Drupal\Tests\taxonomy\Functional\TaxonomyTestBase; |
7 | 8 |
8 /** | 9 /** |
9 * Tests RDFa markup generation for taxonomy term fields. | 10 * Tests RDFa markup generation for taxonomy term fields. |
84 ->save(); | 85 ->save(); |
85 | 86 |
86 // Create a term in each vocabulary. | 87 // Create a term in each vocabulary. |
87 $term1 = $this->createTerm($this->vocabulary); | 88 $term1 = $this->createTerm($this->vocabulary); |
88 $term2 = $this->createTerm($this->vocabulary); | 89 $term2 = $this->createTerm($this->vocabulary); |
89 $taxonomy_term_1_uri = $term1->url('canonical', ['absolute' => TRUE]); | 90 $taxonomy_term_1_uri = $term1->toUrl('canonical', ['absolute' => TRUE])->toString(); |
90 $taxonomy_term_2_uri = $term2->url('canonical', ['absolute' => TRUE]); | 91 $taxonomy_term_2_uri = $term2->toUrl('canonical', ['absolute' => TRUE])->toString(); |
91 | 92 |
92 // Create the node. | 93 // Create the node. |
93 $node = $this->drupalCreateNode(['type' => 'article']); | 94 $node = $this->drupalCreateNode(['type' => 'article']); |
94 $node->set($this->fieldName, [ | 95 $node->set($this->fieldName, [ |
95 ['target_id' => $term1->id()], | 96 ['target_id' => $term1->id()], |
101 $html = \Drupal::service('renderer')->renderRoot($node_render_array); | 102 $html = \Drupal::service('renderer')->renderRoot($node_render_array); |
102 | 103 |
103 // Parse the teaser. | 104 // Parse the teaser. |
104 $parser = new \EasyRdf_Parser_Rdfa(); | 105 $parser = new \EasyRdf_Parser_Rdfa(); |
105 $graph = new \EasyRdf_Graph(); | 106 $graph = new \EasyRdf_Graph(); |
106 $base_uri = \Drupal::url('<front>', [], ['absolute' => TRUE]); | 107 $base_uri = Url::fromRoute('<front>', [], ['absolute' => TRUE])->toString(); |
107 $parser->parse($graph, $html, 'rdfa', $base_uri); | 108 $parser->parse($graph, $html, 'rdfa', $base_uri); |
108 | 109 |
109 // Node relations to taxonomy terms. | 110 // Node relations to taxonomy terms. |
110 $node_uri = $node->url('canonical', ['absolute' => TRUE]); | 111 $node_uri = $node->toUrl('canonical', ['absolute' => TRUE])->toString(); |
111 $expected_value = [ | 112 $expected_value = [ |
112 'type' => 'uri', | 113 'type' => 'uri', |
113 'value' => $taxonomy_term_1_uri, | 114 'value' => $taxonomy_term_1_uri, |
114 ]; | 115 ]; |
115 $this->assertTrue($graph->hasProperty($node_uri, 'http://purl.org/dc/terms/subject', $expected_value), 'Node to term relation found in RDF output (dc:subject).'); | 116 $this->assertTrue($graph->hasProperty($node_uri, 'http://purl.org/dc/terms/subject', $expected_value), 'Node to term relation found in RDF output (dc:subject).'); |