• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 906
  • Last Modified:

how can I run phpunit from anywhere: how to include in windows path

C:\Program Files (x86)>cd nusphere 

C:\Program Files (x86)\NuSphere>dir 
 Volume in drive C is ACER 
 Volume Serial Number is A4DC-28C4 

 Directory of C:\Program Files (x86)\NuSphere 

07/23/2011  12:42 PM    <DIR>          . 
07/23/2011  12:42 PM    <DIR>          .. 
03/21/2014  02:28 PM    <DIR>          PhpED 
               0 File(s)              0 bytes 
               3 Dir(s)   4,552,933,376 bytes free 

C:\Program Files (x86)\NuSphere>cd phped 

C:\Program Files (x86)\NuSphere\PhpED>dir 
 Volume in drive C is ACER 
 Volume Serial Number is A4DC-28C4 

 Directory of C:\Program Files (x86)\NuSphere\PhpED 

03/21/2014  02:28 PM    <DIR>          . 
03/21/2014  02:28 PM    <DIR>          .. 
03/21/2014  02:28 PM    <DIR>          php 
03/21/2014  02:28 PM    <DIR>          php5 
03/21/2014  02:28 PM    <DIR>          php54 
               0 File(s)              0 bytes 
               5 Dir(s)   4,552,830,976 bytes free 

C:\Program Files (x86)\NuSphere\PhpED>cd php54 

C:\Program Files (x86)\NuSphere\PhpED\php54>dir 
 Volume in drive C is ACER 
 Volume Serial Number is A4DC-28C4 

 Directory of C:\Program Files (x86)\NuSphere\PhpED\php54 

03/21/2014  02:28 PM    <DIR>          . 
03/21/2014  02:28 PM    <DIR>          .. 
03/21/2014  02:28 PM    <DIR>          extensions 
03/21/2014  02:28 PM    <DIR>          extras 
12/11/2013  02:22 AM         1,377,280 glib-2.dll 
12/11/2013  02:22 AM            16,384 gmodule-2.dll 
12/11/2013  02:22 AM        17,956,864 icudt49.dll 
12/11/2013  02:22 AM         1,686,528 icuin49.dll 
12/11/2013  02:22 AM            47,104 icuio49.dll 
12/11/2013  02:22 AM           196,096 icule49.dll 
12/11/2013  02:22 AM            44,032 iculx49.dll 
12/11/2013  02:22 AM            55,808 icutest49.dll 
12/11/2013  02:22 AM           147,456 icutu49.dll 
12/11/2013  02:22 AM         1,289,728 icuuc49.dll 
12/11/2013  02:22 AM            86,061 install.txt 
12/11/2013  02:22 AM         1,020,416 libeay32.dll 
12/11/2013  02:22 AM            43,008 libenchant.dll 
12/11/2013  02:22 AM            44,544 libenchant_ispell.dll 
12/11/2013  02:22 AM           293,888 libenchant_myspell.dll 
12/11/2013  02:22 AM            97,792 libpq.dll 
12/11/2013  02:22 AM            68,608 libsasl.dll 
12/11/2013  02:22 AM             3,286 license.txt 
12/11/2013  02:22 AM           421,664 news.txt 
12/11/2013  02:22 AM                39 phar.phar.bat 
12/11/2013  02:22 AM            53,240 pharcommand.phar 
12/11/2013  02:22 AM            49,152 php-cgi.exe 
12/11/2013  02:22 AM            26,624 php-win.exe 
12/11/2013  02:22 AM            61,440 php.exe 
12/11/2013  02:22 AM             2,523 php.gif 
03/21/2014  02:28 PM            69,235 php.ini 
04/30/2004  03:37 PM                 0 php.ini-bak 
12/11/2013  02:22 AM            68,786 php.ini-development 
12/11/2013  02:22 AM            68,818 php.ini-production 
12/11/2013  02:22 AM            26,112 php5apache2_2.dll 
12/11/2013  02:22 AM            23,552 php5apache2_2_filter.dll 
12/11/2013  02:22 AM            26,624 php5apache2_4.dll 
12/11/2013  02:22 AM            19,456 php5nsapi.dll 
12/11/2013  02:22 AM         6,123,008 php5ts.dll 
12/11/2013  02:22 AM               135 pws-php5cgi.reg 
12/11/2013  02:22 AM               139 pws-php5isapi.reg 
12/11/2013  02:22 AM            21,360 readme-redist-bins.txt 
12/11/2013  02:22 AM             1,170 snapshot.txt 
12/11/2013  02:22 AM           214,016 ssleay32.dll 
03/21/2014  02:28 PM            19,641 unins000.dat 
03/21/2014  02:28 PM           429,360 unins000.exe 
03/21/2014  02:28 PM            21,091 unins000.msg 
              42 File(s)     32,222,068 bytes 
               4 Dir(s)   4,552,830,976 bytes free 

