Skip to content
Snippets Groups Projects
Verified Commit 0d414462 authored by Dave Long's avatar Dave Long
Browse files

Issue #3456417 by eugene bocharov, pablo_pukha, smustgrave, oily, andypost:...

Issue #3456417 by eugene bocharov, pablo_pukha, smustgrave, oily, andypost: [regression] DateHelper::dayOfWeekName() returns untranslated name

(cherry picked from commit 3aaf8f3b)
parent e061a933
No related branches found
No related tags found
1 merge request!10602Issue #3438769 by vinmayiswamy, antonnavi, michelle, amateescu: Sub workspace does not clear
Pipeline #370788 passed with warnings
Pipeline: drupal

#370840

    Pipeline: drupal

    #370837

      Pipeline: drupal

      #370828

        +6
        ......@@ -521,7 +521,7 @@ public static function dayOfWeek($date = NULL) {
        * (optional) Whether to return the abbreviated name for that day.
        * Defaults to TRUE.
        *
        * @return string|null
        * @return \Drupal\Core\StringTranslation\TranslatableMarkup|null
        * The name of the day in the week for that date, or null if the $date has
        * errors.
        */
        ......@@ -533,7 +533,7 @@ public static function dayOfWeekName($date = NULL, $abbr = TRUE) {
        if (!$date->hasErrors()) {
        $dow = self::dayOfWeek($date);
        $days = $abbr ? self::weekDaysAbbr() : self::weekDays();
        return $days[$dow]->getUntranslatedString();
        return $days[$dow];
        }
        return NULL;
        }
        ......
        ......@@ -7,6 +7,7 @@
        use Drupal\Core\Datetime\DateHelper;
        use Drupal\Core\DependencyInjection\ContainerBuilder;
        use Drupal\Core\Language\Language;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        use Drupal\Tests\UnitTestCase;
        /**
        ......@@ -31,6 +32,7 @@ protected function setUp(): void {
        $container = new ContainerBuilder();
        $config = ['system.date' => ['first_day' => 'Sunday']];
        $container->set('config.factory', $this->getConfigFactoryStub($config));
        $container->set('string_translation', $this->getStringTranslationStub());
        $this->languageManager = $this->createMock('\Drupal\Core\Language\LanguageManagerInterface');
        $language = new Language(['langcode' => 'en']);
        ......@@ -245,6 +247,9 @@ public function testDayOfWeekName(): void {
        $this->assertNotNull(DateHelper::dayOfWeekName(FALSE));
        $this->assertNotNull(DateHelper::dayOfWeekName(''));
        // Ensure proper return value type.
        $this->assertInstanceOf(TranslatableMarkup::class, DateHelper::dayOfWeekName());
        // Pass nothing and expect to get NULL.
        $this->assertNull(DateHelper::dayOfWeekName(0));
        $this->assertNull(DateHelper::dayOfWeekName('0'));
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Finish editing this message first!
        Please register or to comment