comparison core/modules/rdf/tests/src/Functional/UserAttributesTest.php @ 18:af1871eacc83

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:33:08 +0100
parents 129ea1e6d783
children
comparison
equal deleted inserted replaced
17:129ea1e6d783 18:af1871eacc83
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\Tests\BrowserTestBase; 6 use Drupal\Tests\BrowserTestBase;
6 7
7 /** 8 /**
8 * Tests the RDFa markup of Users. 9 * Tests the RDFa markup of Users.
9 * 10 *
52 53
53 $this->drupalCreateContentType(['type' => 'article']); 54 $this->drupalCreateContentType(['type' => 'article']);
54 55
55 /** @var \Drupal\user\UserInterface[] $authors */ 56 /** @var \Drupal\user\UserInterface[] $authors */
56 foreach ($authors as $author) { 57 foreach ($authors as $author) {
57 $account_uri = $author->url('canonical', ['absolute' => TRUE]); 58 $account_uri = $author->toUrl('canonical', ['absolute' => TRUE])->toString();
58 59
59 // Parses the user profile page where the default bundle mapping for user 60 // Parses the user profile page where the default bundle mapping for user
60 // should be used. 61 // should be used.
61 $parser = new \EasyRdf_Parser_Rdfa(); 62 $parser = new \EasyRdf_Parser_Rdfa();
62 $graph = new \EasyRdf_Graph(); 63 $graph = new \EasyRdf_Graph();
63 $base_uri = \Drupal::url('<front>', [], ['absolute' => TRUE]); 64 $base_uri = Url::fromRoute('<front>', [], ['absolute' => TRUE])->toString();
64 $parser->parse($graph, $this->drupalGet('user/' . $author->id()), 'rdfa', $base_uri); 65 $parser->parse($graph, $this->drupalGet('user/' . $author->id()), 'rdfa', $base_uri);
65 66
66 // Inspects RDF graph output. 67 // Inspects RDF graph output.
67 // User type. 68 // User type.
68 $expected_value = [ 69 $expected_value = [
71 ]; 72 ];
72 $this->assertTrue($graph->hasProperty($account_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'User type found in RDF output (sioc:UserAccount).'); 73 $this->assertTrue($graph->hasProperty($account_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'User type found in RDF output (sioc:UserAccount).');
73 // User name. 74 // User name.
74 $expected_value = [ 75 $expected_value = [
75 'type' => 'literal', 76 'type' => 'literal',
76 'value' => $author->getUsername(), 77 'value' => $author->getAccountName(),
77 ]; 78 ];
78 $this->assertTrue($graph->hasProperty($account_uri, 'http://xmlns.com/foaf/0.1/name', $expected_value), 'User name found in RDF output (foaf:name).'); 79 $this->assertTrue($graph->hasProperty($account_uri, 'http://xmlns.com/foaf/0.1/name', $expected_value), 'User name found in RDF output (foaf:name).');
79 80
80 // User creates a node. 81 // User creates a node.
81 $this->drupalLogin($author); 82 $this->drupalLogin($author);
83 $this->drupalLogin($user1); 84 $this->drupalLogin($user1);
84 85
85 // Parses the node created by the user. 86 // Parses the node created by the user.
86 $parser = new \EasyRdf_Parser_Rdfa(); 87 $parser = new \EasyRdf_Parser_Rdfa();
87 $graph = new \EasyRdf_Graph(); 88 $graph = new \EasyRdf_Graph();
88 $base_uri = \Drupal::url('<front>', [], ['absolute' => TRUE]); 89 $base_uri = Url::fromRoute('<front>', [], ['absolute' => TRUE])->toString();
89 $parser->parse($graph, $this->drupalGet('node/' . $node->id()), 'rdfa', $base_uri); 90 $parser->parse($graph, $this->drupalGet('node/' . $node->id()), 'rdfa', $base_uri);
90 91
91 // Ensures the default bundle mapping for user is used on the Authored By 92 // Ensures the default bundle mapping for user is used on the Authored By
92 // information on the node. 93 // information on the node.
93 $expected_value = [ 94 $expected_value = [
96 ]; 97 ];
97 $this->assertTrue($graph->hasProperty($account_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'User type found in RDF output (sioc:UserAccount).'); 98 $this->assertTrue($graph->hasProperty($account_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'User type found in RDF output (sioc:UserAccount).');
98 // User name. 99 // User name.
99 $expected_value = [ 100 $expected_value = [
100 'type' => 'literal', 101 'type' => 'literal',
101 'value' => $author->getUsername(), 102 'value' => $author->getAccountName(),
102 ]; 103 ];
103 $this->assertTrue($graph->hasProperty($account_uri, 'http://xmlns.com/foaf/0.1/name', $expected_value), 'User name found in RDF output (foaf:name).'); 104 $this->assertTrue($graph->hasProperty($account_uri, 'http://xmlns.com/foaf/0.1/name', $expected_value), 'User name found in RDF output (foaf:name).');
104 105
105 } 106 }
106 } 107 }