Closed (duplicate)
Project:
Drupal core
Version:
8.0.x-dev
Component:
documentation
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
15 Sep 2013 at 08:03 UTC
Updated:
29 Jul 2014 at 22:55 UTC
Updated: Comment #N
I noticed that a number of issues that converted to use services/change drupal_container() to Drupal:: where forced to use $this->container->get(). I don't understand the reason for this. We don't want to test tests, do we?
The DX of $this->container->get('config.factory')->get('something') instead of \Drupal::config('something') is crap, both for remembering how to call it and then not having method autocomplete.
Allow and recommend to use \Drupal:: in test methods. (No need to change already converted code, I care about DX when writing new code).
Discuss, fight!
Duh.
None.
Many, for example #2078155-21: Access protected field items being removed.
Comments
Comment #1
dawehner#2084637: Use a service container with automated wrappers would really help at least for the autocompletion.
I am fine with using \Drupal, and even don't really care about consistency ... is it safe that \Drupal::getContainer() and $this->container() is the same all the time?
Comment #2
berdirNo, right now they are not, we sometimes rebuild the container but don't update $this->container. That doesn't affect most code, but it does affect me in #1786490: Add caching to the state system, have to use \Drupal there.
Comment #3
alexpottThis is a duplicate of #2087751: [policy, no patch] Stop using $this->container in web tests
Comment #3.0
alexpottUpdated issue summary.