Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293221

datetime* Functional tests should use container, not \Drupal::service()

$
0
0

Problem/Motivation

While adding tests for #2845081: Provide a datetime_range widget to define end time via a duration offset I started from a copy of core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php.

@heddn pointed out:

+++ b/tests/src/Functional/DateRangeDurationWidgetTest.php
@@ -0,0 +1,327 @@
+    \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
...
+    \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
...
+    \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();

I think we want to use $this->container instead.

Proposed resolution

Convert both DateTimeFieldTest and DateRangeFieldTest to use the $this->container->get(), not \Drupal::service().

Remaining tasks

  1. Write patch
  2. Review
  3. Commit

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

N/A.


Viewing all articles
Browse latest Browse all 293221

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>