Directories marked as test source root getting unmarked

已回答

Hi,

 

I'm working with a project that use composer and when I restart PhpStorm, the directories that I marked as a test source root get unmarked. How may I tell PhpStorm to stop unmarking my directories ?

 

Thanks for your help!

1

Hi there,

Are they marked as such in composer.json?

Right now it sounds like IDE is syncing these settings (PHP Language Level + Source/Test roots) with composer.json (which happens on project opening) which overrides manually configured ones.

Either disable such syncing .. or define them in composer.json.

2
Avatar
Permanently deleted user

Hi Andriy,

I added the autoload-dev in my composer and it did marked the proper directories.

Thanks for your help!

0

I have the same problem. Directories don't persist the settings. I constantly need to unmark them as test directories, because I don't have tests in one directory only, but organized in modules. It's annoying, wastes my time and searching doesn't work properly because of it.

0

Hello Jorg Sowa,

Please try PhpStorm 2025.1 EAP build. It should work there.

0

@Anastasiia Zyrianova This is still happening to me in 2025.2.5. We have tests in a `./tests` directory as well as several modules in `./modules/{ModuleName}/test`, yet PHPStorm keeps marking the entire `./modules/` folder as tests root. What logic does PHPStorm use to do this?

 

Below is my  php storm info:
PhpStorm 2025.2.5

Build #PS-252.28238.9, built on November 19, 2025

Source revision: 7059016f3609e

Licensed to Kroll Bond Rating Agency / Trenton Craig

Subscription is active until May 2, 2026.

Runtime version: 21.0.9+10-b1038.76 aarch64 (JCEF 122.1.9)

VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

Toolkit: sun.lwawt.macosx.LWCToolkit

macOS 15.6.1

GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation

Memory: 4096M

Cores: 10

Metal Rendering is ON

Registry:

 ide.balloon.shadow.size=0

 debugger.watches.in.variables=false

 debugger.new.tool.window.layout=true

 run.processes.with.pty=TRUE

 ide.experimental.ui=true

Non-Bundled Plugins:

 org.jetbrains.plugins.yaml (252.28238.33)

 JavaScriptDebugger (252.28238.33)

 org.editorconfig.editorconfigjetbrains (252.28238.22)

 org.jetbrains.intellij.scripting-javascript (1.3)

 org.intellij.plugins.hcl (252.26199.7)

 aws.toolkit.core (3.99.252)

 Subversion (252.28238.33)

 com.intellij.copyright (252.28238.33)

 org.jetbrains.plugins.go-template (252.23892.201)

 com.intellij.kubernetes (252.28238.33)

 String Manipulation (9.16.0)

 dev.meanmail.plugin.nginx-intellij-plugin (2025.21)

 hunspell (252.28238.33)

 com.intellij.swagger (252.28238.33)

 com.jetbrains.restClient (252.28238.33)

 Docker (252.28238.33)

 org.jetbrains.plugins.gitlab (252.28238.33-IU)

 org.jetbrains.plugins.github (252.28238.33-IU)

 com.intellij.react (252.28238.29)

 org.jetbrains.plugins.vue (252.28238.32)

 com.jetbrains.php.drupal (252.28238.9)

 com.jetbrains.twig (252.28238.10)

 com.jetbrains.php.wordPress (252.28238.9)

 de.espend.idea.php.annotation (12.0.1)

 com.jetbrains.php.rector (252.23892.360)

 com.jetbrains.php.blade (252.28238.9)

 com.pestphp.pest-intellij (252.28238.9)

 com.github.copilot (1.5.61-243)

 com.datadog.intellij (1.10.4)

 com.intellij.mcpServer (252.28238.29)

 mobi.hsz.idea.gitignore (4.5.6)

 com.intellij.php.psalm (252.28238.9)

 com.jetbrains.php.phpspec (252.28238.9)

 com.jetbrains.php.codeception (252.28238.9)

 com.intellij.php.tools.quality.phpstan (252.28238.9)

 org.jetbrains.security.package-checker (252.28238.22)

 aws.toolkit (3.99.252)


Below is the relevant sample of my composer.json file

"autoload": {
    "psr-4": {
      "MyCompany\\Kcp\\": "src/",
      "MyCompany\\ApiConsumer\\": "module/MyCompany/ApiConsumer/src/",
      "MyCompany\\Cache\\": "module/MyCompany/Cache/src/",
      "MyCompany\\Logger\\": "module/MyCompany/Logger/src/",
      "MyCompany\\MailService\\": "module/MyCompany/MailService/src/",
      "MyCompany\\Queue\\": "module/MyCompany/Queue/src/",
      "MyCompany\\Search\\": "module/MyCompany/Search/src/",
      "MyCompany\\Secret\\": "module/MyCompany/Secret/src/",
      "MyCompany\\SawDigest\\": "module/MyCompany/SawDigest/src/",
      "MyCompany\\SwarmClient\\": "module/MyCompany/SwarmClient/src/",
      "MyCompany\\Theme\\": "module/MyCompany/Theme/src/",
      "MyCompany\\Utility\\": "module/MyCompany/Utility/src/",
      "Admin\\": "module/Admin/src/",
      "Application\\": "module/Application/src/",
      "DataFeed\\": "module/DataFeed/src/",
      "Console\\": "module/Console/src/Console/",
      "Portal\\": "module/Portal/src/",
      "Search\\": "module/Search/src/",
      "WidgetEngine\\": "module/WidgetEngine/src/"
    }
  },
  "autoload-dev": {
    "AdminTest\\": "module/Admin/test/",
    "ApplicationTest\\": "module/Application/test/ApplicationTest/",
    "DataFeedTest\\": "module/DataFeed/test/",
    "MyCompany\\KcpTest\\": "tests/Unit/",
    "MyCompany\\KcpTest\\Integration\\": "tests/Integration/",
    "MyCompany\\SecretTest\\": "module/MyCompany/Secret/test/",
    "PortalTest\\": "module/Portal/test/",
    "SearchTest\\": "module/Search/test/",
    "WidgetEngineTest\\": "module/WidgetEngine/test/"
  },

0

I just reviewed WI-78142 and took a look at my phpunit.xml file. I saw that we had `./module/` as one of the test directories. I modified this to reference specific module test folders instead and now the problem has gone away.

I think we need to update the PHPStorm documentation on https://www.jetbrains.com/help/phpstorm/content-root.html to mention phpunit.xml is also considered by phpstorm when automatically updating directory markings.

0

Hi Trenton Craig,

Thank you for sharing your experience and commenting on WI-78142. As soon as this issue is addressed, there will be no need to adjust the documentation.

0

请先登录再写评论。