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\FunctionalCode
protected function setUp() : void {
parent::setUp();
$this->baseUri = Url::fromRoute('<front>', [], [
'absolute' => TRUE,
])
->toString();
// Create two test users.
$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);
// Create term.
$this->term = Term::create([
'name' => $this
->randomMachineName(),
'description' => $this
->randomMachineName(),
'vid' => 'tags',
]);
$this->term
->save();
// Create image.
\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();
// Create article.
$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);
// Create second article to test teaser list.
$this
->drupalCreateNode([
'type' => 'article',
'promote' => NodeInterface::PROMOTED,
]);
// Create article comment.
$this->articleComment = $this
->saveComment($this->article
->id(), $this->webUser
->id(), NULL, 0);
// Create page.
$this->page = $this
->drupalCreateNode([
'type' => 'page',
]);
// Set URIs.
// Image.
$image_file = $this->article
->get('field_image')->entity;
$this->imageUri = ImageStyle::load('wide')
->buildUrl($image_file
->getFileUri());
// Term.
$this->termUri = $this->term
->toUrl('canonical', [
'absolute' => TRUE,
])
->toString();
// Article.
$this->articleUri = $this->article
->toUrl('canonical', [
'absolute' => TRUE,
])
->toString();
// Page.
$this->pageUri = $this->page
->toUrl('canonical', [
'absolute' => TRUE,
])
->toString();
// Author.
$this->authorUri = $this->adminUser
->toUrl('canonical', [
'absolute' => TRUE,
])
->toString();
// Comment.
$this->articleCommentUri = $this->articleComment
->toUrl('canonical', [
'absolute' => TRUE,
])
->toString();
// Commenter.
$this->commenterUri = $this->webUser
->toUrl('canonical', [
'absolute' => TRUE,
])
->toString();
$this
->drupalLogout();
}