You are here

protected function ImageFieldAttributesTest::setUp in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/rdf/tests/src/Functional/ImageFieldAttributesTest.php \Drupal\Tests\rdf\Functional\ImageFieldAttributesTest::setUp()

Overrides ImageFieldTestBase::setUp

File

core/modules/rdf/tests/src/Functional/ImageFieldAttributesTest.php, line 66

Class

ImageFieldAttributesTest
Tests the RDFa markup of imagefields.

Namespace

Drupal\Tests\rdf\Functional

Code

protected function setUp() {
  parent::setUp();
  $this->fieldName = 'field_image';

  // Create the image field.
  $this
    ->createImageField($this->fieldName, 'article');

  // Set the RDF mapping for the new field.
  rdf_get_mapping('node', 'article')
    ->setFieldMapping($this->fieldName, [
    'properties' => [
      'og:image',
    ],
    'mapping_type' => 'rel',
  ])
    ->setBundleMapping([
    'types' => [],
  ])
    ->save();

  // Get the test image that simpletest provides.
  $image = current($this
    ->drupalGetTestFiles('image'));

  // Save a node with the image.
  $nid = $this
    ->uploadNodeImage($image, $this->fieldName, 'article', $this
    ->randomMachineName());
  $this->node = Node::load($nid);
  $this->file = File::load($this->node->{$this->fieldName}->target_id);

  // Prepares commonly used URIs.
  $this->baseUri = Url::fromRoute('<front>', [], [
    'absolute' => TRUE,
  ])
    ->toString();
}