As part of #3049638-10: Replace call to deprecated function format_date the dateFormatter object was added to SchedulerBrowserTestBase.

This means that in test files we can change all ocurrences of
\Drupal::service('date.formatter')->format
to
$this->dateFormatter->format

There are four test files that can have this change:
SchedulerBasicTest.php
SchedulerPastDatesTest.php
SchedulerTokenReplaceTest.php
SchedulerValidationTest.php

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jonathan1055 created an issue. See original summary.

kavbiswa’s picture

Assigned: Unassigned » kavbiswa

I am working on this issue. will update the patch file with the changes.

shreyal999’s picture

Hey, updated \Drupal::service('date.formatter')->format to $this->dateFormatter->format for all Functional Test's.

jonathan1055’s picture

@shreyal999 please be curteous and if someone assigns the issue to themselves then let them work on it, and do not post a patch before they have made theirs.
Thank you
Jonathan (Scheduler maintainer)

kavbiswa’s picture

Thanks @jonathan1055 .

I have made the changes and attached the patch. Please review.
Let me know if any further change is needed for this.

jonathan1055’s picture

Status: Needs review » Needs work

Thanks kavbiswa. Just two minor changes required:

1) in tests/src/Functional/SchedulerBasicTest.php

-    // values so that date.formatter can utilise the current users timezone. The
+    // values so that dateFormatter can utilise the current users timezone. The

can you add $this-> in front of dateFormatter

2) in tests/src/Functional/SchedulerTokenReplaceTest.php
instead of

-    $date_formatter = \Drupal::service('date.formatter');
+    $date_formatter = $this->dateFormatter;

just delete that line and use the new object directly in lines 59 and 60.

Thanks.

kavbiswa’s picture

Thanks @jonathan1055 for the inputs. I am working on the changes suggested.

kavbiswa’s picture

Assigned: Unassigned » kavbiswa
kavbiswa’s picture

Assigned: kavbiswa » Unassigned
Status: Needs work » Needs review
FileSize
6.98 KB

Thanks @jonathan1055 for review and inputs on it.
I have made the suggested changes and have attached a patch file . Let me know if any further changes needs to be made.

  • jonathan1055 committed 70a2fc4 on 8.x-1.x authored by kavbiswa
    Issue #3054372 by kavbiswa: Replace Drupal::service('date.formatter')...
jonathan1055’s picture

Status: Needs review » Fixed

Thanks kavbiswa, committed and creditted.
I made one small adjustment, to fix the new "line exceeds 80 chars" coding standard fault introduced with the longer comment.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jonathan1055’s picture