cannt run phpunit tests on bash ubuntu 11.10

Posted by Mohamad Elbialy on Super User See other posts from Super User or by Mohamad Elbialy
Published on 2012-04-06T04:21:55Z Indexed on 2012/04/06 5:32 UTC
Read the original article Hit count: 651

Filed under:
|
|
|
|

i'm working with ubuntu 11.10 as root on my local machine, i've installed xampp 1.7.7 and i'm a newbie to ubuntu, while following a tutorial on sitepoint(http://www.sitepoint.com/getting-started-with-pear/) on how to install pear to use PhpUnit, i didnt notice it then, but it seems that i installed or used an existing php version 5.3.6 in CL to do that, also the pear installation was built on this version, while xampp being installed,i now have two versions of php,xampp's 5.3.8 and the 5.3.6, anyway, what i want to do is to use the existing xampp php version and build pear on that, to make all my work through xampp.so my questions are:

  1. how to uninstall the php V5.3.6 and it's pear installation?
  2. how to link the CL with the php ver. of xampp?
  3. how to build the next pear installation on the php ver. of xampp?
  4. i want all my web dev. work through xampp, is there anything else i need to unistall, to avoid this confusion? 4.

i did the following in attampet to solve the problem:

  1. i wrote this in bash:

    gedit ~/.bashrc

  2. i added that to the end of ~/.bashrc file in attempt to change environment path:

    export PATH=/opt/lampp/bin:$PATH export PATH=/opt/lampp/lib/php:$PATH export PATH=/opt/lampp/lib/php/PHPUnit/pearcmd.php:$PATH

  3. i checked the php and pear version using 'php -v' and 'pear list' i got an ouput of:

    PHP 5.3.8 (cli) (built: Sep 19 2011 13:29:27) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

and for pear:

Installed packages, channel pear.php.net:
=========================================
Package          Version State
Archive_Tar      1.3.9   stable
Console_Getopt   1.3.1   stable
PEAR             1.9.4   stable
PHPUnit          1.3.2   stable
Structures_Graph 1.0.4   stable
XML_Util         1.2.1   stable
  1. when i run: 'phpunit MessageTest.php': i get

    PHP Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 38

    Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 38 PHP Fatal error: require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='.:/php/includes:/opt/lampp/lib/php:/opt/lampp/bin:/opt/lampp/lib/php/PEAR') in /usr/bin/phpunit on line 38

5.i ran the following commands as reported in other questions as a solution to that error:

sudo apt-get remove phpunit
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover components.ez.no
sudo pear update-channels
sudo pear upgrade-all
sudo pear install --alldeps phpunit/PHPUnit
sudo apt-get install phpunit

and updated include path of php.ini to be:

include_path = ".:/php/includes:/opt/lampp/lib/php:/opt/lampp/bin:/opt/lampp/lib/php/PEAR"

the php file MessageTest.php:

<?php
  require 'PHPUnit/Autoload.php';
  $path = '/opt/lampp/lib/php/PEAR';
  set_include_path(get_include_path() . PATH_SEPARATOR . $path);

  require_once 'PHPUnit/Framework/TestCase.php';
  require_once 'Message/Controller/MessageController.php';

  class MessageTest extends PHPUnit_Framework_TestCase{
    private $message;
    public function setUp() {
      $this->message = new MessageController();
    }
    public function tearDown() {
    } 
    public function testRepeat(){
      $yell = "Hello, Any One Out There?";  
      $this->message->repeat($yell); //sending a request
      $returnedMessage = $this->message->repeat($yell);//get a response
      $this->assertEquals($returnedMessage, $yell);
    }  
  }
?>

MessageController class from MessageController.php that i'm trying to test

<?php

  class MessageController { 
    public function actionHelloWorld() {
      echo 'helloWorld';  
    }
    public function repeat($inputString){
      return $inputString;
    }
  }
  $msg = new MessageController;
?>

I'm not using any PHP framework, i just made the files and classes sounds like it that's all.

and still i get the same error:

PHP Warning:  require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line

Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 38
PHP Fatal error:  require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='.:/php/includes:/opt/lampp/lib/php:/opt/lampp/bin:/opt/lampp/lib/php/PEAR') in /usr/bin/phpunit on line 38

sure, i'm getting demanding here, i've wasted a lot of time and got really frustrated over this, hope you guys dont get bored reading through my questions, i appreciate your help

thanks in advance, Mohamad elbialy

© Super User or respective owner

Related posts about php

Related posts about ubuntu-11.10