function FieldTestBase::setUpFieldStorages

Same name in other branches
  1. 9 core/modules/field/tests/src/Functional/Views/FieldTestBase.php \Drupal\Tests\field\Functional\Views\FieldTestBase::setUpFieldStorages()
  2. 8.9.x core/modules/field/src/Tests/Views/FieldTestBase.php \Drupal\field\Tests\Views\FieldTestBase::setUpFieldStorages()
  3. 8.9.x core/modules/field/tests/src/Functional/Views/FieldTestBase.php \Drupal\Tests\field\Functional\Views\FieldTestBase::setUpFieldStorages()
  4. 10 core/modules/field/tests/src/Functional/Views/FieldTestBase.php \Drupal\Tests\field\Functional\Views\FieldTestBase::setUpFieldStorages()
1 call to FieldTestBase::setUpFieldStorages()
FieldUITest::setUp in core/modules/field/tests/src/Functional/Views/FieldUITest.php
Sets up the test.

File

core/modules/field/tests/src/Functional/Views/FieldTestBase.php, line 56

Class

FieldTestBase
Provides some helper methods for testing fieldapi integration into views.

Namespace

Drupal\Tests\field\Functional\Views

Code

public function setUpFieldStorages($amount = 3, $type = 'string') {
    // Create three fields.
    $field_names = [];
    for ($i = 0; $i < $amount; $i++) {
        $field_names[$i] = 'field_name_' . $i;
        $this->fieldStorages[$i] = FieldStorageConfig::create([
            'field_name' => $field_names[$i],
            'entity_type' => 'node',
            'type' => $type,
        ]);
        $this->fieldStorages[$i]
            ->save();
    }
    return $field_names;
}

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