function OptionsTestBase::mockStandardInstall

Same name in other branches
  1. 9 core/modules/options/tests/src/Kernel/Views/OptionsTestBase.php \Drupal\Tests\options\Kernel\Views\OptionsTestBase::mockStandardInstall()
  2. 10 core/modules/options/tests/src/Kernel/Views/OptionsTestBase.php \Drupal\Tests\options\Kernel\Views\OptionsTestBase::mockStandardInstall()
  3. 11.x core/modules/options/tests/src/Kernel/Views/OptionsTestBase.php \Drupal\Tests\options\Kernel\Views\OptionsTestBase::mockStandardInstall()

Provides a workaround for the inability to use the standard profile.

See also

https://www.drupal.org/node/1708692

1 call to OptionsTestBase::mockStandardInstall()
OptionsTestBase::setUp in core/modules/options/tests/src/Kernel/Views/OptionsTestBase.php

File

core/modules/options/tests/src/Kernel/Views/OptionsTestBase.php, line 77

Class

OptionsTestBase
Base class for options views tests.

Namespace

Drupal\Tests\options\Kernel\Views

Code

protected function mockStandardInstall() {
    $this->installEntitySchema('user');
    $this->installEntitySchema('node');
    NodeType::create([
        'type' => 'article',
    ])->save();
    $this->fieldValues = [
        $this->randomMachineName(),
        $this->randomMachineName(),
    ];
    $this->fieldNames = [
        'field_test_list_string',
        'field_test_list_integer',
    ];
    // Create two field entities.
    FieldStorageConfig::create([
        'field_name' => $this->fieldNames[0],
        'entity_type' => 'node',
        'type' => 'list_string',
        'cardinality' => 1,
        'settings' => [
            'allowed_values' => [
                $this->fieldValues[0] => $this->fieldValues[0],
                $this->fieldValues[1] => $this->fieldValues[1],
            ],
        ],
    ])
        ->save();
    FieldStorageConfig::create([
        'field_name' => $this->fieldNames[1],
        'entity_type' => 'node',
        'type' => 'list_integer',
        'cardinality' => 1,
        'settings' => [
            'allowed_values' => [
                $this->fieldValues[0],
                $this->fieldValues[1],
            ],
        ],
    ])
        ->save();
    foreach ($this->fieldNames as $field_name) {
        FieldConfig::create([
            'field_name' => $field_name,
            'entity_type' => 'node',
            'label' => 'Test options list field',
            'bundle' => 'article',
        ])->save();
    }
}

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