FieldCardinalityTest.php in Mini site 8
File
tests/src/Functional/FieldCardinalityTest.php
View source
<?php
namespace Drupal\Tests\minisite\Functional;
use Drupal\Tests\field_ui\Traits\FieldUiTestTrait;
class FieldCardinalityTest extends MinisiteTestBase {
use FieldUiTestTrait;
protected static $modules = [
'block',
];
protected function setUp() {
parent::setUp();
$this
->drupalPlaceBlock('system_breadcrumb_block');
}
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.');
}
}