You are here

public function FieldCardinalityTest::testCardinality in Mini site 8

Tests that only cardinality 1 is allowed.

File

tests/src/Functional/FieldCardinalityTest.php, line 33

Class

FieldCardinalityTest
Tests the minisite field cardinality.

Namespace

Drupal\Tests\minisite\Functional

Code

public function testCardinality() {
  $type_name = $this->contentType;
  $field_name = 'ms_fn_' . strtolower($this
    ->randomMachineName(4));
  $field_label = 'ms_fl_' . strtolower($this
    ->randomMachineName(4));
  $initial_edit = [
    'new_storage_type' => 'minisite',
    'label' => $field_label,
    'field_name' => $field_name,
  ];
  $this
    ->drupalPostForm("admin/structure/types/manage/{$type_name}/fields/add-field", $initial_edit, $this
    ->t('Save and continue'));
  $this
    ->assertRaw($this
    ->t('These settings apply to the %label field everywhere it is used.', [
    '%label' => $field_label,
  ]), 'Storage settings page was displayed.');
  $this
    ->assertRaw($this
    ->t('This field cardinality is set to 1 and cannot be configured.'), 'Cardinality is restricted to 1.');
}