Problem/Motivation

\Drupal\Tests\system\Functional\Datetime\DrupalDateTimeTest::testTimezoneFormat doesn't make any HTTP requests.

Proposed resolution

Move \Drupal\Tests\system\Functional\Datetime\DrupalDateTimeTest::testTimezoneFormat to an existing date kernel test or create a new one.
While you're there, remove the unnecessary ::setup method
Consider moving testSystemTimezone too, which as per #2 could be tested via routing a Request via the Kernel.

Remaining tasks

See above

User interface changes

None

API changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mile23’s picture

Category: Task » Bug report
Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs reroll

Needs a reroll.

$ git apply extend-kernek-test-base-instead-of-web-test-base-in-drupal-date-time-test-1.patch 
error: patch failed: core/modules/system/src/Tests/Datetime/DrupalDateTimeTest.php:2
error: core/modules/system/src/Tests/Datetime/DrupalDateTimeTest.php: patch does not apply
rpayanm’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
3.63 KB

Status: Needs review » Needs work

The last submitted patch, 2: 2349453-2.patch, failed testing.

Mile23’s picture

+++ b/core/modules/system/src/Tests/Datetime/DrupalDateTimeTest.php
@@ -8,27 +8,48 @@
   protected function setUp() {
     parent::setUp();
 
+    $this->installSchema('system', array('sequences', 'router'));
+    $this->installEntitySchema('user');
+
+    $this->account = User::create([
+      'name' => $this->randomMachineName(),
+      'status' => 1,
+    ]);
+    $this->account->save();
+    $this->container->get('current_user')->setAccount($this->account);

Since the goal is to speed up the test, and since only testDateTimezone() uses $this->account or the current_user service, we should make a helper method for it, or inline it in the test method. The point being: We don't need to create user objects for all the tests so take it out of setUp().

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mile23’s picture

Version: 8.6.x-dev » 8.8.x-dev

Everything has moved around. :-)

Drupal\Tests\system\Functional\Datetime\DrupalDateTimeTest::testTimezoneFormat() could still be moved to Drupal\Tests\Core\Datetime\DrupalDateTimeTest.

Manuel Garcia’s picture

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Mile23’s picture

Status: Needs work » Closed (outdated)

Drupal\Tests\system\Functional\Datetime\DrupalDateTimeTest currently says this in setup:

  /**
   * Test setup.
   */
  protected function setUp(): void {
    parent::setUp();

  }

So that's a bug in that it's an unnecessary function, which is different from the scope here. But it certainly solves this issue. :-)

There's also a unit test for Drupal\Core\Datetime\DrupalDateTime which fills me with a warm glow.

larowlan credited mstrelan.

larowlan’s picture

Title: Extend KernelTestBase instead of WebTestBase in DrupalDateTimeTest » Move \Drupal\Tests\system\Functional\Datetime\DrupalDateTimeTest::testTimezoneFormat into a Kernel test
Category: Bug report » Task
Issue summary: View changes
Status: Closed (outdated) » Needs work
Issue tags: +Bug Smash Initiative

Crediting @mstrelan and @Mile23 for their time triaging this in #bugsmash

larowlan’s picture

Issue summary: View changes

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.