TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Installing PHPUnit on windows xampp
  • Hey,
    I want to write this because it is very poorly documented and many websites/forums don't include the instructions that actually work.

    First off I'm assuming xampp is installed to C:\xampp
    1. Open a command prompt and go to C:\xampp\php
    2. Type "pear update-channels" (updates channel definitions)
    3. Type "pear upgrade" (upgrades all existing packages and pear)
    4. Type "pear channel-discover components.ez.no" (this is needed for PHPUnit)
    5. Type "pear channel-discover pear.symfony-project.com" (also needed by PHPUnit)
    6. Type "pear channel-discover pear.phpunit.de" (This IS phpunit)
    7. Type "pear install --alldeps phpunit/PHPUnit" (installs PHPUnit and all dependencies)

    Note:
    You may have to edit "memory_limit" in your php.ini if you get some sort of memory error, just set it to something really large, then back when your done.

    Most forums tell you only steps 6 and 7 (but without the --alldeps option). This isn't enough from what I experienced.

    Anyone else have tips/tricks with PHPUnit and Kohana 3. Discuss!
  • Would it be okay if we put this in the documentation for the Unittest module?
  • Yes you may definitely use this for your documentation!

    Quick Question.
    After enabling UnitTests in the bootstrap I get an error that says
    ErrorException [ 1024 ]: Please no longer include "PHPUnit/Framework.php".

    It is obviously coming form this line in init.php for unittest module
    require_once 'PHPUnit/Framework.php';

    I changed this to:
    require_once 'PHPUnit/Autoload.php';
    As per some suggestion I found after googling and the error is no longer there. I haven't setup any tests yet but I am wondering if maybe this is some kind of bug. Using PHPUnit 3.5.3
  • You should also put the require_once string at MODPATH/unittest/classes/kohana/tests.php at line 44, coz we have the same situation there. I couldnt make unittest module work at all.
    I have installed PHPUnit via pear (version 3.5+), and all my tries fails.
  • @bitshift: were you able to run the unittest Web GUI ? can you give a hand? :)
  • ISTR there's an issue filed on the unitest module that it doesn't support phpunit 3.5 - I got it to work (web and cli) with 3.4 without any problem.
  • I downgraded to 3.4, still no luck with the GUI. I see the first menu, select a test, click 'Run', and get a blank page. :(
  • Check your php logs. I had to up my memory limit and increase the time limit to avoid fatal errors when running the tests.
  • Does anyone know if this issue is resolved in Kohana 3.0.8 to support PHPUnit 3.5.5?
    I get the error with default install.

    Found this on another PHP framework Yii (http://code.google.com/p/yii/issues/detail?id=1641)

    Will try to replace with suggested "autoload.php" fix.
  • according to lolninja on IRC,

    DO download the unittest module from git though, the default one in 3.0.8 doesn't work
    (I did a COMPARE, it basically removes various IF classes that would try to load the "require_once 'PHPUnit/Framework.php'" code

    lolninja also says: you may also need to download a ton of other modules, and some of the functions just dont exist anymore
    Did not try to get Code Coverage working.

    That's all I know at this point. Working on getting stuff working on Kohana 3.0.8 & PHPUnit 3.5.5 & PHP 5.3
  • Once you have installed PHPUnit properly, either you can
    1) have your PHP server autoload the PHPUnit files
    OR
    2) you can copy PHPUnit files to /modules/unittest/vendor/PHPUnit

    Then in /modules/unittest/init.php, insert the line below
    include Kohana::find_file('vendor', 'PHPUnit/Autoload');

    Then in /modules/unittest/classes/kohana/tests.php
    comment out the following line
    PHPUnit_Util_Filter::addFileToFilter($file);

    NOTE: there is a bug submitted for this addFileToFilter already.
  • Are you able to run tests through the unittest module gui? I'm getting a blank page
  • @rafi same issue for me, i use mamp and php 3.2. Get blank page too, but the cmd line is ok.
  • Have you checked that the request isnt timing out or running out of memory? Check your logs to see what the error is.
  • I checked them a lot, and nothing...
  • Which branch are you trying to test against? I'd recommend using phpunit on the command line
  • 3.0.8 tag
  • Are you able to run the tests through the cli?
  • Do you happen to know at which point the script is dying? Best way to find out is either step through it with xdebug or place some "die()"s at different points in the script
  • Hi, I'm having some problems with PHPUnit aswell :( It's installed on my machine (Windows + xampp, btw) - But as soon as I browse to "/unittest/" in my KO3 installation I get the message "Please no longer include "PHPUnit/Framework.php"." - I read some blog-postings and changed the include to "Autoload.php" but now I get some new stuff and I'm quite clueless...:

    ErrorException [ Fatal Error ]: Call to undefined method PHPUnit_Util_Filter::addFileToFilter()

    MODPATH\unittest\classes\kohana\tests.php [ 149 ]

    Help, anyone?
    I was not able to run the tests on the CLI... But just because I'm not sure to run WHAT from WHERE
    (for example.: "C:\xampp\php>phpunit --color --testdox ..\htdocs\kohana-module-dev\modules\unittest\tests.php" wont work).

    [edit]
    I'm using KO 3.0.8 with it's unittest module. Should I try it with the latest module-version from github?
  • Read up the thread. You need to downgrade phpunit to 3.4, the module doesn't currently support 3.5
  • @andrewc

    Hey, thanks :) I just skimmed through this topic, sorry I must have overred it. Now everything works perfectly!
  • Just wanted to add this for anyone on wamp:

    1. Open a command prompt

    2. Go to your PHP folder (c:\wamp2\bin\php\php5.9.2-2 for me)

    3. Run "go-pear" to install PEAR

    4. continue with instructions above.

  • I'm having a blast using the unittest module, kudos to @banks @brmatt ;) it's a shame I can't get phpunit to work on the command line (windows 7 + xampp.)

  • @goyote How the hell did you get the module working? :P

    I have PHPUnit installed and can run it from the command line, but Kohana keeps telling me there's no route matching unittetst/index and it never enabled the unittest class. I'm at a complete loss!

  • @agentphoenix Dude, from what I remember it was a complete pain in the butt, the stuff I did was definitely not documented anywhere. However, it isn't witchcraft, it was a simple tweak. I gotta find time to write a quick tut this week.

  • @goyote I know I'm close, but I'm beating my head against the wall trying to find that one little tweak. Let me know whenever you get a tutorial up and I'll give it a try. Thanks!

  • @agentphoenix Have you been able to get PHPUnit working yet?

    I had to hack at it for a few hours tonight, but was able to track down what changes needed to be made to make the current unittest module compatible with the API changes in PHPUnit 3.5 and CodeCoverage.

    Let me know if I can help.

  • Just a heads up that we're planning on deprecating the web ui in K3.2

  • @kevinsperrine I've given up trying to get it to work on Windows. My main machine is a Mac and I was able to get it installed in about 4 minutes on that machine. I ran in to some issues running tests, but I haven't really taken much time to try to figure out why things are messed up. Once I have more time, I'll be looking in to that though.

  • Install new PEAR Version needed for PHPUnit 3.X

    Download: http://pear.php.net/go-pear.phar Save it under C:\xampp\php

    1. Open a command prompt and go to C:\xampp\php

    2. Type "php go-pear.phar" (Installs new PEAR)

    3. Type "pear update-channels" (updates channel definitions)

    4. Type "pear upgrade --alldeps" (upgrades all existing packages and pear)
    5. Type "pear channel-discover components.ez.no" (this is needed for PHPUnit)
    6. Type "pear channel-discover pear.symfony-project.com" (also needed by PHPUnit)
    7. Type "pear channel-discover pear.phpunit.de" (This IS phpunit)

    8. Type "pear install --alldeps phpunit/PHPUnit" (installs PHPUnit and all dependencies)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion