This commit is contained in:
2020-07-13 17:09:59 +02:00
parent 03559a7b76
commit 3a082e23cc
492 changed files with 4129 additions and 982 deletions
+2 -2
View File
@@ -17,8 +17,8 @@
*
* In the Field API, each field has a type, which determines what kind of data
* (integer, string, date, etc.) the field can hold, which settings it provides,
* and so on. The data type(s) accepted by a field are defined in
* hook_field_schema().
* and so on. The data type(s) accepted by a field are defined in the class
* implementing \Drupal\Core\Field\FieldItemInterface::schema() method.
*
* Field types are plugins annotated with class
* \Drupal\Core\Field\Annotation\FieldType, and implement plugin interface
@@ -175,12 +175,14 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
* The custom storage indexes for the field data storage.
*
* This set of indexes is merged with the "default" indexes specified by the
* field type in hook_field_schema() to determine the actual set of indexes
* that get created.
* field type in the class implementing
* \Drupal\Core\Field\FieldItemInterface::schema() method to determine the
* actual set of indexes that get created.
*
* The indexes are defined using the same definition format as Schema API
* index specifications. Only columns that are part of the field schema, as
* defined by the field type in hook_field_schema(), are allowed.
* defined by the field type in the class implementing
* \Drupal\Core\Field\FieldItemInterface::schema() method, are allowed.
*
* Some storage backends might not support indexes, and discard that
* information.
@@ -24,6 +24,7 @@ abstract class FieldTestBase extends WebTestBase {
*
* @param $cardinality
* Number of values to generate.
*
* @return
* An array of random values, in the format expected for field values.
*/
@@ -58,6 +58,7 @@ require_once __DIR__ . '/field_test.field.inc';
* The key under which to store to $value, or NULL as described above.
* @param $value
* A value to store for $key.
*
* @return
* An array mapping each $key to an array of each $value passed in
* for that key.
@@ -50,7 +50,14 @@ class BooleanFormatterSettingsTest extends BrowserTestBase {
$type = $this->drupalCreateContentType(['name' => $type_name, 'type' => $type_name]);
$this->bundle = $type->id();
$admin_user = $this->drupalCreateUser(['access content', 'administer content types', 'administer node fields', 'administer node display', 'bypass node access', 'administer nodes']);
$admin_user = $this->drupalCreateUser([
'access content',
'administer content types',
'administer node fields',
'administer node display',
'bypass node access',
'administer nodes',
]);
$this->drupalLogin($admin_user);
$this->fieldName = mb_strtolower($this->randomMachineName(8));
@@ -192,7 +192,7 @@ class EntityReferenceAdminTest extends BrowserTestBase {
'field_test_entity_ref_field[0][target_id]' => $node1->getTitle() . ' (' . $node1->id() . ')',
];
$this->drupalPostForm('node/add/' . $this->type, $edit, t('Save'));
$this->assertLink($node1->getTitle());
$this->assertSession()->linkExists($node1->getTitle());
// Tests adding default values to autocomplete widgets.
Vocabulary::create(['vid' => 'tags', 'name' => 'tags'])->save();
@@ -92,7 +92,10 @@ class EntityReferenceAutoCreateTest extends BrowserTestBase {
])
->save();
$account = $this->drupalCreateUser(['access content', "create $this->referencingType content"]);
$account = $this->drupalCreateUser([
'access content',
"create $this->referencingType content",
]);
$this->drupalLogin($account);
}
@@ -44,7 +44,13 @@ class EntityReferenceFieldDefaultValueTest extends BrowserTestBase {
$this->drupalCreateContentType(['type' => 'referenced_content']);
// Create admin user.
$this->adminUser = $this->drupalCreateUser(['access content', 'administer content types', 'administer node fields', 'administer node form display', 'bypass node access']);
$this->adminUser = $this->drupalCreateUser([
'access content',
'administer content types',
'administer node fields',
'administer node form display',
'bypass node access',
]);
$this->drupalLogin($this->adminUser);
}
@@ -147,7 +147,9 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends BrowserTestBase {
$this->setUpEntityReferenceField();
$this->createContent();
$this->webUser = $this->drupalCreateUser(['edit any ' . $this->referrerType->id() . ' content']);
$this->webUser = $this->drupalCreateUser([
'edit any ' . $this->referrerType->id() . ' content',
]);
}
/**
@@ -121,7 +121,10 @@ class EntityReferenceFileUploadTest extends BrowserTestBase {
* Tests that the autocomplete input element does not cause ajax fatal.
*/
public function testFileUpload() {
$user1 = $this->drupalCreateUser(['access content', "create $this->referencingType content"]);
$user1 = $this->drupalCreateUser([
'access content',
"create $this->referencingType content",
]);
$this->drupalLogin($user1);
$test_file = current($this->getTestFiles('text'));
@@ -59,7 +59,11 @@ class EntityReferenceIntegrationTest extends BrowserTestBase {
parent::setUp();
// Create a test user.
$web_user = $this->drupalCreateUser(['administer entity_test content', 'administer entity_test fields', 'view test entity']);
$web_user = $this->drupalCreateUser([
'administer entity_test content',
'administer entity_test fields',
'view test entity',
]);
$this->drupalLogin($web_user);
}
@@ -35,7 +35,10 @@ class FieldHelpTest extends BrowserTestBase {
parent::setUp();
// Create the admin user.
$this->adminUser = $this->drupalCreateUser(['access administration pages', 'view the administration theme']);
$this->adminUser = $this->drupalCreateUser([
'access administration pages',
'view the administration theme',
]);
}
/**
@@ -55,10 +58,10 @@ class FieldHelpTest extends BrowserTestBase {
\Drupal::service('plugin.manager.field.field_type')->clearCachedDefinitions();
$this->drupalGet('admin/help/field');
$this->assertLink('Options', 0, 'Options module is listed on the Field help page.');
$this->assertSession()->linkExists('Options', 0, 'Options module is listed on the Field help page.');
$this->assertText('Field API Test', 'Modules with field types that do not implement hook_help are listed.');
$this->assertNoLink('Field API Test', 'Modules with field types that do not implement hook_help are not linked.');
$this->assertNoLink('Link', 'Modules that have not been installed, are not listed.');
$this->assertSession()->linkNotExists('Field API Test', 'Modules with field types that do not implement hook_help are not linked.');
$this->assertSession()->linkNotExists('Link', 'Modules that have not been installed, are not listed.');
}
}
@@ -17,6 +17,7 @@ abstract class FieldTestBase extends BrowserTestBase {
*
* @param $cardinality
* Number of values to generate.
*
* @return
* An array of random values, in the format expected for field values.
*/
@@ -69,7 +69,10 @@ class FormTest extends FieldTestBase {
protected function setUp() {
parent::setUp();
$web_user = $this->drupalCreateUser(['view test entity', 'administer entity_test content']);
$web_user = $this->drupalCreateUser([
'view test entity',
'administer entity_test content',
]);
$this->drupalLogin($web_user);
$this->fieldStorageSingle = [
@@ -28,7 +28,10 @@ class NestedFormTest extends FieldTestBase {
protected function setUp() {
parent::setUp();
$web_user = $this->drupalCreateUser(['view test entity', 'administer entity_test content']);
$web_user = $this->drupalCreateUser([
'view test entity',
'administer entity_test content',
]);
$this->drupalLogin($web_user);
$this->fieldStorageSingle = [
@@ -96,7 +96,10 @@ class ReEnableModuleFieldTest extends BrowserTestBase {
// Test that the module can't be uninstalled from the UI while there is data
// for its fields.
$admin_user = $this->drupalCreateUser(['access administration pages', 'administer modules']);
$admin_user = $this->drupalCreateUser([
'access administration pages',
'administer modules',
]);
$this->drupalLogin($admin_user);
$this->drupalGet('admin/modules/uninstall');
$this->assertText("The Telephone number field type is used in the following field: node.field_telephone");
@@ -37,7 +37,11 @@ class StringFieldTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
$this->webUser = $this->drupalCreateUser(['view test entity', 'administer entity_test content', 'access content']);
$this->webUser = $this->drupalCreateUser([
'view test entity',
'administer entity_test content',
'access content',
]);
$this->drupalLogin($this->webUser);
}
@@ -92,7 +92,10 @@ class TranslationWebTest extends FieldTestBase {
* Tests field translations when creating a new revision.
*/
public function testFieldFormTranslationRevisions() {
$web_user = $this->drupalCreateUser(['view test entity', 'administer entity_test content']);
$web_user = $this->drupalCreateUser([
'view test entity',
'administer entity_test content',
]);
$this->drupalLogin($web_user);
// Prepare the field translations.
@@ -163,6 +163,7 @@ abstract class FieldKernelTestBase extends KernelTestBase {
*
* @param $cardinality
* Number of values to generate.
*
* @return
* An array of random values, in the format expected for field values.
*/