Closed plakhin closed 6 months ago
I think your excecutable path should be vendor/bin/pest
:
*Substitute your correct php executa
"phpunit.executable": "vendor/bin/pest",
"phpunit.php_executable": "/Users/stan/Library/Application Support/Herd/bin/php",
"phpunit.pest": true,
Though you may not need to set the executable path at all, because when
phpunit.pest
is true, we try to auto discover the executable path,
which is usually vendor/bin/pest
.
You only need to set the executable paths when they can't be auto-discovered, for one reason or another.
Herd probably puts the php executable on the system. See if works with
just setting phpunit.pest
to true:
"phpunit.pest": true,
If no, try just setting the php executable:
"phpunit.php_executable": "/Users/stan/Library/Application Support/Herd/bin/php",
"phpunit.pest": true,
Then, the pest executable, which is relative to your project path or absolute:
"phpunit.php_executable": "/Users/stan/Library/Application Support/Herd/bin/php",
"phpunit.executable": "vendor/bin/pest",
"phpunit.pest": true,
For example, how do you run the test via the command line? I assume you
cd into your project and simply run vendor/bin/pest
? In that case you
probably only need:
"phpunit.pest": true,
There is some new documentation I haven't finished yet, see https://blog.gerardroche.com/projects/sublime-phpunit
Also, set phpunit.debug
to true and inspect the console log, Menu →
View → Show Console, for additional information.
Let me know if these work for you.
I'm thinking too, that there might be an issue with the space in the php executable path:
"/Users/stan/Library/Application Support/Herd/bin/php"
Maybe try escape the space, if all the above fails:
"/Users/stan/Library/Application\ Support/Herd/bin/php"
Thanks for the response!
Though you may not need to set the executable path at all, because when phpunit.pest is true, we try to auto discover the executable path, which is usually vendor/bin/pest.
Tried this before. Double-checked again. The error is PHPUnit: 'phpunit not found'
.
"phpunit.php_executable": "/Users/stan/Library/Application Support/Herd/bin/php", "phpunit.pest": true,
Same with this — PHPUnit: 'phpunit not found'
Then trying this:
"phpunit.php_executable": "/Users/stan/Library/Application Support/Herd/bin/php", "phpunit.executable": "vendor/bin/pest", "phpunit.pest": true,
And getting PHPUnit: ''NoneType' object is not iterable'
.
For example, how do you run the test via the command line? I assume you cd into your project and simply run vendor/bin/pest? In that case you
Exactly.
Maybe try escape the space, if all the above fails:
Doesn't work, as settings file becomes invalid JSON:
Error trying to parse settings: Invalid escape in Packages/User/Preferences.sublime-settings:81:27
Also tried "/Users/stan/Library/Application\\ Support/Herd/bin/php"
, but getting PHPUnit: ''phpunit.php_executable' '/Users/stan/Library/Application\ Support/Herd/bin/php' is not an executable file'
So, I think the problem is somewhere else as paths are correct in this case:
"phpunit.php_executable": "/Users/stan/Library/Application Support/Herd/bin/php", "phpunit.executable": "vendor/bin/pest", "phpunit.pest": true,
I will try to set phpunit.debug
and check the unfinished documentation and let you know.
Console output with "phpunit.debug" = true,
:
reloading settings Packages/User/Preferences.sublime-settings
PHPUnit: run working_dir=None, file=None, options={}
PHPUnit: find configuration for '/Users/stan/Herd/laravel/app/Domains/Ui/tests/ArchitectureTest.php' ...
PHPUnit: found 1 folders ['/Users/stan/Herd/laravel']
PHPUnit: found 5 possible locations ['/Users/stan/Herd/laravel/app/Domains/Ui/tests', '/Users/stan/Herd/laravel/app/Domains/Ui', '/Users/stan/Herd/laravel/app/Domains', '/Users/stan/Herd/laravel/app', '/Users/stan/Herd/laravel']
PHPUnit: looking for ['phpunit.xml', 'phpunit.xml.dist', 'phpunit.dist.xml'] ...
PHPUnit: found configuration '/Users/stan/Herd/laravel/phpunit.xml'
PHPUnit: session options None
PHPUnit: view options None
PHPUnit: options {}
PHPUnit: ''NoneType' object is not iterable'
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python38/sublime_plugin.py", line 1660, in run_
return self.run()
File "/Users/stan/Library/Application Support/Sublime Text/Packages/PHPUnitKit/plugin.py", line 28, in run
PHPUnit(self.window).run(options=options)
File "/Users/stan/Library/Application Support/Sublime Text/Packages/PHPUnitKit/lib/runner.py", line 119, in run
raise e
File "/Users/stan/Library/Application Support/Sublime Text/Packages/PHPUnitKit/lib/runner.py", line 71, in run
cmd += get_setting(self.view, 'prepend_cmd')
TypeError: 'NoneType' object is not iterable
It looks like you have the setting phpunit.prepend_cmd
set to null. It
should be a list []
.
I've patched it to handle invalid types:
https://github.com/gerardroche/sublime-phpunit/commit/bece7839d1af5f77d0f5c727b5700518edff3114
And I've added additional settings debugging.
I'm tagging a release now, so it should be available from package control soon.
When you update, run it again with debug enabled and inspect the additional settings debug output to make sure your settings are what you expect them to be.
For the moment, 3.19.3 is still not available on package control.
I've set "phpunit.prepend_cmd": [],
so the error is gone, debug panel shows Running vendor/bin/pest
as the last command, status bar shows "Building" for a few seconds, then Build finished
, or Build finished with 2 errors
in case I specifically set one of the expectations to the wrong value, so looks like it works. Thanks!
/offtopic
~Is there a way to view the output of pest in case there were errors and/or in case there was no errors?~
UPD: PHPUnit: Test Results
command does it.
Should we close the issue or better wait for 3.19.3 and check without explicitly settings "phpunit.prepend_cmd": []
?
The test results should always auto open, at least when using pest. If you're using something like the tmux strategy, the panel won't auto open.
If this resolves the issue, you can close the issue. Though, I'm
wondering why phpunit.prepend_cmd
was null? Did you set it null, or is
there an underlying issue. By default it should be []
so there
shouldn't be an error.
3.19.3 became available, works good even without explicitly setting "phpunit.prepend_cmd": []
.
Closing the issue.
Thank you once again!
The test results should always auto open, at least when using pest. If you're using something like the tmux strategy, the panel won't auto open.
I've found out that I have "show_panel_on_build": false
in settings, so it doesn't, however this is expected :) All good.
Though, I'm wondering why phpunit.prepend_cmd was null? Did you set it null, or is there an underlying issue. By default it should be [] so there shouldn't be an error.
I didn't set it to null. Here are all my settings:
"phpunit.composer": false, // doesn't affect in any way in my case, just explicitly set it to false while was trying various ways to make it work since the default value was true.
"phpunit.pest": true,
"phpunit.php_executable": "/Users/stan/Library/Application Support/Herd/bin/php",
"phpunit.executable": "vendor/bin/pest",
Let me know if you need some more testing from my side.
The phpunit.composer
enable auto-discovery of phpunit vendor/bin/* scripts. So in your case, you probably don't to set the "phpunit.executable": "vendor/bin/pest"
, because if phpunit.composer
is enabled (default):
vendor/bin/
vendor/bin/pest
, then vendor/bin/phpunit
, then the system pathvendor/bin/phpunit
, then the system pathIf phpunit.composer
is not enabled then phpunitkit doesn't check vendor/bin/*
and instead just falls back to the system path.
So you can probably delete both the phpunit.composer
and phpunit.executable
settings. Composer will default to true and auto discover the pest script in vendor/bin.
You can probably delete phpunit.php_executable
too, if Herd puts php on the system path. For example, when you run tests via the command line, can you just run vendor/bin/pest
? If yes, then the Herd php is on the system path and you can delete the phpunit.php_executable
setting. In which case, the only setting you would need is:
"phpunit.pest": true,
Could you please share a working Pest config?
I'm on macOs, using Herd, having this config:
Getting this error:
PHPUnit: ''NoneType' object is not iterable'
Was playing with config, testing different options, but was getting only
PHPUnit: 'phpunit not found'
andPHPUnit: ''phpunit.php_executable' 'php' is not an executable file'