Verified Commit 6d8c0395 authored by Dave Long's avatar Dave Long
Browse files

Issue #3473029 by dcam, annmarysruthy, igorgoncalves, smustgrave,...

Issue #3473029 by dcam, annmarysruthy, igorgoncalves, smustgrave, guillaumepacilly: Wrong maxlength on Authored By field for translation

(cherry picked from commit 970ce375)
parent 93d9fe46
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -487,7 +487,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En
        '#default_value' => User::load($uid),
        // Validation is done by static::entityFormValidate().
        '#validate_reference' => FALSE,
        '#maxlength' => 60,
        '#maxlength' => 1024,
        '#description' => $this->t('Leave blank for %anonymous.', ['%anonymous' => \Drupal::config('user.settings')->get('anonymous')]),
      ];

+13 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
use Drupal\Core\Url;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
use Drupal\user\UserInterface;

/**
 * Tests the Content Translation UI.
@@ -353,6 +354,18 @@ protected function doTestAuthoringInfo() {
    $metadata = $this->manager->getTranslationMetadata($entity->getTranslation($langcode));
    $this->assertEquals($values[$langcode]['uid'], $metadata->getAuthor()->id(), 'Translation author correctly kept.');
    $this->assertEquals($values[$langcode]['created'], $metadata->getCreatedTime(), 'Translation date correctly kept.');

    // Verify that long usernames can be saved as the translation author.
    $user = $this->drupalCreateUser([], $this->randomMachineName(UserInterface::USERNAME_MAX_LENGTH));
    $edit = [
      // Format the username as it is entered in autocomplete fields.
      'content_translation[uid]' => $user->getAccountName() . ' (' . $user->id() . ')',
      'content_translation[created]' => $this->container->get('date.formatter')->format($values[$langcode]['created'], 'custom', 'Y-m-d H:i:s O'),
    ];
    $this->submitForm($edit, $this->getFormSubmitAction($entity, $langcode));
    $reloaded_entity = $storage->load($this->entityId);
    $metadata = $this->manager->getTranslationMetadata($reloaded_entity->getTranslation($langcode));
    $this->assertEquals($user->id(), $metadata->getAuthor()->id(), 'Translation author correctly set.');
  }

  /**