phpunit command return "phpunit --help" screen - magento

I'm trying to make some PhpUnit test on Magento with using ecomdev (https://github.com/EcomDev/EcomDev_PHPUnit).
I've correctly installed modman, PEAR and related packages dependencies (I'm on Ubuntu server 12.04 through a Virtualbox).
What is really strange is, after the step 2, from ecomdev procedure, when I'm trying to start a first "$ phpunit" command, it shows the screen as if I typed "$ phpunit --help".
When I type "$ phpunit --version" it correctly displaying the current version (mean it seems correctly installed).
All advices are welcome.

I have been similar problem on WAMP, WinXP SP3, Apache 2.4, PHP5.4.44, Xdebug v2.3.3, vc10+vc14
I downloaded phpunit.phar from phpunit.de
My error was wrong phpunit.cmd file.
I wrote
#php "%~dp0phpunit.phar"
Correct cmd is
#php "%~dp0phpunit.phar" %*

phpunit needs to know what to run. EcomDev_phpUnit includes a phpunit.xml.dist file that phpunit can use. Neither modman nor modgit installs it in Magento's root by default. You can copy the default version into Magento's webroot from the module's source folder or by installing the module manually.
I used modgit to install EcomDev_phpUnit. Here is the copy command I used to copy the file:
cp .modgit/ecomdev_phpunit/source/phpunit.xml.dist .
Once in place, phpunit should give you something like this:
$ phpunit
PHPUnit 3.7.28 by Sebastian Bergmann.
Configuration read from /path/to/your/magento/phpunit.xml.dist
There is likely a more correct way to use the included ecomdev-phpunit.php script to copy the phpunit.dist.xml file into place.

Related

How to specify external library file locations when installing CPAN modules

I'm trying to get Perl's Finance::Quote module working after MacOS upgrade to 11.4. One of the dependencies is B::Keywords. B::Keywords installation fails a test with this error:
> sudo cpan B::Keywords
[...]
Can't open /System/Library/Perl/5.30/darwin-thread-multi-2level/CORE/keywords.h: No such file or directory at t/11keywords.t line 25
Digging around, I see that keywords.h exists on my system in this location:
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Perl/5.30/darwin-thread-multi-2level/CORE/keywords.h
Is there a way to tell cpan (or cpanm, or some other installation tool) where to look for these headers? Or, any other approach to get this working would be welcome.
It seems like they removed the keywords.h from the CORE directory (relative to the path given from $Config{archlibexp}) for the system perl on macOS 10.14, see this bug report.
The reason you are not able to install B::Keywords is due to a failed test 11keywords.t see line 24. Some possible solutions:
Install the module without running the tests (sudo cpan -T B::Keywords)
Submit an issue at the GitHub issue tracker so the author of the module can fix the problem.
Install the module with perlbrew instead of using the system perl (I tested this and it worked fine here).

laravel 4 cannot get phpunit testing to work

I'v installed phpunit by adding it into my composer.js and running the update. The composer did it's thing and automatically installed phpunit and updated various scripts.
I then ran the 'phpunit' command (from the laravel folder) as instructed by the docs and received
'phpunit' is not recognized as an internal or external command operable program or batch file
Which is fustrating as the doc simply say
You may run all of the tests for your application by executing the phpunit command from your terminal.
Which seem to be false.
So after looking around trying out various things I managed to get a response from
php vendor/bin/phpunit
which I ran from the same folder where phpunit.xml is located.
The response I got was
SRC_DIR="`pwd`"
cd "`dirname "$0"`"
cd "../phpunit/phpunit"
BIN_TARGET="`pwd`/phpunit"
cd "$SRC_DIR"
"$BIN_TARGET" "$#"
What is that?? That they what I'm expected to receive from the unit testing. I assume not.
My understanding is that it will run all the unit tests located in the laravel/app/test/ folder.
What is going on and how do I get this to work?
Note I am running from the windows CMD.
I tried installing the laravel homestead but this just introduced more headaches and problems.
To get phpunit working I edited the 'Path' environment variable.
Method for windows 7
1) Right click on 'My computer'->properties
2) In the left hand column click 'Advanced System Settings'
3) under the Advance tab click 'Enviroment Variables'
4) Under 'System Variable' local the 'Path' variable and click edit
5) Append the location of phpunit.bat to the end of the variable data.
IE C:/some/other/thing; C:/something/else; C:/myproject/laravel/vendor/bin/
6) Save it all.
This is what I've done and it seem to work fine.

cannot install or use ZeroMQ library

