function FieldAccessTest::setUp

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

Overrides FieldTestBase::setUp

File

drupal/core/modules/field/lib/Drupal/field/Tests/FieldAccessTest.php, line 30
Definition of Drupal\field\Tests\FieldAccessTest.

Class

FieldAccessTest
Tests the functionality of field access.

Namespace

Drupal\field\Tests

Code

function setUp() {
  parent::setUp();
  $web_user = $this
    ->drupalCreateUser(array(
    'view test_view_field content',
  ));
  $this
    ->drupalLogin($web_user);

  // Create content type.
  $this->content_type_info = $this
    ->drupalCreateContentType();
  $this->content_type = $this->content_type_info->type;
  $this->field = array(
    'field_name' => 'test_view_field',
    'type' => 'text',
  );
  field_create_field($this->field);
  $this->instance = array(
    'field_name' => $this->field['field_name'],
    'entity_type' => 'node',
    'bundle' => $this->content_type,
    'widget' => array(
      'type' => 'text_textfield',
    ),
    'display' => array(
      'default' => array(
        'type' => 'text_default',
      ),
    ),
  );
  field_create_instance($this->instance);

  // Create test node.
  $this->test_view_field_value = 'This is some text';
  $settings = array();
  $settings['type'] = $this->content_type;
  $settings['title'] = 'Field view access test';
  $settings['test_view_field'] = array(
    LANGUAGE_NOT_SPECIFIED => array(
      array(
        'value' => $this->test_view_field_value,
      ),
    ),
  );
  $this->node = $this
    ->drupalCreateNode($settings);
}