Zend Framework (PHPUnit) Tests won'r run (phpunit: command not found / Class 'PHPUnit_Framework_TestCase' not found) - zend-framework

i installed PHPUnit by the book:
sudo pear channel-discover pear.phpunit.de
sudo pear install phpunit/PHPUnit
The include path is added in the /etc/php5/cli/php.ini
include_path = ".:/usr/share/php"
$ ls /usr/share/php/PHPUnit/
Extensions Framework
But now, if I want to run the Tests for Zend Framework
user#server:/var/www/page/tests$ ./runtests.sh
+ phpunit --verbose AllTests
./runtests.sh: line 72: phpunit: command not found
user#server:/var/www/page/tests$ php AllTests.php
PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /var/www/page/tests/Zend/Acl/AclTest.php on line 37
Of course i also get a phpunit: command not foundwhen i try to follow the instructions in the PHPUnit Manual http://www.phpunit.de/manual/3.6/en/writing-tests-for-phpunit.html outside of Zend Framework Context.
I'm getting the Feeling I'm missing something essential here ...
Solved
Looks like there was a Problem with the PEAR Channels, after adding the other 2 Again, it worked:
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com

Since the problem was solved in the comments I just make a real answer to sum up.
The reason for the problem was missing phpunit command. Reinstallation of phpunit and setting variable PATH to the folder containing phpunit command (export PATH=$PATH:/path/to/folder/with/phpunit) solved the issue.

Related

PHP Fatal error: Class 'RemoteWebElement' not found in

I have a symfony project that run normal in command line:
php app/console server:run
But, I want to run inside PhpStorm. When I try to do this, it gives the fatal error:
PHP Fatal error: Class 'RemoteWebElement' not found in
I already tried to look the oficial documentation of the classe:
http://facebook.github.io/php-webdriver/classes/RemoteWebElement.html. But I didn't found information that culd help me.
I also added the compose dependency:
composer require facebook/webdriver
But had no effect!
=======================================
I'll explain step-step how to get this the bug (It will be very long!):
I have:
PHP 5.5.9
PhpStorm 10.0.3
composer 1.0-dev (7117a5775ffdcdfd31bbd52a138a6f9c65e7e3c2) 2016-02-03
So, create a new symfony project (current version 3.0) and add composer dependencies:
symfony new project
cd project
composer update
Then, open this project inside of phpstorm and I configure settings for to run the project:
Settings -> Languages & Frameworks -> PHP
"PHP language level": 5.5
"Interpreter": 5.5.9
Add through plus(+) the PHP folder:
/usr/share/php
Click 'OK'
Now, try to run de project through PhpStorm by the shortcut:
Ctrl+Shif+F10.
Will appear the bug:
PHP Fatal error: Class
'Symfony\Bundle\FrameworkBundle\Test\WebTestCase' not found in
Solve this by this way inside of PhpStorm:
Settings -> Languages & Frameworks -> PHP -> PHPUnit
Choose: "Use custom autoloader"
And, in the field "Path to script", informe the autoloader's address. For example:
/home/murilo/git/slu/app/autoload.php. Click 'OK'.
Again, try to run de project through PhpStorm by the shortcut:
Ctrl+Shif+F10
Will appear the bug:
PHP Fatal error: Class 'Doctrine\Tests\Common\Cache\CacheTest' not
found in
Solve this through this command inside the project folder:
composer require maslosoft/cachetest:dev-master -n --no-progress
For the last time, try to run de project through PhpStorm by the shortcut:
Ctrl+Shif+F10
Will appear the bug:
PHP Fatal error: Class 'RemoteWebElement' not found in
I'm at this bug.
Please, someone knows how I can overcome this bug? o.O
I struggled with the same exact issue as you have described. After breaking my head for most of the day with this problem, I found the issue.
When you execute the command php app/console server:run in command line, it sets up a server and runs the website. However, when you run the project in PHPStorm, it doesn't actually run it as a server but runs it as a PHPUnit. What you need to do is configure a PHP Web Application in PHPStorm and run that.
Check the image below where I have configured the website. When I run the Web Application, it will run by the url and it will show up in your browser.

How to configure PHPUnit with ZF version 1.12.11

I am using zend framework 1.12.11 and now I want to use PHPunit with it.Pear has stopped it's stopped support for phpunit.Now it's working with composer.
I have install composer and phpunit via composer.But Where I have to put composer json setting file and my project and what should include in my project which automatically take phpunit of composer
Per the PHPUnit documentation for Composer installation, add PHPUnit to the dependencies in your project's composer.json file, something like:
{
"require-dev": {
"phpunit/phpunit": "4.6.*"
}
}
Then run:
composer update -vvv phpunit/phpunit
to actually bring PHPUnit and its dependencies down into your project.
I usually add the -vvv (maximally verbose) flag to see what's going on under the hood. Feel free to omit if you prefer.
Once they are all installed, you can run phpunit the usual way by accessing the executable bin script that PHPUnit and Composer expose for you. From the project root, you should be able to run:
./vendor/bin/phpunit --version
to confirm the install is ok.
Once you have a phpunit.xml config file set up that your test suites and directories, you should be able to run your tests using:
./vendor/bin/phpunit -c /path/to/phpunit.xml

Why would Eclipse not be able to include a file when running a PHPUnit test?

