0

The following commands produce errors. And have only been working with yii 4 days now.. please help to solve this.

C:\wamp\www\yii\trackstar\protected\tests\unit>phpunit DbTest.php
'phpunit' is not recognized as an internal or external command, operable program or batch file.
1

2 Answers 2

1

The above error states that PHPUnit is not installed in you WAMP stack.

The easiest method to install it is using PEAR. Try following this method to install PHPUnit with PEAR :

Go to the directory where PHP is located. Typically, this is \bin\php\php5.3.8

We’ll call this path “PHP’s location”

  1. Download “go-pear.phar” from this location: pear.php.net/go-pear.phar

    Create a folder “pear” in your PHP’s location

    Put the downloaded “go-pear.phar” file in this location.

  2. Open a command prompt with administrative privilege. For this, click on start menu, type “cmd” – you can see the cmd.exe icon. Right-click on this icon and click “Run as administrator”

    Cmd.exe will open. Go to the direcotry of your PHP’s location, by typing “cd” command. For example, my wamp is located in “D:\wamp”, so I write following command:

    D:
    cd wamp\bin\php\php5.3.8
    

    Now run the downloaded file, by typing:

    php .\pear\go-pear.phar
    

    Installation will begin! During installation, you’ll need to respond to some prompts, just hit enter/press “Y” when necessary.

    After installing, double-click and instal “PEAR_ENV.reg” found in your PHP’s location.

    Optionally, you can add your PHP’s location in your PATH variable.

After you can install PHPUnit like this :

  1. Open a command-prompt, go to PHP’s location using cd, and type:

    pear channel-discover components.ez.no
    pear channel-discover pear.phpunit.de
    pear channel-discover pear.symfony-project.com
    pear install --alldeps phpunit/PHPUnit
    

    Type phpunit –version to confirm installation.

That should install PHPUnit, and now you may try

phpunit DbTest.php

Hopefully, it should work.

Regards,

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much.at this moment i have paused working with Yii and will be back asap. i'll do it as you have stated when i restart.
0

If you're trying to set up unit tests then I found it quicker and easier to set up a ubuntu virtual machine. It will only take a couple of hours including PHPunit and selenium server. Whereas you could spend hours or days trying to get PHP paths and system variables right on windows.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.