How to connect PHPUnit?

Hi all. Installed PHPUnit via Composer, but the "vendor\bin\phpunit tests" does not work - "vendor is not recognized as an internal..." Only if you go to the bin folder, you can work with phpunit that I did. Saw that in this folder there's a bat file I copied it to the root and changed the path to "vendor/phpunit/phpunit/phpunit". Now from the project root everything works. Such variant takes place to be or needed in the PATH variable to prescribe better or just globally install PHPUnit?
June 10th 19 at 15:21
1 answer
June 10th 19 at 15:23
Solution
First, you can add in the composer.json:
"config": {
 "bin-dir": "bin"
 }

Then in the bin folder in the project root will create symlinks for all console packages.
Second, you need to create in a root a file with the config phpunit.xml that may look like this:
<phpunit bootstrap="vendor/autoload.php">
<testsuites>
 <testsuite name="Unit test">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>

And it has to describe the detail settings. Then, when you run bin/phpunit will run the tests specified in the config settings.
Thanks, I'll try - Kennedi_Thompson commented on June 10th 19 at 15:26
I tried, I created a bin folder in the project root, but now when I write bin/phpunit get "bin is not recognized as an internal..." what could be? - Kennedi_Thompson commented on June 10th 19 at 15:29
try with another backslash bin\phpunit if you are under Windows - Birdie commented on June 10th 19 at 15:32

Find more questions by tags PHPPHPUnit