0

I have a php file in the root of the project. It consists of about 112 (1600 lines of code) helper functions.
If I do something like this in my composer.json and run phpunit:

"autoload": {
  "psr-4": {
    "My\\Namespace\\": "src"
  },
  "files": [
    "helpers.php"
  ]
},

Then I get segmentation fault ./vendor/bin/phpunit

Without including this file via composer my unit tests work fine and take no more that 4mb

What do I do wrong and how can I test functions inside this file?

  • What have you tried to resolve the problem? Where are you stuck? – Nico Haase Oct 21 '22 at 06:53
  • @NicoHaase I don't even know where to start... It's the first time I see something like that – Max Trunnikov Oct 21 '22 at 07:06
  • You could start by removing all content of that `helpers.php` file to check whether this resolves the problem. If yes, add the data to the file again, function by function to identify which one triggers the problem. Maybe you use `include` in a recursive way? – Nico Haase Oct 21 '22 at 07:19
  • 1
    One reference Q&A about segfaulting while running phpunit is: https://stackoverflow.com/q/6343674/367456 - often run-away recursion or a regular expression. However this entirely depends on each project (just saying) and can have many different issues. Maybe some of the answers there give you a pointer on how to troubleshoot it. To cope with runaway recursions you can try the xdebug feature to error-out when a recursion depth limit is hit, you'll have a stack-trace then to inspect. – hakre Oct 22 '22 at 07:41

0 Answers0