I'm trying to run the PHPUnit into the NetBeans 8.0.2.
If I run # phpunit inside my folder tests all tests run. So it's seems been set right.
But in the NetBeans output I always got:
"C:\nginx\php\5.6.12\php.exe" "C:\nginx\php\5.6.12\phpunit.phar" "--colors" "--log-junit" "C:\Users\...\AppData\Local\Temp\nb-phpunit-log.xml" "--bootstrap" "E:\var\www\...\tests\TestHelper.php" "--configuration" "E:\var\www\...\tests\phpunit.xml" "C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php" "--run=E:\var\www\...\tests\app\utils\FormatUtilTest.php"
PHPUnit 4.8.2 by Sebastian Bergmann and contributors.
unrecognized option --run
Done.
Maybe the "--run message" it's right, because this command doesn't exist in the PHPUnit manual. But if is that so, how to create another script for the NetBeans execute the tests?
I ran into the same issue yesterday after a PHPUnit update. So I reverted back to PHPUnit 4.7.7 for now, until this is fixed in NB.
I too have encountered this error causing the latest version of PHPUnit not to work with NetBeans v8.0.2.
Further investigating this issue has resulted in determining that there is an incompatibility between NetBeansSuite.php and the latest version of PHPUnit.
The error 'unrecognized option --run' is being thrown by the phpunit.phar and not being thrown by NetBeansSuite.php. I also do not believe the NetBeansSuite.php is even being executed.
phpunit.phar, line 63816 or 63894, is where the exception is being thrown.
Until this is fixed, PHPUnit will not work from NetBeans v8.0.2.
#Pablo: I thank you for opening an issue and have commented on your issue.
PHPUnit v4.7.7 works correctly.
Opened a bug report: https://netbeans.org/bugzilla/show_bug.cgi?id=254276
The answer is: This was indeed a bug in NB and is now fixed in nightly.
Possible solutions:
Upgrade to latest nightly from http://bits.netbeans.org/dev/nightly/
Use PHPUnit 4.7.7 as mentioned by Luuk
"--run" option is used in the NetBeansSuite.php for running tests. So, you should submit that to NetBeans bugzilla [1] if you want to avoid that.
[1] https://netbeans.org/community/issues.html (PHP/PHPUnit)
2019 and the problem still exists. Downgrading PHPUnit is no option anymore today. So I created, as a workaround, a wrapper script for phpunit which takes care of removing the bad parameters.
It also removes the NetBeansSuite.php file completely because it does the same a call directly to the phpunit script would.
My setup is Windows Netbeans 11, Windows PHP 7.3, and a cygwin wrapper (because it's bash code). If somebody feels like porting this to native windows, please leave a comment here.
#!/usr/bin/env sh
# modified phpunit script originally from vendors dir
# 1. cygwin default search path is bad in my installation...
PATH="$PATH:/bin:/usr/bin"
# original code, only adjust the ../../ to match your installation.
# the directory this is run in is where the wrapper script resides
dir=$(cd "${0%[/\\]*}" > /dev/null; cd "../../vendor/phpunit/phpunit" && pwd)
if [ -d /proc/cygdrive ] && [[ $(which php) == $(readlink -n /proc/cygdrive)/* ]]; then
# We are in Cgywin using Windows php, so the path must be translated
dir=$(cygpath -m "$dir");
fi
# fix netbeans parameters
while [ $# -gt 0 ]; do
case "$1" in
*NetBeansSuite.php) shift;;
--run=*) PARAMS="$PARAMS ${1#--run=}"; shift;;
--) shift ;;
*) PARAMS="$PARAMS $1"; shift;;
esac
done
"${dir}/phpunit" $PARAMS
You have to adjust both occurrences of "../"s to your folder structure.
This solution works with ALT-F6 (run all tests), right clicking a test folder "Run Tests" and also single test files right click "Run".
The setting for "Netbeans: Tools/Options/Frameworks & Tools/PHPUnit" is then:
C:\cygwin\bin\bash.exe /cygdrive/c/workspace/Project/src/cli/phpunit
Adjust these path names to your needs, again.
HTH,
M.
Related
I have configured PhpStorm to connect to a remote web server. I am running phpunit for unit tests. I have xdebug running and have created an ssh tunnel for debugging. I know xdebug is running as I am able to click and run a phpunit test (with breakpoint set) by just clicking the run button (after turning on listening for PHP debug connections). However if I instead choose the Debug option in PhpStorm I get connection errors.
Enabling debug messages to the PhpStorm log file I see that the command being sent is:
DEBUG - ellij.ssh.SshConnectionService - Executing SSH command:
cd /[path to project files];
exec env "IDE_PHPUNIT_CUSTOM_LOADER"="/[path to autoloader]/autoload.php" "JETBRAINS_REMOTE_RUN"="1" "XDEBUG_CONFIG"="idekey=17650" /usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9002 -dxdebug.remote_host=[ip address] /[path to phpunit]/phpunit/phpunit --configuration /[path to phpunit xml file]/phpunit.xml --filter '/(::myTestClassMethod)( .*)?$/' 'another method being tested' /[path to unit test file]/myUnitTest.php --teamcity within SshjSshConnection([blah]#[foo])#bar
My php.ini settings are expecting idekey=PHPSTORM but I'm seeing a numeric key in the command line that keeps changing for each attempt.
I'm assuming these two values for idekey need to match. If that's correct how do I do that?
Thanks
They don't need to match. In fact, PhpStorm is just overriding it here so that it can match against what it expects.
I don't understand why it does that, as IDE Keys are (currently) only used in combination with DBGp proxies.
As you don't describe what "connection errors" are, it's not really possible to provide an answer to that part of the question yet.
I got this error message when I tried to make an alias for artisan:
[Settings | Tools | Command Line Tool Support ] -> add -> tool based on Symfony Console
Problem
Failed to parse output as xml: Error on line 4: Content is not allowed in prolog..
Command
C:\xampp\php\php.exe C:\xampp\htdocs\laratest\artisan list --xml
Output
[Symfony\Component\Console\Exception\RuntimeException]
The "--xml" option does not exist.
Ok, I know, what's the problem but I don't find any solution for this.
Thank you for the tips!
A temporal modification of the "artisan" file under the Laravel folder will do the trick. (Working on PhpStorm 10.0.3)
if( isset($argv[1]) && $argv[1] == 'list' &&
isset($argv[2]) && $argv[2] == '--xml' ) {
$argv[2] = '--format=xml';
$_SERVER['argv'] = $argv;
}
require __DIR__.'/bootstrap/autoload.php';
Now you can add the "artisan" command line tool support based on Symfony and remove the lines if you wish to.
For everybody affected, this is the commit which removed support for –xml: https://github.com/symfony/console/commit/6d6d9031b9148fed0e2aacb98ac23ce6168ba7ac
Just revert changes in ListCommand.php
it work in 2.7 version
There is no --xml option, you are getting this error when you running this command:
The "--xml" option does not exist.
So what you should do in this case is running:
php artisan help list
and you will get list of all available parameters
and now you will know you need to use:
php artisan list --format=xml
instead of:
php artisan list --xml
EDIT
I've verified it in PhpStorm 10.0.3
as Tool path you can paste in your case:
C:\xampp\php\php.exe C:\xampp\htdocs\laratest\artisan list --format=xml
and it will work
Update composer before add command line tool:
composer update
Running phpunit tests using PhpStorm.
Receiving this error:
/usr/local/php5/bin/php
/private/var/folders/m8/k61mmmmj7g732j3pd0_91s0c0000gn/T/ide-phpunit.php
--configuration /Users/psteinheuser/unity/test/phpunit.xml DatabaseDumperTest
/Users/psteinheuser/unity/test/DatabaseDumperTest.inc Testing started
at 11:36 AM ...
Fatal error: Class IDE_PHPUnit_Framework_TestListener contains 1
abstract method and must therefore be declared abstract or implement
the remaining methods (PHPUnit_Framework_TestListener::addRiskyTest)
in
/private/var/folders/m8/k61mmmmj7g732j3pd0_91s0c0000gn/T/ide-phpunit.php
on line 504
Call Stack:
0.0013 340096 1. {main}() /private/var/folders/m8/k61mmmmj7g732j3pd0_91s0c0000gn/T/ide-phpunit.php:0
PHP Fatal error: Class IDE_PHPUnit_Framework_TestListener contains 1
abstract method and must therefore be declared abstract or implement
the remaining methods (PHPUnit_Framework_TestListener::addRiskyTest)
in
/private/var/folders/m8/k61mmmmj7g732j3pd0_91s0c0000gn/T/ide-phpunit.php
on line 504
Have found previous posts which have said this is fixed, though I seem to have the correct versions where it should work.
PHPStorm 7.1.3
phpunit 3.7.28
php 5.4.24
The OS is Mac 10.9.2
Have removed and re-installed PHPStorm, upgraded php, re-installed phpunit, restarted apache, rebooted, scratched my head, etc.
Running the phpunit tests manually from the terminal, works fine.
Looking at Preferences within PHpStorm, it seems to be pointing to phpunit correctly.
I'm thinking it's a permission or path issue, but I don't know where to look next.
Appreciate any input or direction.
In PHPStorm, the only way I was able to solve this was by manually updating the contents of the jar file where this error exists.
We're both on Mac OSX 10.9, so these instructions should work for you.
Begin by making a copy of the existing jar file:
cp /Applications/PhpStorm.app/plugins/php/lib/php.jar /Applications/PhpStorm.app/plugins/php/lib/php.jar.orig
Now, create a temporary directory to hold your jar file's contents and extract
mkdir ~/jarfiles
cd ~/jarfiles
jar xf /Applications/PhpStorm.app/plugins/php/lib/php.jar
Once extracted, you'll need to edit the phpunit.php file to add the missing method stub
vi scripts/phpunit.php
Around line 310 in my file is a class 'IDE_PHPUnit_Framework_TestListener'. Insert the following method stub:
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time){}
Now just re-pack your jar and replace it into your PhpStorm:
jar cf0 php.jar ./*
mv php.jar /Applications/PhpStorm.app/plugins/php/lib/php.jar
That fixed it for me. Hope it fixes it for you too. Good luck!
Background: i am on a windows host and sshing into a vagrant LAMP setup (ubuntu 13.04).
I have installed phpunit with composer using the following line in my composer.json:
"require-dev": {
"phpunit/phpunit": "3.7.*"
}
I have then run composer update which installed phpunit. I can now navigate to /vendor/bin and see phpunit binary.
However if i type phpunit from within that directory (or anywhere elese for that matter) I get the error "phpunit is not installed"
Any suggestions as to where I go next with this - there are so few steps involved in this setup I really cant see where I could have gone wrong
So I had this issue too, for me the fix was to change in my vagrant file:
config.vm.synced_folder "C:/dev/vm/share", "/var/www/", mount_options: ['dmode=777','fmode=666']
to
config.vm.synced_folder "C:/dev/vm/share", "/var/www/", mount_options: ['dmode=777','fmode=777']
There is a lot of advise saying 666 is permissive enough, but in my case it was not and as this is only a development machine the security implications are not too important.
./phpunit from the bin directory.
It's just not in your path.
I created the script above:
#!/bin/bash
binary=$1
shift
dir=$PWD
for i in $( seq 5 )
do
if [ -e "$dir/composer.json" ]
then
$dir/vendor/bin/$binary $#
else
echo "not found phpunit in $dir"
fi
dir="$dir/.."
done
If you name it 'composer.exec', and put it n your path, you can call it:
composer.exec phpunit [phpunit-options]
And there is it! Calling phpunit or any other bin contained in vendor/bin.
I am trying to move my development environment (symfony2 application) from my windows 7 localhost to a virtual machine using vagrant and the default ubuntu 10.04 64 bit machine. Everything is set up and it almost works, but there is one thing bothering me:
When I run ant and it executes phpunit, I get the following error while executing my selfmade bootstrap:
stty: standard input: Invalid argument
I could narrow the problem down to the following line of code, which executes the symfony cache:warmup command:
executeCommand($application, "cache:warmup");
This executes the following command:
php app/console -e test -q cache:warmup
Running phpunit without ant works fine, so does running ant without the executeCommand line.
I read a bit about this stty error and looked up ~/.bashrc, ~./profile, /etc/bash.bashrc, /etc/profile as well as /root/.bashrc and /root/.profile without finding anything like tty or stty. SO I don't know what I could delete to make it work.
I am a bit stuck as I need the cache warmup and cannot figure out what is going wrong.
This took a while to figure out, but I now got it.
For some reason, the options passed to the symfony2 application object causeing the issue only when run by ant.
I don't have any insight on what causes it, but changing the command to this fixes the issue:
php app/console --env=test --quiet cache:warmup
As this is only the long form and does not change anything, I'm very happy. My whole executeCommand function looks like this:
function executeCommand($application, $command, Array $options = array()) {
$options["--env"] = "test";
$options["--quiet"] = true;
$options = array_merge($options, array('command' => $command));
$application->run(new ArrayInput($options));
}
The only lines changes are 2 and 3 where the key for the array was changed from -eand -q. I hope this helps one or another who struggles with an issue like this!