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

Remove unused code from KernelTestBase

$
0
0

https://www.drupal.org/node/2880911 was fixed a long time ago but the codebase still has a code related to that issue (but not used anymore)

As that code is not used anywhere (lines 344-353 of KernelTestBase) it can be safely removed.

KernelTestBase used to say this;

+    // Prepare a precompiled container for all tests of this class.
+    // Substantially improves performance, since ContainerBuilder::compile()
+    // is very expensive. Encourages testing best practices (small tests).
+    // Normally a setUpBeforeClass() operation, but object scope is required to
+    // inject $this test class instance as a service provider (see above).
+    $rc = new \ReflectionClass(get_class($this));
+    $test_method_count = count(array_filter($rc->getMethods(), function ($method) {
+      // PHPUnit's @test annotations are intentionally ignored/not supported.
+      return strpos($method->getName(), 'test') === 0;
+    }));
+    if ($test_method_count > 1 && !$this->isTestInIsolation()) {
+      // Clone a precompiled, empty ContainerBuilder instance for each test.
+      $container = $this->getCompiledContainerBuilder($modules);
+    }

But that last if statement is now gone, leaving only the declarations of $rc and $test_method_count.


Viewing all articles
Browse latest Browse all 294951

Trending Articles