Update outdated class references from Drupal\*\Tests to Drupal\Tests\*

Created on 30 January 2023, almost 2 years ago
Updated 11 February 2023, almost 2 years ago

Problem/Motivation

The codebase contains references to the outdated namespace Drupal\*\Tests. These should be updated to Drupal\Tests\*

Steps to reproduce

See for example core/modules/node/tests/modules/node_access_test/node_access_test.module:

- * @see \Drupal\node\Tests\NodeQueryAlterTest
- * @see \Drupal\node\Tests\NodeAccessBaseTableTest

Proposed resolution

Update outdated class references from Drupal\*\Tests to Drupal\Tests\*

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

None.

πŸ“Œ Task
Status

Needs work

Version

10.1 ✨

Component
OtherΒ  β†’

Last updated about 3 hours ago

Created by

πŸ‡³πŸ‡±Netherlands idebr

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @idebr
  • πŸ‡³πŸ‡±Netherlands Lendude Amsterdam

    Proposed automation:
    In PHPStorm do a replace in file
    Find with regex: \\Drupal\\(\w+)\\Tests\\
    Replace with : \\Drupal\\Tests\\$1

  • Status changed to Needs review almost 2 years ago
  • πŸ‡³πŸ‡±Netherlands Lendude Amsterdam

    Lets see if this breaks anything

    Tagging for the PHPUnit initiative since we should have changed it then ;)

  • πŸ‡³πŸ‡±Netherlands Lendude Amsterdam

    Lets try that again with the trailing slashes added

  • Status changed to Needs work almost 2 years ago
  • πŸ‡³πŸ‡±Netherlands idebr

    The automated replacement is missing the added namespace for `Functional` / `Unit` etc, so it's unlikely this can be automated.

  • πŸ‡³πŸ‡±Netherlands Lendude Amsterdam

    Yeah good point, it does provide a handy list of what needs to be checked I guess.

  • Status changed to Needs review almost 2 years ago
  • πŸ‡³πŸ‡±Netherlands Lendude Amsterdam

    Manually went through them and added what needed to be added. Reverted a couple that still use the old namespaces (in Views mostly), remoed some things that no longer seem to exist

  • Status changed to Needs work almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Ran this locally and found these instances. Could you confirm if they are no relevant to this

    Targets
        Occurrences of '\\Drupal\\.*\\Tests\\' in Directory /Users/smustgrave/Sites/Drupal-Demos/drupal-10.x/web/core
    Found Occurrences in Directory /Users/smustgrave/Sites/Drupal-Demos/drupal-10.x/web/core  (23 usages found)
        Unclassified  (3 usages found)
            drupal-10.x  (3 usages found)
                web/core  (3 usages found)
                    phpstan-baseline.neon  (3 usages found)
                        3159 e 'ClassWithConstants\\.SOME_KEY' \\(\\\\Drupal\\\\Tests\\\\Component\\\\Annotation\\\\Doctrine\\\\Fixtures\\\\ClassWithConstants\\:\\:SOME_KEY, \\\\Drupal\\\\Tests\\\\Component\\\\Annotation\\\\Doctrine\\\\Fixtures\\\\ClassWithConstants\\:\\:SOME_KEY\\)\\.$#"
                        3264 			message: "#^\\#lazy_builder callback '\\\\\\\\Drupal\\\\\\\\Tests\\\\\\\\Core…' at key '0' is not trusted\\.$#"
                        3274 			message: "#^\\#pre_render callback '\\\\\\\\Drupal\\\\\\\\Tests\\\\\\\\Core…' at key '0' is not trusted\\.$#"
        Usage in comments  (9 usages found)
            drupal-10.x  (9 usages found)
                web/core/modules/views/tests/modules/views_entity_test  (1 usage found)
                    views_entity_test.module  (1 usage found)
                        58 // \Drupal\views\Tests\ViewResultAssertionTrait::assertIdenticalResultsetHelper()
                web/core/modules/views/tests/src/Functional/Handler  (2 usages found)
                    AreaTitleWebTest.php  (2 usages found)
                        57 // \Drupal\views\Tests\ViewTestData::dataSet().
                        76 // \Drupal\views\Tests\ViewTestData::dataSet().
                web/core/modules/views/tests/src/Unit  (1 usage found)
                    PluginBaseTest.php  (1 usage found)
                        17 * @var \Drupal\views\Tests\TestHelperPlugin
                web/core/modules/views/tests/src/Unit/EventSubscriber  (1 usage found)
                    RouteSubscriberTest.php  (1 usage found)
                        40 * @var \Drupal\views\EventSubscriber\RouteSubscriber|\Drupal\Tests\views\Unit\EventSubscriber\TestRouteSubscriber
                web/core/tests/Drupal/KernelTests/Core/Plugin/Condition  (1 usage found)
                    RequestPathTest.php  (1 usage found)
                        29 * @var \Drupal\system\Tests\Routing\MockAliasManager
                web/core/tests/Drupal/Tests/Core/Asset  (1 usage found)
                    LibraryDiscoveryParserTest.php  (1 usage found)
                        30 * @var \Drupal\Core\Asset\LibraryDiscoveryParser|\Drupal\Tests\Core\Asset\TestLibraryDiscoveryParser
                web/core/tests/Drupal/Tests/Core/EventSubscriber  (1 usage found)
                    CustomPageExceptionHtmlSubscriberTest.php  (1 usage found)
                        57 * @var \Drupal\Core\EventSubscriber\CustomPageExceptionHtmlSubscriber|\Drupal\Tests\Core\EventSubscriber\CustomPageExceptionHtmlSubscriberTest
                web/core/tests/Drupal/Tests/Core/Extension  (1 usage found)
                    ThemeHandlerTest.php  (1 usage found)
                        39 * @var \Drupal\Core\Extension\ThemeHandler|\Drupal\Tests\Core\Extension\StubThemeHandler
        Usage in string constants  (11 usages found)
            drupal-10.x  (11 usages found)
                web/core/modules/rest/tests/src/Kernel/EntityResource  (1 usage found)
                    EntityResourceRestTestCoverageTest.php  (1 usage found)
                        96 $class_alternative = str_replace("\\Drupal\\Tests\\$module_name\\Functional", '\Drupal\FunctionalTests', $class);
                web/core/tests/Drupal/Tests/Component/Assertion  (2 usages found)
                    InspectorTest.php  (2 usages found)
                        235 $this->assertTrue(Inspector::assertAllObjects([new \ArrayObject(), new StringObject()], '\\Traversable', '\\Drupal\\Tests\\Component\\Assertion\\StringObject'));
                        236 $this->assertFalse(Inspector::assertAllObjects([new \ArrayObject(), new StringObject(), new \stdClass()], '\\ArrayObject', '\\Drupal\\Tests\\Component\\Assertion\\StringObject'));
                web/core/tests/Drupal/Tests/Component/ProxyBuilder  (1 usage found)
                    ProxyBuilderTest.php  (1 usage found)
                        302 public function typehintSelf(?\Drupal\Tests\Component\ProxyBuilder\TestServiceNullableTypehintSelf $parameter): ?\Drupal\Tests\Component\ProxyBuilder\TestServiceNullableTypehintSelf
                web/core/tests/Drupal/Tests/Core/Render  (5 usages found)
                    RendererCallbackTest.php  (5 usages found)
                        46 t be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was \Drupal\Tests\Core\Render\callback. See https://www.drupal.org/node/2966725',
                        50 t be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was \Drupal\Tests\Core\Render\RendererCallbackTest::renderCallback. See https://www.drupal.org/node/2966725',
                        54 t be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was Drupal\Tests\Core\Render\RendererCallbackTest::renderCallback. See https://www.drupal.org/node/2966725',
                        58 t be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was \Drupal\Tests\Core\Render\callback. See https://www.drupal.org/node/2966725',
                        62 t be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was Drupal\Tests\Core\Render\RendererCallbackTest. See https://www.drupal.org/node/2966725',
                web/core/tests/Drupal/Tests/Core/Test  (2 usages found)
                    TestDiscoveryTest.php  (2 usages found)
                        450 $data['simpletest-webtest'] = ['\Drupal\rest\Tests\NodeTest', FALSE];
                        461 $data['core-buildtest'] = ['\Drupal\BuildTests\Framework\Tests\BuildTestTest', 'Build'];
    
    
Production build 0.71.5 2024