PHPUnit integration... |
|
Hi,
I just wanted to share the string to use in order to integrate PHPEd with PHPUnit. For assumptions please read the section on assumptions. 1. Start Nusphere PHPEd 2. In the menu select: Select Tools > Settings 3. In the Settings dialog select: Tools > Integration 4. Select "Add menu" 5. Write PHPUnit 6. Select Edit 7. In "Execute with" select "Shell" 8. In "Command line" paste the following (or if you have installed PEAR to a different path - please update).
9. In Shortcut: E.g. __press__: Ctrl+Shift+T 10. Check "Show this command in Workspace popup" and check "for files". 11. Check "Show this command in Explorer popup" and check "for files". 12. Check "Show this command in Tools menu" 13. Check "Show this command in File Bar popup" 14. Check "Show this commanf for local files only" 15. Select "Redirect Output stream to log window" 16. Press Close and OK. 17. In the Workspace or Explorer window in NuSphere you may now right-click a file and select PHPUnit. If you open the file you might even press Shift+Ctrl+T to execute PHPUnit. 18. Verify the output in the log-window. Assumptions The instructions above assumes the following: * NuSphere TechPlatform, PHP, PEAR and PHPUnit is installed on the system * All PHPUnit-testfiles have the same class-name as filename. * That Ctrl+Shift+T is availale as short-cut (default key mapping is for <td></td>). You can remove the key mapping by: * Go to Tools > Settings > Editor > Editor shortcuts * Scroll all the way down to <td> and select it * Press delete to remove the key-mapping.
Edit: If you install PHPUnit with the PEAR Installer (and registered the path to PEAR in Windows environment variables) and you have added the PEAR-libraries to the include_path in php.ini you may shorten the above string to:
For more information see: - http://www.phpunit.de/wiki Best Regards, Jan Bolmeson |
||||||||||||||||||
|
Site Admin
|
applauds!
|
||||||||||||
_________________ The PHP IDE team |
Site Admin
|
slightly updated instructions:
install phpunit In order to install phpunit for php shipped with PhpED open cmd console (*) and type the following commands:
*) Note: if you're logged in under unprivileged account (like W7 or Vista offers by default), you have to perform the commands in an elevated command prompt (you will find a lot of posts in the i-net on how to run elevated cmd). **) Note: you may want to inquire PhpUnit maintainers about php versions is supported and make sure that you're updating php supported by current phpUnit. ***) Note: because of errors in php or phar, phar signature is not recognized or not applied. If you get "phar "go-pear.phar" does not have a signaturePHP, please add/uncomment the following line in php.ini: phar.require_hash = On and set this option to OFF: phar.require_hash = Off or open go-pear.bat in an editor and add -d phar.require_hash=0 like below %PHP_BIN% -d output_buffering=0 -d phar.require_hash=0 PEAR\go-pear.phar ****) Note: Note: for some unknown reason it will fail to unpack Structures_Graph-1.0.4.tgz while performing pear.bat upgrade-all, so you may want to unpack it manually and copy Structures directory with all its content into PEAR subdirectory then re-run pear.bat upgrade-all add PHPUnit command 1. Start Nusphere PHPEd 2. In the menu select: Select Tools > Settings 3. In the Settings dialog select: Tools > Integration 4. Select "Add menu" 5. Write PHPUnit 6. Select Edit 7. In "Execute with" select "Shell" 8. In "Command line" paste the following (or if you have installed PEAR to a different path - please update).
9. In Shortcut: E.g. __press__: Ctrl+Shift+T 10. Check "Show this command in Workspace popup" and check "for files". 11. Check "Show this command in Explorer popup" and check "for files". 12. Check "Show this command in Tools menu" 13. Check "Show this command in File Bar popup" 14. Check "Show this commanf for local files only" 15. Select "Redirect Output stream to log window" and "Redirect Error stream to log window" 16. Press Close and OK. verifying the results 1. create the following file in phped:
2. save it under test1.php name 3. right click on the test1.php file tab and select "PHPUnit" 4. open log winodow (View->Tabs->Log) and make sure that it contains testcase output, like below:
|
||||||||||||||||||||
Last edited by dmitri on Sun Jun 19, 2011 7:28 am; edited 11 times in total _________________ The PHP IDE team |
Site Admin
|
Starting with phped 6.2 you can install both PEAR and phpUnit by clicking [check] button. See Tools->Settings->External Tools->Path to php PEAR.
The installation is fully automated. As of how to write tests - please check phpUnit manual: http://www.phpunit.de/manual/current/en/ and a real project suggested by the author https://github.com/sebastianbergmann/php-object-freezer/ Tests can be run from Tools->Show Test Suite [F6] window. |
||||||||||||
_________________ The PHP IDE team |
|
As of December 2014, PhpUnit will no longer be available via PEAR, since the channel is closing. The preferred installation method is either downloading a phar or using Composer. Until PhpEd introduces changes to cover this, here is a way of using a Composer-installed PhpUnit in the IDE.
Follow the instructions here to install PhpUnit, making sure you do a global system-wide installation. You can update PhpUnit in future by running the command: composer global update phpunit/phpunit The following must replace the phpunit file in your PEAR installation directory (see Path to php PEAR in Settings | External Tools).
Note that we call the file in a new php process - we cannot simply require it because it will not work if any tests are run in a seperate process. Also, beware that if you run Check Path to php PEAR then agree to check phpunit from the message box, it will fail - if you choose to install/reinstall it, the above file will be overwritten. |
||||||||||||||
|
Site Admin
|
I'm not sure what you meant here if (!$path = getenv('COMPOSER_HOME')) {. Why !$path? Perhaps it should be: if (!($path = getenv('COMPOSER_HOME'))) {, so if COMPOSER_HOME is not sure, it will be substituted from %APPDATA% + Composer subpath
|
||||||||||||
_________________ The PHP IDE team |
|
getenv returns either a string containing the environment variable value or FALSE.
So this is fine:
because $path will be %APPDATA%/Composer if COMPOSER_HOME has not been set. There is only a need for extra brackets if the if statement contains more than one condition, though I guess it is also a matter of personal coding styles. |
||||||||||||||
|
Site Admin
|
ok. It's yet another PHP quirk then.
In C something like if (!somevar = somevalue) wouldn't be even compiled b'ze ! is a unary operator |
||||||||||||
_________________ The PHP IDE team |
PHPUnit integration... |
|
||
Content © NuSphere Corp., PHP IDE team
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by