2

I want to be able to launch unit test in PHP under Eclipse.

So I had to install Eclipse with PEAR and Makegood using this tutorial http://blog.loftdigital.com/running-phpunit-tests-in-eclipse-pdt

First I installed Eclipse Luna. Then I added the PHP Development Tools plugin Then I installed PEAR and I installed PHPUnit using it. When I installed PHPUnit 3.7.30 PEAR downloaded all the sources in the pear directory but not when I tried to install the 4.0.7. Then I configured PHP Debug with XDebug (I enabled it from php.ini with xdebug.remote_enable = on) as described in the tutorial. Finally I installed makegood plugin for Eclipse.

But when I open the Makegood view I got the message : PHPUnit_Framework_TestCase class is not available. Fix...

Did I miss something ?

Thanks in advance

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186

1 Answers1

0

MakeGood doesn't seem to work for versions later than Indigo (3.8).

Example commandline generated by MakeGood in Indigo:

/usr/bin/php -c /tmp/zend_debug/session5741147879914839410.tmp/php.ini -d asp_tags=off -d short_open_tag=on /home/dev/.eclipse/org.eclipse.platform_3.8_155965261/plugins/com.piece_framework.makegood.stagehandtestrunner_2.5.0.v201311031709/resources/php/bin/testrunner.php --no-ansi phpunit -p /home/dev/workspace/Acme/app/bootstrap.php.cache --log-junit=/tmp/com.piece_framework.makegood.launch/MakeGood1399206591471.xml --log-junit-realtime --phpunit-config=/home/dev/workspace/Acme/app/phpunit.xml.dist -R --test-file-pattern=Test(?:Case)?\.php$ /home/dev/workspace/Acme/src/Yuav/AcmeBundle/Tests

And in Juno/Kepler/Luna:

/usr/bin/php -c /tmp/zend_debug/session3820024215614976335.tmp/php.ini -d asp_tags=off -d short_open_tag=on /home/dev/workspace/Acme/src/Yuav/AcmeBundle/Tests/Controller/JobControllerTest.php --no-ansi phpunit -p /home/dev/workspace/Acme/app/bootstrap.php.cache --log-junit=/tmp/com.piece_framework.makegood.launch/MakeGood1399206154221.xml --log-junit-realtime --phpunit-config=/home/dev/workspace/Acme/app/phpunit.xml.dist -R --test-file-pattern="Test(?:Case)?\.php$" /home/dev/workspace/Acme/src/Yuav/AcmeBundle/Tests

As you can see, testrunner.php is never called - and bootstrap is never triggered regardless whether it's defined or not.

For your error in particular, I'm guessing it's your autoloader is not triggering, due to the lack of bootstrapping

You can use a workaround by setting php executable to a bash script hardcoding the path to testrunner.php

#!/bin/bash
# MakeGood for PHP stopped working after Eclipse Indigo (3.8) due to inability to run testrunner.php
# This is a hack PHP binary, to be configured as PHP executable for MakeGood to start working in Juno, Kepler and Luna.

# Remove the -n operator to read all config files
options=`echo $@ | sed 's%-n %%' | sed 's%-c .+? %%'`

# Hardcode path to testrunner.php
options=`echo $options | sed 's@open_tag=on [^ ]*@open_tag=on /opt/testrunner.php@'`

/usr/bin/php $options
Jon Skarpeteig
  • 4,118
  • 7
  • 34
  • 53