protected function HandlerFieldFieldTest::setUp

@todo.

Overrides FieldTestBase::setUp

File

drupal/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php, line 43
Contains \Drupal\field\Tests\Views\HandlerFieldFieldTest.

Class

HandlerFieldFieldTest
Tests the field_field handler. @TODO Check a entity-type with bundles Check a entity-type without bundles Check locale:disabled, locale:enabled and locale:enabled with another language Check revisions

Namespace

Drupal\field\Tests\Views

Code

protected function setUp() {
  parent::setUp();

  // Setup basic fields.
  $this
    ->setUpFields(3);

  // Setup a field with cardinality > 1.
  $this->fields[3] = $field = field_create_field(array(
    'field_name' => 'field_name_3',
    'type' => 'text',
    'cardinality' => FIELD_CARDINALITY_UNLIMITED,
  ));

  // Setup a field that will have no value.
  $this->fields[4] = $field = field_create_field(array(
    'field_name' => 'field_name_4',
    'type' => 'text',
    'cardinality' => FIELD_CARDINALITY_UNLIMITED,
  ));
  $this
    ->setUpInstances();

  // Create some nodes.
  $this->nodes = array();
  for ($i = 0; $i < 3; $i++) {
    $edit = array(
      'type' => 'page',
    );
    for ($key = 0; $key < 3; $key++) {
      $field = $this->fields[$key];
      $edit[$field['field_name']][0]['value'] = $this
        ->randomName(8);
    }
    for ($j = 0; $j < 5; $j++) {
      $edit[$this->fields[3]['field_name']][$j]['value'] = $this
        ->randomName(8);
    }

    // Set this field to be empty.
    $edit[$this->fields[4]['field_name']] = array(
      array(
        'value' => NULL,
      ),
    );
    $this->nodes[$i] = $this
      ->drupalCreateNode($edit);
  }
  $this->container
    ->get('views.views_data')
    ->clear();
}