Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
simpletest.module
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
14 Feb 2014 at 12:50 UTC
Updated:
29 Jul 2014 at 23:22 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
alexpottLet's see if anything breaks.
Comment #3
jhodgdonDo you perhaps need to put the translation services into WebTestBase if you take them out of TestBase? It looks like the failing tests extend WebTestBase.
Comment #4
sunI'm spotting these causes:
WebTestBase, Drupal is not installed yet. We need to change those tests to actually resemble the minimal bootstrap container that is built ininstall_begin_request(), ideally even with the identical logic for discovering string translations. Before attempting that, it would be good to do #2175459: Convert Drupal\system\Tests\InstallerTest into a new Drupal\simpletest\InstallerTestBase first.Drupal\system\Tests\Plugin\*classes appear to be unit tests. I suspect they're using t() in assertion messages.Drupal\system\Tests\Common\SizeUnitTest.I would actually recommend to remove these entire lines, too:
Instead, the patch in #2171315: Ensure a NULL container in UnitTestCase::setUP will allow us to simply nuke the global state container:
Comment #5
alexpottActually
Drupal\system\Tests\Plugin\*andDrupal\system\Tests\Common\SizeUnitTesthave dependencies on the string_translation service. The former because of the @Translation annotation and the latter due toformat_plural()being used informat_size().Patch just creates the services in the tests as necessary.
Leaving the installer test alone till #2175459: Convert Drupal\system\Tests\InstallerTest into a new Drupal\simpletest\InstallerTestBase gets in.
Comment #6
sunI wonder whether these are appropriate unit tests in the first place?
If a test needs a service container, then it ought to be DUTB?
→ Let's simply change all of those into DUTB?
Closely related side-note: My ultimate goal for D8 is to remove
UnitTestBaseprior to 8.0. Unit tests should exclusively be PHPUnit tests only. That's going to leave us withDrupalUnitTestBase+WebTestBasefor the non-unit scenarios.(At that point, we could consider to rename
DrupalUnitTestBaseintoUnitTestBase, although I'm not sure whether that's a good idea. A name likeExtensionTestBaseorKernelTestBasewould probably be more accurate.)Comment #7
alexpottGood idea - interdiff is to patch in #1
Comment #10
sunLast patch was not the patch you intended to upload; that's why I canceled it ;)
Attached patch changes those tests to DUTB.
Also added a @todo for #2171315: Ensure a NULL container in UnitTestCase::setUP, even though I'd actually prefer to get that in first, so we can nuke
$this->containerentirely here.Did not touch the installer tests either, waiting for #2175459: Convert Drupal\system\Tests\InstallerTest into a new Drupal\simpletest\InstallerTestBase
Comment #13
dawehnerWell, we have unit-testable code in the background for format_plural() but not for format_size(), see #2157945: Deprecate format_size() and use Drupal\Core\StringTranslation\ByteSizeMarkup instead
PluginTestBase certainly can be tested using pure unit tests.
Let's do that all in follow ups.
Comment #14
sunComment #15
sunRe-rolled. Let's see what remains.
Comment #17
sunComment #19
sunComment #20
sunLet's quickly move forward here to prevent a new test to introduce a new dependency on the minimal mock container of
TestBase! :-)Comment #21
sun19: test.translation.19.patch queued for re-testing.
Comment #23
sunMerged HEAD.
Comment #24
sun23: test.translation.23.patch queued for re-testing.
Comment #25
sun23: test.translation.23.patch queued for re-testing.
Comment #26
sun23: test.translation.23.patch queued for re-testing.
Comment #28
sunMerged 8.x.
Comment #29
znerol commentedGreat! This is almost identical to #2275965: Remove all services from the TestBase container.
Can we remove that line entirely? This operates on the original container. I guess there is no way that this service is tampered with from within tests?
Can we use
KernelTestBaseinstead?Comment #30
sunComment #31
znerol commentedGreat. Running a couple of unit-tests and web-tests through the UI did not reveal any problems, this is ready for inclusion.
Comment #32
tstoecklerAs \Drupal::getContainer() is documented to return a ContainerInterface, I think this is slightly weird. Is there any value in NULL over new ContainerBuilder()?
Comment #34
znerol commentedComment #35
sunMerged 8.x.
@tstoeckler: Passing a NULL value is explicitly supported and desired in this case, because we do not want to build + set a new container, but instead, we explicitly want to reset the container in \Drupal to NULL.
Comment #37
sunPrevent var_export() in default assertion message from getting invoked in DiscoveryTestBase.
It looks like the plugin discovery tests did not run against the actual plugin_test.module plugins in HEAD. Otherwise, the
var_export()PHP warning would appear in HEAD already.With that, we should be back to RTBC.
Comment #40
sunMerged 8.x. Back to RTBC.
Comment #42
sunMerged 8.x.
Comment #43
catchCommitted/pushed to 8.x, thanks!