You are here

protected function ImageFieldAttributesTest::setUp in Zircon Profile 8

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

Sets up a Drupal site for running functional and integration tests.

Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.

Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Overrides ImageFieldTestBase::setUp

File

core/modules/rdf/src/Tests/ImageFieldAttributesTest.php, line 50
Contains \Drupal\rdf\Tests\ImageFieldAttributesTest.

Class

ImageFieldAttributesTest
Tests the RDFa markup of imagefields.

Namespace

Drupal\rdf\Tests

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, array(
    'properties' => array(
      'og:image',
    ),
    'mapping_type' => 'rel',
  ))
    ->setBundleMapping(array(
    'types' => array(),
  ))
    ->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);
}