I am working on Debian Linux / Apache (a VPS at Dreamhost). I have tried to install ZeroMQ (version 3.2.3) as per these instructions. At the first glance, it looks like everything went well.
The sudo make install command proudly reports back that (among others)
Libraries have been installed in: /usr/local/lib
Indeed, here is the ls of /usr/local/lib:
libzmq.a libzmq.so libzmq.so.3.0.0 php python2.5 site_ruby
libzmq.la libzmq.so.3 ocaml pkgconfig python2.6
In order to use ZeroMQ I have added to my php.ini:
extension = /usr/local/lib/libzmq.so
But when I run PHP, I get:
PHP Startup: Invalid library (maybe not a PHP library) '/usr/local/lib/libzmq.so
What am I doing wrong?
update
As per djf's answer, I worked my way through the instructions for PHP bindings (building from Github). Those seem to work. But then, when I run PHP I get:
PHP Warning: PHP Startup:
zmq: Unable to initialize module Module compiled with module API=20060613
PHP compiled with module API=20100525
These options need to match in Unknown on line 0`
Now what?
update 2
Oh, wait a minute. I may know what that is. Dreamhost has PHP 5.2 on the command line. I need PHP 5.4, so I have been calling PHP like so /usr/local/php54/bin/php (this is apparently where the PHP 5.4 executable resides).
However, commands like configure and make use the ordinary, standard PHP. So I needed to upgrade CLI PHP to 5.4.
After that, everything worked. Thanks for the help, everyone!
Seems like you've only installed the C library, hence the error:
PHP Startup: Invalid library (maybe not a PHP library) '/usr/local/lib/libzmq.so
You also have to build the PHP bindings. Check these instructions on howto build them.
I do this for windows but i thinks linux is same.
Just go to http://pecl.php.net/package/zmq/1.1.2/windows and download package that fit with your php version.
Then extract it and coppy 'libzmq.dll' to 'xampp/php' folder, 'php_zmq.dll' to 'xampp/php/etc'.
At the end of 'php.ini' add following line:extension=php_zmq.dll
Don't forget restart your xampp!Good luck

I cant get PHPUnit to work within NetBeans (Mac)

My NetBeans have an option to add a path to a script that runs PHPUnit, however when I try to add this script to my NetBeans I get the error that it doesn't recognize the version. Says that version is ?.?.? and that is not supported. However my PHPUnit version is supported by NetBeans and work perfectly when I run it from the pear installer folder (PHP).
"Selected PHPUnit (version ?.?.?) is too old, upgrade it if possible (the minimum version is 3.3.0)" - I got 3.6.4.
My script looks like this
#!/bin/sh
phpunit --bootstrap MyBootstrap.php --stderr $*
And it works great on linux NetBeans. Just not on my Mac.
And yes it works perfect when I run it in the console.
Thanks a milion
/Marcus
I'm not sure what php runner is, but to recognize valid PhpUnit, NetBeans run command "phpunit --version", so check what this command gives you in console.
Once I had problem with this, so I simply found the code of phpunit that is responsible for "phpunit --version" and manually type what should be printed when this command is executed. So NetBeans "saw" correct version and everybody is happy :)
I solved the phpunit problem (too old phpunit message on netbeans)
First open terminal and then:
cd /private/etc
cp php.ini.default php.ini
open php.ini file
change include_path to include_path = ".:/usr/share/pear"
Problem solved :)
If however the problem is not solved then try install netbeans for php from netbeans.org
Mate, that is error by Netbeans (see bug id 188240), and it looks like it is not fixed yet. It happens on Mac OSX.
What i did is to rename Application/NetBeans/NetBeans 7.1.1 to Application/NetBeans/NetBeans7.1.1 (note the lack of space)
as per Xdebug, read this:
http://xdebug.org/find-binary.php
when you get the version for your server, add these lines into your php.ini:
zend_extension = /opt/local/lib/php/extensions/<name of your extension>/xdebug.so
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
replacing <name of your extension> with, of course, the name of your extension :)
after this you should be ready to go.
Issue about version soved by reinstalling everything, however I now get this
PHPUnit 3.6.7 by Sebastian Bergmann.
The Xdebug extension is not loaded. No code coverage will be generated.
Cannot open file "/Applications/NetBeans/NetBeans".
How could I load Xdebug? Is that in php.ini or apache conf? or is that in NetBeans?

Installling phpunit mac osx snowleopard (zend framework)

I'v been trying to get phpunit up and running but for some reason i'm stuck with the following error:
Warning: require(PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 44
Fatal error: require(): Failed opening required 'PHPUnit/Autoload.php' (include_path='.:') in /usr/bin/phpunit on line 44
Does anybody have a clue how to solve this?
Thanks in advance!
Peter
Your include path is not setup. Follow the instructions at http://pear.php.net/manual/en/installation.checking.php
Also check if you installed phpunit in the correct directory:
$ pear list-files phpunit/phpunit
PHPUnit/Autoload.php should be listed there, in the patch you added to the include path.
Update: the problem was that #Peter had 2 php.ini files, and he edited the wrong one.
Find the correct one with
$ php --ini
Irakli's post was the most helpful.
I'm on Mac OS X 10.7.2 and I use Homebrew to install packages. Homebrew put php in /usr/local/bin/php.
Following Irakli's hint that phpunit is using a different version on of PHP (even though it was using the same php.ini file), I edited /usr/bin/phpunit, replacing this:
#!/usr/bin/php
with this:
#!/usr/local/bin/php
(Irakli's suggestion of "#!/usr/bin/env php" didn't work for me)
Now phpunit can find "File/Iterator/Autoload.php" which is was having trouble with before, so I guess it's in the path now.
On Mac Lion I added the include path:
/usr/lib/php/pear/
to /private/etc/php.ini which solved the error.
In some cases (e.g. when using brew-installed PHP on OS-X Leopard/Snow Leopard/Lion) the problem can be that there're multiple php versions installed and phpunit is picking wrong one.
There's an easy solution, sudo-edit /usr/bin/phpunit and replace #!/usr/bin/php with #!/usr/bin/env php
Somebody should probably submit a bug to phpunit, referring to PHP executable directly is really careless.

Resources