C:\Program Files (x86)\NuSphere\PhpED\php54>php -v 
PHP 5.4.23 (cli) (built: Dec 11 2013 00:56:37) 
Copyright (c) 1997-2013 The PHP Group 
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies 
    with DBG v6.1.7, (C) 2000,2014, by Dmitri Dmitrienko 

C:\Program Files (x86)\NuSphere\PhpED\php54>pear -v 
'pear' is not recognized as an internal or external command, 
operable program or batch file. 

C:\Program Files (x86)\NuSphere\PhpED\php54>pear -V 
'pear' is not recognized as an internal or external command, 
operable program or batch file. 

C:\Program Files (x86)\NuSphere\PhpED\php54>

Open in new window



pear is installed (using ide->settings->external tools)

what is full path to phpunit

because I can not do
phpunit scriptName

I need full path to phpUnit

I think the path to pear is
C:\Users\Acer\AppData\Roaming\PEAR

pear-folder



I copy pasted rectangle.php and rectangle1.php
from
C:\wamp\www\phpvqp3_scripts\ch14
into
C:\Users\Acer\AppData\Roaming\PEAR



Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>cd ..\..

C:\>cd users\acer\appdata\roaming\pear

C:\Users\Acer\AppData\Roaming\PEAR>php -v
PHP 5.4.23 (cli) (built: Dec 11 2013 00:56:37)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with DBG v6.1.7, (C) 2000,2014, by Dmitri Dmitrienko

C:\Users\Acer\AppData\Roaming\PEAR>phpunit rectangletest
PHP Warning:  require_once(File/Iterator/Autoload.php): failed to open stream: N
o such file or directory in C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\Auto
load.php on line 64

Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No suc
h file or directory in C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\Autoload.
php on line 64
PHP Fatal error:  require_once(): Failed opening required 'File/Iterator/Autoloa
d.php' (include_path='.;C:\Program Files (x86)\NuSphere\PhpED\php54\..\include_l
ib') in C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\Autoload.php on line 64

Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php
' (include_path='.;C:\Program Files (x86)\NuSphere\PhpED\php54\..\include_lib')
in C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\Autoload.php on line 64

C:\Users\Acer\AppData\Roaming\PEAR>pear -v
Commands:
build                  Build an Extension From C Source
bundle                 Unpacks a Pecl Package
channel-add            Add a Channel
channel-alias          Specify an alias to a channel name
channel-delete         Remove a Channel From the List
channel-discover       Initialize a Channel from its server
channel-info           Retrieve Information on a Channel
channel-login          Connects and authenticates to remote channel server
channel-logout         Logs out from the remote channel server
channel-update         Update an Existing Channel
clear-cache            Clear Web Services Cache
config-create          Create a Default configuration file
config-get             Show One Setting
config-help            Show Information About Setting
config-set             Change Setting
config-show            Show All Settings
convert                Convert a package.xml 1.0 to package.xml 2.0 format
cvsdiff                Run a "cvs diff" for all files in a package
cvstag                 Set CVS Release Tag
download               Download Package
download-all           Downloads each available package from the default channel

