Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run unit tests from PHPStorm on Magento 2.2. #167

Closed
centerax opened this issue Jan 17, 2018 · 3 comments
Closed

Cannot run unit tests from PHPStorm on Magento 2.2. #167

centerax opened this issue Jan 17, 2018 · 3 comments

Comments

@centerax
Copy link

Problem:
Cannot run tests from PHPStorm.

Magento version: 2.2.2
PHP Unit version: 6.2.4

Error I get.
sftp://vagrant@127.0.0.1:3173/usr/bin/php /home/vagrant/.phpstorm_helpers/phpunit.php --configuration /Users/pablo/Vagrant/magento2/vagrant-magento-22/magento2ce/dev/tests/unit/phpunit.xml /Users/pablo/Vagrant/magento2/vagrant-magento-22/magento2ce/app/code
Testing started at 10:14 AM ...

Fatal error: Class 'PHPUnit_TextUI_ResultPrinter' not found in /home/vagrant/.phpstorm_helpers/phpunit.php on line 253

@nfourteen
Copy link
Contributor

@centerax I just ran into this problem myself. For whatever reason, PhpStorm is running the old class versions of phpunit in /home/vagrant/.phpstorm_helpers/phpunit.php. I kept messing with the configuration and suddenly it ended up working. If you want, you could try these steps and see if it works for you...might be a workaround for now:

  1. SSH into the box and go to /home/vagrant/.phpstorm_helpers/ a run cp phpunit.php phpunit.php.bak
  2. Try and run a test from PhpStorm, you should get the error that /home/vagrant/.phpstorm_helpers/phpunit.php doesn't exist
  3. Go to Preferences > Languages & Frameworks > PHP > Test Frameworks and click on the + button
  4. Choose PHPUnit by Remote Interpreter and set the CLI interpreter to the box's name
  5. Select Use Composer autoloader and set the path to <install dir>/magento2ce/vendor/autoload.php
  6. Set the Test Runner "Default configuration file" to <install dir>/magento2ce/dev/tests/unit/phpunit.xml

Note: the <install dir> is copied to the box using the path to where it's installed on the host. If you're on a Mac, the install dir on the box will be /Users/<username>/<path to git clone location>.

Hopefully that'll work for you!

@centerax
Copy link
Author

thanks @nfourteen I will try that :)

@paliarush
Copy link
Owner

@nfourteen thanks for the suggested solution, added current issue to the FAQ list in the readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants