You are here

protected function MetatagFieldTestBase::addField in Metatag 8

Add a Metatag field to this entity type.

6 calls to MetatagFieldTestBase::addField()
MetatagFieldTestBase::testEntityDefaultsInheritance in tests/src/Functional/MetatagFieldTestBase.php
Confirm that the entity default values work correctly.
MetatagFieldTestBase::testEntityFieldsAvailable in tests/src/Functional/MetatagFieldTestBase.php
Confirm a field can be added to the entity bundle.
MetatagFieldTestBase::testEntityFieldValuesNewEntity in tests/src/Functional/MetatagFieldTestBase.php
Confirm that the default values load correctly.
MetatagFieldTestBase::testEntityFieldValuesOldEntity in tests/src/Functional/MetatagFieldTestBase.php
Confirm that the default values load correctly for an entity created.
MetatagFieldTestBase::testGlobalDefaultsInheritance in tests/src/Functional/MetatagFieldTestBase.php
Confirm that the global default values work correctly.

... See full list

File

tests/src/Functional/MetatagFieldTestBase.php, line 186

Class

MetatagFieldTestBase
Base class for ensuring that the Metatag field works correctly.

Namespace

Drupal\Tests\metatag\Functional

Code

protected function addField() {

  // Add a metatag field to the entity type test_entity.
  $this
    ->drupalGet($this->entityFieldAdminPath . '/add-field');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $edit = [
    'label' => 'Metatag',
    'field_name' => 'metatag',
    'new_storage_type' => 'metatag',
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->t('Save and continue'));
  $this
    ->drupalPostForm(NULL, [], $this
    ->t('Save field settings'));

  // Clear all settings.
  $this->container
    ->get('entity_field.manager')
    ->clearCachedFieldDefinitions();
}