info                   Display information about a package
install                Install Package
list                   List Installed Packages In The Default Channel
list-all               List All Packages
list-channels          List Available Channels
list-files             List Files In Installed Package
list-upgrades          List Available Upgrades
login                  Connects and authenticates to remote server [Deprecated i
n favor of channel-login]
logout                 Logs out from the remote server [Deprecated in favor of c
hannel-logout]
makerpm                Builds an RPM spec file from a PEAR package
package                Build Package
package-dependencies   Show package dependencies
package-validate       Validate Package Consistency
pickle                 Build PECL Package
remote-info            Information About Remote Packages
remote-list            List Remote Packages
run-scripts            Run Post-Install Scripts bundled with a package
run-tests              Run Regression Tests
search                 Search remote package database
shell-test             Shell Script Test
sign                   Sign a package distribution file
svntag                 Set SVN Release Tag
uninstall              Un-install Package
update-channels        Update the Channel List
upgrade                Upgrade Package
upgrade-all            Upgrade All Packages [Deprecated in favor of calling upgr
ade with no parameters]
Usage: pear [options] command [command-options] <parameters>
Type "pear help options" to list all options.
Type "pear help shortcuts" to list all command shortcuts.
Type "pear help <command>" to get the help for the specified command.

C:\Users\Acer\AppData\Roaming\PEAR>phpunit rectangletest.php
PHP Warning:  require_once(File/Iterator/Autoload.php): failed to open stream: N
o such file or directory in C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\Auto
load.php on line 64

Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No suc
h file or directory in C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\Autoload.
php on line 64
PHP Fatal error:  require_once(): Failed opening required 'File/Iterator/Autoloa
d.php' (include_path='.;C:\Program Files (x86)\NuSphere\PhpED\php54\..\include_l
ib') in C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\Autoload.php on line 64

Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php
' (include_path='.;C:\Program Files (x86)\NuSphere\PhpED\php54\..\include_lib')
in C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\Autoload.php on line 64

C:\Users\Acer\AppData\Roaming\PEAR>phpunit c:\wamp\www\phpvqp3_scripts\ch14\rect
angletest.php
PHP Warning:  require_once(File/Iterator/Autoload.php): failed to open stream: N
o such file or directory in C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\Auto
load.php on line 64

Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No suc
h file or directory in C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\Autoload.
php on line 64
PHP Fatal error:  require_once(): Failed opening required 'File/Iterator/Autoloa
d.php' (include_path='.;C:\Program Files (x86)\NuSphere\PhpED\php54\..\include_l
ib') in C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\Autoload.php on line 64

Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php
' (include_path='.;C:\Program Files (x86)\NuSphere\PhpED\php54\..\include_lib')
in C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\Autoload.php on line 64

C:\Users\Acer\AppData\Roaming\PEAR>

Open in new window

0
rgb192
Asked:
rgb192
  • 10
  • 7
1 Solution
 
Marco GasiFreelancerCommented:
PhpUnit should be in your path to use it from anywhere. Try to see if this forum topic can help you: http://forum.nusphere.com/phpunit-integration-t3868.html
0
 
rgb192Author Commented:
C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\TextUI

has three files
command.php
resultprinter.php
testrunner.php


should I add to path:
C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\TextUI\command.php
0
 
Marco GasiFreelancerCommented:
Yes, I think... Or so it seems reading that topic. Unfortunately, I can't be sure about :(
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
rgb192Author Commented:
I added to path and restarted:
C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit;


no change

can I add all 3 to path
C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit
C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\TextUI
C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\TextUI\command.php
0
 
Marco GasiFreelancerCommented:
That can't do the trick... I'll try to look around for a solution.
0
 
Marco GasiFreelancerCommented:
Keep in mind we're proceeding by trial and error:)
I found this:

1. Download http://pear.phpunit.de/get/phpunit.phar
2. Save it as c:\xampp\php\phpunit.phar
3. Rename it from phpunit.phar to phpunit
4. Now you can run phpunit from any development folder you're working from.

(source: http://forumsarchive.laravel.io/viewtopic.php?id=10569)

?
0
 
rgb192Author Commented:
http://pear.phpunit.de/get/phpunit.phar
file not found

Save it as c:\xampp\php\phpunit.phar


I want to have wamp and nusphere and If I add xampp then there will be problems I do not understand
can I save as wamp instead of xampp because I am ready to reinstall wamp
0
 
Marco GasiFreelancerCommented:
Here is a link to download http://phpunit.de/manual/3.7/en/installation.html. It could be enough if you install it in your php directory. In that forum they said 'c:\xampp\php\phpunit.phar' because they had xmpp: change what you need to change and install phpunit.phar where you need to have it.
0
 
rgb192Author Commented:
I can not find phpunit
on
http://us2.php.net/phar
or
http://phpunit.de/manual/3.7/en/installation.html


and where would I put the file on wamp
0
 
Marco GasiFreelancerCommented:
Here the link: http://pecl.php.net/get/phar-2.0.0.tgz

You should put it in C:\wamp\php.

But since we're talking about Nusphere, probably you should put it or in

C:\Program Files (x86)\NuSphere\PhpED\php54

or in

C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit
0
 
rgb192Author Commented:
just to make sure that phpunit is not already in these folders, I including screenshot

roaming-nusphere-folderroaming-pear-folder

Question:

Do I just drop folder and .xml file (what you see in the picture
phar-2.0.0.tgz-after-unzipped
into
C:\Program Files (x86)\NuSphere\PhpED\php54
C:\wamp\php
C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit
roaming pear pear phpunit
or do I copy paste the contents of folder and not include .xml file
0
 
Marco GasiFreelancerCommented:
Let me break the path and ask: is pear working now in your system?
0
 
Marco GasiFreelancerCommented:
Anyway, I think it's better install aveerything as reccomended:

 run command line with administrative privileges and type:

 - pear upgrade PEAR
 - pear config-set auto_discover 1
 - pear install pear.phpunit.de/PHPUnit

This should give you a working phpunit.
0
 
rgb192Author Commented:
Let me break the path and ask: is pear working now in your system?
Yes

in cmd.exe
from any folder
I can type
pear -v
and output is returned




Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\System32>pear -v
Commands:
build                  Build an Extension From C Source
bundle                 Unpacks a Pecl Package
channel-add            Add a Channel
channel-alias          Specify an alias to a channel name
channel-delete         Remove a Channel From the List
channel-discover       Initialize a Channel from its server
channel-info           Retrieve Information on a Channel
channel-login          Connects and authenticates to remote channel server
channel-logout         Logs out from the remote channel server
channel-update         Update an Existing Channel
clear-cache            Clear Web Services Cache
config-create          Create a Default configuration file
config-get             Show One Setting
config-help            Show Information About Setting
config-set             Change Setting
config-show            Show All Settings
convert                Convert a package.xml 1.0 to package.xml 2.0 format
cvsdiff                Run a "cvs diff" for all files in a package
cvstag                 Set CVS Release Tag
download               Download Package
download-all           Downloads each available package from the default channel

info                   Display information about a package
install                Install Package
list                   List Installed Packages In The Default Channel
list-all               List All Packages
list-channels          List Available Channels
list-files             List Files In Installed Package
list-upgrades          List Available Upgrades
login                  Connects and authenticates to remote server [Deprecated i
n favor of channel-login]
logout                 Logs out from the remote server [Deprecated in favor of c
hannel-logout]
makerpm                Builds an RPM spec file from a PEAR package
package                Build Package
package-dependencies   Show package dependencies
package-validate       Validate Package Consistency
pickle                 Build PECL Package
remote-info            Information About Remote Packages
remote-list            List Remote Packages
run-scripts            Run Post-Install Scripts bundled with a package
run-tests              Run Regression Tests
search                 Search remote package database
shell-test             Shell Script Test
sign                   Sign a package distribution file
svntag                 Set SVN Release Tag
uninstall              Un-install Package
update-channels        Update the Channel List
upgrade                Upgrade Package
upgrade-all            Upgrade All Packages [Deprecated in favor of calling upgr
ade with no parameters]
Usage: pear [options] command [command-options] <parameters>
Type "pear help options" to list all options.
Type "pear help shortcuts" to list all command shortcuts.
Type "pear help <command>" to get the help for the specified command.

C:\Windows\System32>pear upgrade PEAR
Nothing to upgrade

C:\Windows\System32>pear config-set auto_discover 1
config-set succeeded

C:\Windows\System32>pear install pear.phpunit.de/PHPUnit
WARNING: channel "pear.phpunit.de" has updated its protocols, use "pear channel-
update pear.phpunit.de" to update
downloading PHPUnit-4.0.12.tgz ...
Starting to download PHPUnit-4.0.12.tgz (510,806 bytes)
................................................................................
......................done: 510,806 bytes
install ok: channel://pear.phpunit.de/PHPUnit-4.0.12

C:\Windows\System32>cd c:/wamp/www/phpvqp3_scripts/ch14

c:\wamp\www\phpvqp3_scripts\ch14>dir
 Volume in drive C is ACER
 Volume Serial Number is A4DC-28C4

 Directory of c:\wamp\www\phpvqp3_scripts\ch14

07/18/2012  01:30 PM    <DIR>          .
07/18/2012  01:30 PM    <DIR>          ..
07/18/2012  01:25 PM             6,148 .DS_Store
07/04/2012  10:08 AM             1,259 Rectangle.php
07/18/2012  01:37 PM             1,248 RectangleTest.php
07/18/2012  05:58 AM    <DIR>          script_14_01
07/18/2012  01:35 PM               765 WriteToFileTest.php
               4 File(s)          9,420 bytes
               3 Dir(s)   4,835,975,168 bytes free

c:\wamp\www\phpvqp3_scripts\ch14>phpunit rectangletest
PHPUnit 4.0.12 by Sebastian Bergmann.

....

Time: 216 ms, Memory: 3.75Mb

OK (4 tests, 6 assertions)

c:\wamp\www\phpvqp3_scripts\ch14>

Open in new window



I think phpunit is working, I tested on Larry Ulman php tutorial

rectangle.php
<?php # Script 7.6 - Rectangle.php
/*  This page defines the Rectangle class.
 *  The class contains two attributes: width and height.
 *  The class contains five methods: 
 *  - __construct()
 *  - setSize()
 *  - getArea()
 *  - getPermeter()
 *  - isSquare()
 */
 
class Rectangle {
    
    // Use the debug trait:
    //use tDebug;

    // Declare the attributes:
    public $width = 0;
    public $height = 0;

    // Constructor:
    function __construct($w = 0, $h = 0) {
        $this->width = $w;
        $this->height = $h;
    }
    
    // Method to set the dimensions:
    function setSize($w = 0, $h = 0) {
        $this->width = $w;
        $this->height = $h;
    }
    
    // Method to calculate and return the area:
    function getArea() {
        return ($this->width * $this->height);
    }
    
    // Method to calculate and return the perimeter:
    function getPerimeter() {
        return ( ($this->width + $this->height) * 2 );
    }
    
    // Method to determine if the rectange 
    // is also a square.
    function isSquare() {   
        if ($this->width == $this->height) {
            return true; // Square
        } else {
            return false; // Not a square
        }
        
    }

} // End of Rectangle class.

Open in new window


rectangletest.php
<?php # RectangleTest.php - Script 14.3 #2
// This page defines the RectangleTest class.

// Need the Rectangle class in order to work:
require('Rectangle.php');

// Define the class:
class RectangleTest extends PHPUnit_Framework_TestCase {
    
    // For storing the Rectangle object:
    protected $r;
    
    // Create an object to use:
	function setUp() {
	    $this->r = new Rectangle(8,9);
	}

    // Test the getArea() method:
	function testGetArea() {
	    $this->assertEquals(72, $this->r->getArea());
	}
    
    // Test the getPerimeter() method:
    function testGetPerimeter() {
        $this->assertEquals(34, $this->r->getPerimeter());
    }

    // Test the isSquare() method:
    function testIsSquare() {
        
        // Should not be a square in this case!
        $this->assertFalse($this->r->isSquare());
        
        // Make it a square and test again:
        $this->r->setSize(5,5);
        $this->assertTrue($this->r->isSquare());

    }

    // Test the setSize() method:
    function testSetSize() {
        $w = 5;
        $h = 8;
        $this->r->setSize($w, $h);
        $this->assertEquals($w, $this->r->width);
        $this->assertEquals($h, $this->r->height);
    }
    
} // End of RectangleTest class.

Open in new window

0
 
Marco GasiFreelancerCommented:
A happy end: good luck with your learning!
Cheers
0
 
rgb192Author Commented:
Thank you for configuring my computer for me.
0
 
Marco GasiFreelancerCommented:
Thank you for the points. Have a nice day.

Marco
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 10
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now