Verified Commit 4d6e2348 authored by godotislate's avatar godotislate
Browse files

test: #3575234 Add return types to FieldUiTestTrait

By: longwave
By: mstrelan
parent 4ba0eff8
Loading
Loading
Loading
Loading
Loading
+11 −821

File changed.

Preview size limit exceeded, changes collapsed.

+6 −6
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ trait FieldUiTestTrait {
   *   (optional) Parameter for conditional execution of second and third step
   *   (Saving the storage settings and field settings). Defaults to 'TRUE'.
   */
  public function fieldUIAddNewField($bundle_path, $field_name, $label = NULL, $field_type = 'test_field', array $storage_edit = [], array $field_edit = [], bool $save_settings = TRUE) {
  public function fieldUIAddNewField($bundle_path, $field_name, $label = NULL, $field_type = 'test_field', array $storage_edit = [], array $field_edit = [], bool $save_settings = TRUE): void {
    // Generate a label containing only letters and numbers to prevent random
    // test failure.
    // See https://www.drupal.org/project/drupal/issues/3030902
@@ -118,7 +118,7 @@ public function fieldUIAddNewField($bundle_path, $field_name, $label = NULL, $fi
   *   (optional) $edit parameter for submitForm() on the second step
   *   ('Field settings' form).
   */
  public function fieldUIAddExistingField($bundle_path, $existing_storage_name, $label = NULL, array $field_edit = []) {
  public function fieldUIAddExistingField($bundle_path, $existing_storage_name, $label = NULL, array $field_edit = []): void {
    $label = $label ?: $this->randomMachineName();
    $field_edit['edit-label'] = $label;

@@ -158,7 +158,7 @@ public function fieldUIAddExistingField($bundle_path, $existing_storage_name, $l
   * @param string $source_label
   *   (optional) The label of the source entity type bundle.
   */
  public function fieldUIDeleteField($bundle_path, $field_name, $label, $bundle_label, string $source_label = '') {
  public function fieldUIDeleteField($bundle_path, $field_name, $label, $bundle_label, string $source_label = ''): void {
    // Display confirmation form.
    $this->drupalGet("$bundle_path/fields/$field_name/delete");
    $this->assertSession()->pageTextContains("Are you sure you want to delete the field $label");
@@ -183,7 +183,7 @@ public function fieldUIDeleteField($bundle_path, $field_name, $label, $bundle_la
   * @return string|null
   *   Group name
   */
  public function getFieldFromGroup($field_type) {
  public function getFieldFromGroup($field_type): ?string {
    /** @var \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_plugin_manager */
    $field_type_plugin_manager = \Drupal::service('plugin.manager.field.field_type');
    $grouped_field_types = $field_type_plugin_manager->getGroupedDefinitions($field_type_plugin_manager->getUiDefinitions());
@@ -203,7 +203,7 @@ public function getFieldFromGroup($field_type) {
   *
   * @throws \Behat\Mink\Exception\ElementNotFoundException
   */
  protected function assertFieldExistsOnOverview(string $label) {
  protected function assertFieldExistsOnOverview(string $label): void {
    $field_labels = array_map(
      fn ($element): string => html_entity_decode($element->getHtml()),
      $this->getSession()->getPage()->findAll('css', 'table#field-overview tr td:first-child .field-label-text'),
@@ -217,7 +217,7 @@ protected function assertFieldExistsOnOverview(string $label) {
   * @param string $label
   *   The field label.
   */
  protected function assertFieldDoesNotExistOnOverview(string $label) {
  protected function assertFieldDoesNotExistOnOverview(string $label): void {
    $xpath = $this->assertSession()
      ->buildXPathQuery("//table[@id=\"field-overview\"]//tr/td[1 and text() = :label]", [
        ':label' => $label,