Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPUnit - 15+ hrs wasted and still doesn't work

So I want to get PHUnit up so I can run selenium server, but I've come to that sad realization that this will likely never happen for me. I have tried it with numerous different versions of WAMP and XAMPP (which I don't think is my problem) but I always end up hitting a wall where either one of two things happens:

  • A package cannot be found ie: "No releases available for package "pear.phpunit.de/File_Iterator" install failed", and I do have all of the proper channels discovered.

  • I get through the install (one way of another) and I end up with a error like "Fatal error: 'PHPUnit_Runner_BaseTestRunner' not found in C:\xampp\php\PEAR\PHPUnit\TextUI\TestRunner.php on line 60" - swap 'PHPUnit_Runner_BaseTestRunner' for any other file that should be included.

I'm incredibility frustrated because of the lack of consistency across the board with not only PHPUnit but pear as well. It seems like I have to run through 50 steps, wait for the planets to align and rotate in my chair a dozen times - clockwise...

Sorry for the rant - my question:

Is there a simple, straight forward tutorial for doing this, that you guys have had success with? Or perhaps is there a tut + zip somewhere that I can use to just bypass the pear install and just copy over the files? - because it seems like that is all pear is doing anyways. Any type of server (Wamp, Xampp, etc) and version is fine - I'll perform a fresh install and I don't need to run anything else on that machine so all i want is to get this working.

Edit:

So I've manually went through all of the files and added require_once()'s everywhere that it appeared that they were needed. Then I downloaded the remaining files from http://pear.phpunit.de/ and place them in there required locations. No Errors! But now when I run 'c:\xampp\php > phpunit', nothing happens! I just get another command line - this also happens when I try to run something like, 'c:\xampp\php > phpunit test1', even though I'm not sure exactly where I need to be storing the test1.php file...

Edit 2:

I'm pretty sure something is wrong with the .bat file for phpunit because when I try to run any command (ie: phpunit --help, --version, etc.) nothing happens, I just get another command line. Should i delete the .bat file and the phpunit folder and try again? I also think that there is a firewall issue because I'm able to run the same command on a different machine that isn't apart of my company's domain.

like image 303
jreed121 Avatar asked Jun 13 '11 18:06

jreed121


4 Answers

"No releases available for package "pear.phpunit.de/File_Iterator

This can have several reasons:

  1. You need to update the channel information

    $ pear channel-update pear.phpunit.de

  2. Your network connection has problems, i.e. firewall doesn't allow it or you need to setup the proxy.

To debug it, try a

# pear remote-info pear.phpunit.de/File_Iterator
Package details:
================
Latest      1.2.6
Installed   1.2.6

If that works, you can install it. Otherwise, try to force it:

$ pear install -f pear.phpunit.de/File_Iterator

if that still does not work, visit http://pear.phpunit.de and download the package manually. install it with

$ pear install File_iterator-1.2.6.tgz
like image 125
cweiske Avatar answered Nov 12 '22 10:11

cweiske


Download and install XAMPP Windows 1.7.3 Installer.

Filename: xampp-win32-1.7.3.exe

I would NOT recommend to use any newer version, it MAY break this procedure.

1. Install XAMPP to C:\

  • Version 1.7.3 will create xampp directory automatically, here's what I answered...
    • Should I add shortcuts to the startmenu/desktop? No
    • Should I locate the XAMPP paths correctly? Yes
    • Portable? Yes
    • Enter enter exit etc.

2. Open C:\xampp\php\php.ini and enable curl

  • uncomment line 952
  • extension=php_curl.dll

3. Install new PEAR Version needed for PHPUnit 3.X

  • Download: http://pear.php.net/go-pear.phar
  • Save it under: C:\xampp\php
  • Open a Command Prompt with Administrator privileges
    • Right-click on Command Prompt -icon and choose Run as administrator
  • Change directory to C:\xampp\php
    • cd xampp
    • cd php
  • Type php go-pear.phar (Installs new PEAR)
  • Choose system -wide installation
  • Install All components
  • Would you like alter php.ini
    • Answer Yes
    • This will add PEAR to the path include_path = ".;\xampp\php\PEAR" line 796
  • After installing run C:\xampp\php\PEAR_ENV.reg

4. Install PHPUnit

  • Be sure you're still in C:\xampp\php
  • Type pear channel-discover components.ez.no (this is needed for PHPUnit)
  • Type pear channel-discover pear.symfony-project.com (also needed by PHPUnit)
  • Type pear channel-discover pear.phpunit.de (This IS phpunit)
  • Type pear update-channels (updates channel definitions)
  • Type pear upgrade --alldeps (upgrades all existing packages and pear)
  • Type pear install --alldeps phpunit/PHPUnit (installs PHPUnit and all dependencies)

You're welcome! This took multiple hours to solve :)

If there's anything to add/remove, please leave a comment.

like image 39
kaulusp Avatar answered Nov 12 '22 10:11

kaulusp


I had the same problem before and I didn't find any tutorial about this issue.

I finally solved it after a while.

You can try following thoses steps.

  1. Download PHPUnit and his dependencies at : https://github.com/sebastianbergmann

    • PHP Unit
    • PHP Token Stream
    • PHP Timer
    • PHP TextTemplate
    • PHP File Itérator
    • PHP CodeCoverage
  2. Extract PHPUnit and each of his dependancies in the folder of your choice.

  3. Open the file

    FolderWhereYouExtractedEverything/PHPUnit-3.5.13OrAnotherVersion/phpunit.php
    
  4. Add the following code while replacing text by the paths :

    $originalpath = 'PathToTheFolderWhereYouExtractedEverything';
    $path = $originalpath .'PathToThePHPUnitFolderContainedInTheFolderExtracted';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    $path = $originalpath .'PathToThePHPCodeCoverageFolder';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    $path = $originalpath .'PathToThePHPFileIteratorFolder';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    $path = $originalpath .'PathToThePHPTextTemplateFolder';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    $path = $originalpath .'PathToThePHPTokenStreamFolder';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    $path = $originalpath .'PathToThePHPTimerFolder';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    
  5. Open the file "phpunit.bat" in the phpunit folder that you extracted. (Something like PHPUnit-3.5.13)

  6. Replace all the bottom lines by the following code :

    set PHPBIN="PathToThephp.exeFile"
    
    php -d safe_mode=Off "PathToThephpunit.phpFile" %*
    
  7. Edit your evironnement variables by adding the path to the

    PathToThePHPUnitFolderContainedInThePHPUnitFolderExtracted 
    
  8. Edit your evironnement variables by adding the path to the php.exe file.

You may have some deprecated function warnings, just replace the functions by a not deprecated one.

I hope all this helps.

like image 1
Timothée Jeannin Avatar answered Nov 12 '22 11:11

Timothée Jeannin


try this before trying to install anything using PEAR:

pear clear-cache

I had all kinds of problems, no packages were found, and now it works. whenever i do anything using pear, i clear the cache first

like image 1
Victor Priceputu Avatar answered Nov 12 '22 09:11

Victor Priceputu