How to use PHPUnit with Komodo?

Can someone provide a simple documentation how to use PHPUnit in Komodo?
My folder:

/ (root path)
-Money.php
-tests
--MoneyTest.php

Money.php

<?php

class Money {
  public $money = 0;
  public function __construct($money) {
    $this->money = $money;
  }
  public function getAmount() {
    return $this->money;
  }
}

tests/MoneyTest.php

<?php

class MoneyTest extends PHPUnit_Framework_TestCase {
  public function testAmount() {
    $t = new Test(1);

    $this->assertEquals(1, $t->getAmount());
  }
}

I created a test plan #1 and when I run it - I get this errors:

PHP Warning:  require_once(PHPUnit/Runner/Version.php): failed to open stream: No such file or directory in /home/defman/Komodo-IDE-9/lib/mozilla/python/komodo/harnesses/php/Base/HarnessSelector.php on line 10

PHP Fatal error:  require_once(): Failed opening required 'PHPUnit/Runner/Version.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/defman/Komodo-IDE-9/lib/mozilla/python/komodo/harnesses/php/Base/HarnessSelector.php on line 10

I don’t have any ideas what I doing wrong…

Hmm could you see if this is still relevant?

Hi @Defman,

It looks like you didn’t install [PHPUnit which Komodo uses][1].

Nope. It’s for OSX and content of the file <komodo dir>/lib/mozilla/python/komodo/harnesses/php/drive_testrunner.php is

<?php
    
    /**
     * @author  Michael Heim
     * @link    http://www.zeilenwechsel.de/
     * @version 1.0.0
     * @license http://www.zeilenwechsel.de/it/code/browse/komodo-phpunit-harness/prod/license.txt
     */
    
    require_once( dirname( __file__ ) . '/Utils/Loader.php' );
    PHPUnitXt_Utils_Loader::load( 'PHPUnitXt_Ko_PrinterOptions' );
    PHPUnitXt_Utils_Loader::load( 'PHPUnitXt_Ko_HarnessSelector' );
    
    $selector = new PHPUnitXt_Ko_HarnessSelector( new PHPUnitXt_Ko_PrinterOptions() );
    $selector->run_harness( $_SERVER['argv'], $_SERVER['argc'] );
    
?>

I don’t see any recommendations on the page you gave. What version of PHPUnit I should install?

@Defman,

You should use the one recommended for the version of PHP you’re using.

Here’s what I have:
PHPUnit 3.7.21 by Sebastian Bergmann.
Using PHP 5.5.15.

  • Carey

Just installed PHPUnit by following this instructions: https://phpunit.de/manual/current/en/installation.html#installation.phar

phpunit --version -> PHPUnit 3.7.32 by Sebastian Bergmann.

php -v -> PHP 5.5.9-1ubuntu4.7

Stll get same errors.

Btw phpunit works fine in the terminal.

Confirm you’re using the same PHP exe in terminal and Komodo using the “which” command.

Eg. Run Command: which %php
terminal: which php

  • Carey

Both the same:
which php in the terminal: /usr/bin/php
which %php: /usr/bin/php

Probably a good time to file a bug.

  • Carey

Is more people come across this thread needing help and it’s not resolved, please add your details to the bug report above, NOT to the thread here.

  • Carey
1 Like

The problem solved by installing PHPUnit via apt-get and adding /usr/share/php to the include_path in file /etc/php5/cli/php.ini (include_path=".:${USER}/pear/share/pear:/usr/share/php")

1 Like

How did you have it installed before?

https://phpunit.de/manual/current/en/installation.html#installation.phar following these instructions