protected function StandardProfileTest::setUp in Drupal 10
Same name and namespace in other branches
- 8 core/modules/rdf/tests/src/Functional/StandardProfileTest.php \Drupal\Tests\rdf\Functional\StandardProfileTest::setUp()
- 9 core/modules/rdf/tests/src/Functional/StandardProfileTest.php \Drupal\Tests\rdf\Functional\StandardProfileTest::setUp()
File
- core/modules/rdf/tests/src/Functional/StandardProfileTest.php, line 151
Class
- StandardProfileTest
- Tests the RDF mappings and RDFa markup on top of the standard profile.
Namespace
Drupal\Tests\rdf\Functional
Code
protected function setUp() : void {
parent::setUp();
$this->baseUri = Url::fromRoute('<front>', [], [
'absolute' => TRUE,
])
->toString();
$this->adminUser = $this
->drupalCreateUser([
'administer content types',
'administer comments',
'access comments',
'access content',
]);
$this->webUser = $this
->drupalCreateUser([
'access comments',
'post comments',
'skip comment approval',
'access content',
]);
$this
->drupalLogin($this->adminUser);
$this->term = Term::create([
'name' => $this
->randomMachineName(),
'description' => $this
->randomMachineName(),
'vid' => 'tags',
]);
$this->term
->save();
\Drupal::service('file_system')
->copy($this->root . '/core/misc/druplicon.png', 'public://example.jpg');
$this->image = File::create([
'uri' => 'public://example.jpg',
]);
$this->image
->save();
$article_settings = [
'type' => 'article',
'promote' => NodeInterface::PROMOTED,
'field_image' => [
[
'target_id' => $this->image
->id(),
],
],
'field_tags' => [
[
'target_id' => $this->term
->id(),
],
],
];
$this->article = $this
->drupalCreateNode($article_settings);
$this
->drupalCreateNode([
'type' => 'article',
'promote' => NodeInterface::PROMOTED,
]);
$this->articleComment = $this
->saveComment($this->article
->id(), $this->webUser
->id(), NULL, 0);
$this->page = $this
->drupalCreateNode([
'type' => 'page',
]);
$image_file = $this->article
->get('field_image')->entity;
$this->imageUri = ImageStyle::load('wide')
->buildUrl($image_file
->getFileUri());
$this->termUri = $this->term
->toUrl('canonical', [
'absolute' => TRUE,
])
->toString();
$this->articleUri = $this->article
->toUrl('canonical', [
'absolute' => TRUE,
])
->toString();
$this->pageUri = $this->page
->toUrl('canonical', [
'absolute' => TRUE,
])
->toString();
$this->authorUri = $this->adminUser
->toUrl('canonical', [
'absolute' => TRUE,
])
->toString();
$this->articleCommentUri = $this->articleComment
->toUrl('canonical', [
'absolute' => TRUE,
])
->toString();
$this->commenterUri = $this->webUser
->toUrl('canonical', [
'absolute' => TRUE,
])
->toString();
$this
->drupalLogout();
}