function ImageFieldAttributesTest::setUp

Same name in other branches
  1. 8.9.x 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 70

Class

ImageFieldAttributesTest
Tests the RDFa markup of imagefields.

Namespace

Drupal\Tests\rdf\Functional

Code

protected function setUp() : void {
    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();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.