Problem/Motivation

Most stuff of what \Drupal\Tests\system\Functional\Common\FormatDateTest is testing can actually be considered as kernel test.

Proposed resolution

* Keep some of the existing ui stuff in this file
* Move most of the test into a kernel test

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner created an issue. See original summary.

jhedstrom’s picture

Status: Active » Needs review
FileSize
9.56 KB

Came across this while reviewing datetime issues. Here's a quick conversion to kernel. I left the other test method in place since it covers the UI. Do we want to remove the calls to format_date and call the service directly as part of this?

mpdonadio’s picture

Status: Needs review » Needs work

The split of WTB vs KTB is good. I think this is essentially good to go, just some small nits since we have a new test class, we can update things.

  1. +++ b/core/tests/Drupal/KernelTests/Core/Datetime/FormatDateTest.php
    @@ -0,0 +1,90 @@
    +      '' => array('Sunday' => 'domingo'),
    +      'Long month name' => array('March' => 'marzo'),
    

    Short array syntax.

  2. +++ b/core/tests/Drupal/KernelTests/Core/Datetime/FormatDateTest.php
    @@ -0,0 +1,90 @@
    +  function testFormatDate() {
    

    PHPCS complained that this should be explicitly public.

  3. +++ b/core/tests/Drupal/KernelTests/Core/Datetime/FormatDateTest.php
    @@ -0,0 +1,90 @@
    +    $this->assertSame(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test all parameters.');
    

    Since this is a new file, I think it is a good idea to go ahead and replace the `format_date` calls with the $formatter from the container. Fewer places to update once we finally start to remove this (this will get rid of about 20% of the current usages).

jhedstrom’s picture

Status: Needs work » Needs review
FileSize
7.82 KB
9.76 KB

This should address #3. While I was at it, I also changed the order of the assertion arguments to be correct (expected, then actual).

mpdonadio’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me. I think this would qualify for 8.2 under https://www.drupal.org/core/d8-allowed-changes#patch per

Internal code cleanup that improves maintainability and is not disruptive may sometimes be backported to a patch release, but this is always at committer discretion.

but no big deal if others disagree.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 5c4a8df to 8.3.x and c30416f to 8.2.x. Thanks!

  • alexpott committed 5c4a8df on 8.3.x
    Issue #2795601 by jhedstrom, mpdonadio: Convert \Drupal\Tests\system\...

  • alexpott committed c30416f on 8.2.x
    Issue #2795601 by jhedstrom, mpdonadio: Convert \Drupal\Tests\system\...

Status: Fixed » Closed (fixed)

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