Windows Unit Test Root Directory Separator

Created on 25 September 2017, about 7 years ago
Updated 6 April 2024, 9 months ago

Problem

Drupal\Tests\Core\Extension\ModuleHandlerTest::testLoadInclude won't pass unit test on Windows due to Directory Separator issue.

======Output of Unit Test======

Drupal\Tests\Core\Extension\ModuleHandlerTest::testLoadInclude
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'C:\xampp\htdocs\drupal-8.4.x\core\tests\Drupal\Tests\Core\Extension/modules/module_handler_test/hook_include.inc'
+'C:\xampp\htdocs\drupal-8.4.x/core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/hook_include.inc'

========================

Proposed resolution

Instead of checking against:
__DIR__ . '/modules/module_handler_test/hook_include.inc'

Check against:
dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)))) . '/core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/hook_include.inc'
This check is more compatible with Windows environment.

🐛 Bug report
Status

Closed: won't fix

Version

11.0 🔥

Component
PHPUnit 

Last updated about 21 hours ago

Created by

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇿New Zealand quietone

    In #15 alexpott explained that Drupal needs to have testing in Windows environment to be able to commit this change. That hasn't happened in the last 5 years and there are not plans to add such a test environment. Therefor I think this is a won't fix.

    If you disagree, re-open this issue and add a comment.

Production build 0.71.5 2024