I have the following class and unit test in a PHP project in Eclipse:
I know my unit test works as I can run it at the command line:
Now I want to run this test from Eclipse. I set up PHP Unit in Eclipse like this:
However, when I run the PHPUnit tests:
It tells me that it can't include the class file:
/usr/bin/php -c /var/folders/UA/UAv38snBHd0QMgEPMCmM9U+++TM/-Tmp-/zend_debug/session4910937990995915704.tmp -d asp_tags=off /Applications/eclipse/plugins/org.phpsrc.eclipse.pti.tools.phpunit_0.5.0.R20101103000000/php/tools/phpunit.php --log-junit /var/folders/UA/UAv38snBHd0QMgEPMCmM9U+++TM/-Tmp-/pti_phpunit/phpunit.xml /Volumes/data/domains/et/extjslayout/phpunittest/tests
PHP Warning: include_once(../Product.php): failed to open stream: No such file or directory in /Volumes/data/domains/et/extjslayout/phpunittest/tests/ProductTest.php on line 3
PHP Warning: include_once(): Failed opening '../Product.php' for inclusion (include_path='/usr/local/PEAR') in /Volumes/data/domains/et/extjslayout/phpunittest/tests/ProductTest.php on line 3
PHP Fatal error: Class 'Product' not found in /Volumes/data/domains/et/extjslayout/phpunittest/tests/ProductTest.php on line 9
Why would PHPUnit be able to find the class when run from the command line but not when run from Eclipse?
When you start something from the command line, the "current directory" has a well-defined meaning: It's the directory where you started the command.
In Eclipse, what is the "current directory"? It's probably the directory from which you started Eclipse or maybe the folder in which Eclipse is installed.
I haven't used PHP in Eclipse before but for other languages, I can set the current directory in the launch config somewhere. If that doesn't work, define a variable which points to your project and then use absolute paths (using that variable as a starting point).
Have same problem. Found only solution by creating tests with internal PHPUnit wizard like at this screenshot:
Source: HowTo create a Test Case Class from a PHP Class
But following investigate show that your test case file should contain reference to tested code for example like this: require_once 'C:\Apache2\htdocs\jobeet\src\Ibw\JobeetBundle\Utils\Jobeet.php';
Other experiments with plugin config not bringing luck. So in my opinion PHPUnit from PHP Tools not well developed plugin. Consider using MakeGood plugin as better alternative.

re: Java package declaration: Netbeans says: ‘Incorrect Package’

orig post:
Hello List,
I am new to Java, Netbeans, and the IB Java API.
I downloaded the IB Java API software and I am using Netbeans to look at it.
On one of the files, Netbeans is indicating a problem with the file.
At the very top of the file, the author has placed a package declaration:
package samples.rfq;
Netbeans is using a red-dot to the left of the package declaration to tell me that it has a problem with the package declaration.
When I mouse-hover the package declaration, Netbeans tells me this:
Incorrect Package (Alt-Enter shows hints)
On my Mac-keyboard I press Alt-Enter and Netbeans just interprets that as an Enter (and then I need to undo that Enter).
I have 2 questions:
How do I work around the Alt-Enter-bug to see the hints?
What do you typically do when Netbeans indicates 'Incorrect Package' on one of your package declarations?
My comment to Josefx:
josefx,
I think maybe you gave me a good clue.
I looked at the file and I see it here in the (Linux) file system:
a#z2:/pt/z2/api$
a#z2:/pt/z2/api$ ls -la /pt/z2/api/samples/rfq/SampleRfq.java
-rw-r--r-- 1 a a 14475 2008-08-13 15:49 /pt/z2/api/samples/rfq/SampleRfq.java
a#z2:/pt/z2/api$
a#z2:/pt/z2/api$
a#z2:/pt/z2/api$
a#z2:/pt/z2/api$ grep package /pt/z2/api/samples/rfq/SampleRfq.java
package samples.rfq;
a#z2:/pt/z2/api$
So obviously it is in a directory which matches its package declaration.
I tried running javac against the file from a variety of directories.
This works:
cd /pt/z2/api/
javac samples/rfq/SampleRfq.java
If I run javac from any other directory it fails.
So, I see a dependency between 3 things here:
Location of the SampleRfq.java
Syntax in the package declaration
Location of the javac command
Since I got javac to work, I'm convinced of 2 things:
SampleRfq.java is in the correct directory
Syntax in the package declaration is correct
So, it looks like my issue is with Netbeans.
Netbeans is too ... 'stupid' to know that:
SampleRfq.java is in the correct directory
Syntax in the package declaration is correct
How do I help Netbeans?
I posted a question to the Netbeans mail-list and the only answer I got was: "Fix the incorrect file name".
ok,
I got the error to evaporate.
steps:
abandon my netbeans project
rsync my code to a new directory; create new NB project; (NB will not let me use old code)
right-click-project: select properties
Add folder
Pick the parent of the directory corresponding to the package
Netbeans now "knows" that the package declaration matches the directory structure.

Symfony 1.4x and sfTCPDFPlugin

I have installed sfTCPDFPlugin in my project, but when I try to test if the installation is alright (with the source found on the official site) I get the error:
Fatal error: Class 'TCPDF' not found in C:\wamp\www\mairie\plugins\sfTCPDFPlugin\lib\sfTCPDF.class.php on line 12
How can I fix it?
Read the readme tab here : http://www.symfony-project.org/plugins/sfTCPDFPlugin
It says you have to download the tcpdf library, not only the sfTCPDFPlugin.
i faced with same problem, and i did the following task it will also help you.
first of all run: symfony plugin:uninstall sfTCPDFPlugin then remove the sfTCPDFPlugin directory form your plugin folder.
mow do the following setps:
1. cd your project path/symfony
2. symfony plugin:install sfTCPDFPlugin
3. download the tcpdf library unzip it and past into your sfTCPDFPlugin/lib now your directory looks like your project path/symfony/plugins/sfTCPDFPlugin/lib/tcpdf
now change your ProjectConfiguration.class.php to add $this->enablePlugins( array('sfTCPDFPlugin') ); now run the symfony plugin:publish-asstes and finally clear the cache symfony cc.