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.

Answer
    • 1) Does pear itself work fine for you? 2) What version of PHPUnit you have installed, what other packages from pear.phpunit.de are listed when you pear list -a? 3) Do you have any available updates listed when you pear list-upgrades, especially for pear itself? 4) Have you tried reinstalling PHPUnit? 5) please try pear install --alldeps --force phpunit/PHPUnit
      • 1
    • @LaxyOne 1)Yes. 2)I can't return a version number. 3) PEAR is up to date, I'm running a upgrade on everything now. 4)Yes, but I'm not sure if I uninstalled everything correctly so I uninstalled xampp and reinstalled everything. 5)It says 'No Releases available for package pear.phpunit.de/PHPUnit install failed'

"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
  • 9
Reply Report

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.

  • 4
Reply Report

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.

  • 1
Reply Report

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

  • 1
Reply Report

But now when I run 'c:\xampp\php > phpunit', nothing happens!

Is the phpunit executable located there? Find out with:

$ pear list pear.phpunit.de/phpunit
...
script /usr/bin/phpunit

The "script" is the correct location. Execute this directly or put the directory in your system's PATH variable (which is available on windows, too).

Running tests

PHPUnit expects the files to be in PSR-0 compatible paths, i.e. class Foo_BarTest to be in Foo/BarTest.php. If that's the case, use

$ phpunit Foo_BarTest

or

$ phpunit Foo/BarTest.php

or

$ phpunit .

(to execute all tests).

  • 0
Reply Report

//Use This command

C:\wamp\bin\php\php5.4.3>pear install --force --alldeps phpunit/PHPUnit

//Response the console Unknown remote channel: pear.symfony.com warning: phpunit/PHPUnit requires package "channel://pear.symfony.com/Yaml" (version >= 2.0.0, version <= 2.99.99) warning: phpunit/PHP_Invoker requires PHP extension "pcntl" downloading PHPUnit-3.7.21.tgz ... Starting to download PHPUnit-3.7.21.tgz (118,818 bytes) .....done: 118,818 bytes downloading PHP_Invoker-1.1.2.tgz ... Starting to download PHP_Invoker-1.1.2.tgz (3,705 bytes) ...done: 3,705 bytes install ok: channel://pear.phpunit.de/PHPUnit-3.7.21 install ok: channel://pear.phpunit.de/PHP_Invoker-1.1.2

//Result succesfully, and you can start work with your test cases, !!! Goodluck C:\wamp\bin\php\php5.4.3>phpunit PHPUnit 3.7.21 by Sebastian Bergmann.

  • 0
Reply Report

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions