You are here

protected function EntityReferenceRdfaTest::setUp in Zircon Profile 8

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

Set the default field storage backend for fields created during tests.

Overrides FieldRdfaTestBase::setUp

File

core/modules/rdf/src/Tests/Field/EntityReferenceRdfaTest.php, line 53
Contains \Drupal\rdf\Tests\Field\EntityReferenceRdfaTest.

Class

EntityReferenceRdfaTest
Tests the RDFa output of the entity reference field formatter.

Namespace

Drupal\rdf\Tests\Field

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('entity_test_rev');

  // Give anonymous users permission to view test entities.
  $this
    ->installConfig(array(
    'user',
  ));
  Role::load(RoleInterface::ANONYMOUS_ID)
    ->grantPermission('view test entity')
    ->save();
  $this
    ->createEntityReferenceField($this->entityType, $this->bundle, $this->fieldName, 'Field test', $this->entityType);

  // Add the mapping.
  $mapping = rdf_get_mapping('entity_test', 'entity_test');
  $mapping
    ->setFieldMapping($this->fieldName, array(
    'properties' => array(
      'schema:knows',
    ),
  ))
    ->save();

  // Create the entity to be referenced.
  $this->targetEntity = entity_create($this->entityType, array(
    'name' => $this
      ->randomMachineName(),
  ));
  $this->targetEntity
    ->save();

  // Create the entity that will have the entity reference field.
  $this->entity = entity_create($this->entityType, array(
    'name' => $this
      ->randomMachineName(),
  ));
  $this->entity
    ->save();
  $this->entity->{$this->fieldName}->entity = $this->targetEntity;
  $this->uri = $this
    ->getAbsoluteUri($this->entity);
}