how to setup environment for phpunit for joomla testing?

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Locked
devlabs
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Jan 23, 2009 10:39 pm

how to setup environment for phpunit for joomla testing?

Post by devlabs » Mon Sep 21, 2009 4:11 pm

I have winXP + wamp server 2.0i:

1. wamp root (done Image)
C:\wamp

2. wamp PHP (done Image)
C:\wamp\bin\php\php5.3.0

3. wamp PEAR (done Image)
C:\wamp\bin\php\php5.3.0\PEAR

4. PHPUnit 3.4.0 in 2 folders
C:\wamp\bin\php\php5.3.0\PEAR\PHPUnit
and
C:\wamp\bin\php\php5.3.0\tests\PHPUnit\PHPUnit\Tests

Next, I open CMD(command line)
#command1:
cd C:\wamp\bin\php\

//cause simple php doesn't work in global environment, it's a bug and haven't found the way to fix it even if to add it in win register

#command2:
--- php phpunit Alltests.php
// I asume that the file is in C:\wamp\bin\php\php5.3.0\tests\PHPUnit\PHPUnit\Tests

and then get the error:
Argument #1 of PHPUnit_Util_Fileloader:checkAndLoad() is no existing file

what is the problem? and how to fix it?

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11614
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: how to setup environment for phpunit for joomla testing?

Post by ooffick » Tue Sep 22, 2009 8:39 am

In Regards to PHPUnit have a look here:
http://docs.joomla.org/Unit_Testing

Olaf
Olaf Offick - Global Moderator
learnskills.org

devlabs
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Jan 23, 2009 10:39 pm

Re: how to setup environment for phpunit for joomla testing?

Post by devlabs » Tue Sep 22, 2009 10:10 am

Where you able to make Unittesting work on wamp server? Cause I asume that unittesting is incompatible with wamp server.

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11614
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: how to setup environment for phpunit for joomla testing?

Post by ooffick » Tue Sep 22, 2009 10:52 am

No, I haven't tried it, but there are a few people who claim to work on WAMP with PHPUnit.
Did you ask the guys at the PHPUnit project?

Olaf
Olaf Offick - Global Moderator
learnskills.org

devlabs
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Jan 23, 2009 10:39 pm

Re: how to setup environment for phpunit for joomla testing?

Post by devlabs » Tue Sep 22, 2009 11:21 am

ooffick wrote:No, I haven't tried it, but there are a few people who claim to work on WAMP with PHPUnit.
Did you ask the guys at the PHPUnit project?

Olaf
I wish if phpunit had any forum like in joomla or any other opensource project but it doesn't and I can't dirrectly communicate with people who use this project.
I wrote a letter to Bergmann, but haven't got any answer yet.

I have spent few days with no luck trying to make it work,phpunit has a good guide about the testing itself, but the problem is just how to setup environment for it on winOS.

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11614
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: how to setup environment for phpunit for joomla testing?

Post by ooffick » Tue Sep 22, 2009 11:30 am

There are a couple of tutorials which explain how to install phpunit on http://www.google.com/search?q=phpunit+wamp

Olaf
Olaf Offick - Global Moderator
learnskills.org

devlabs
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Jan 23, 2009 10:39 pm

Re: how to setup environment for phpunit for joomla testing?

Post by devlabs » Tue Sep 22, 2009 12:21 pm

ooffick wrote:There are a couple of tutorials which explain how to install phpunit on http://www.google.com/search?q=phpunit+wamp

Olaf
Will try to explain you one more time:
1. Yes I do have installed wamp->pear->phpunit. Yes I do have used google and searched a lot.
2. when I try to run phpunit it shows that it is installed. But when I try to run a test with phpunit
it gives an error which I mentioned above and I haven't found any solution for this.


Argument #1 of PHPUnit_Util_Fileloader:checkAndLoad() is no existing file
what is the problem? and how to fix it?

User avatar
ianmac
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4784
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: how to setup environment for phpunit for joomla testing?

Post by ianmac » Tue Sep 22, 2009 2:36 pm

devlabs wrote:
ooffick wrote:There are a couple of tutorials which explain how to install phpunit on http://www.google.com/search?q=phpunit+wamp

Olaf
Will try to explain you one more time:
1. Yes I do have installed wamp->pear->phpunit. Yes I do have used google and searched a lot.
2. when I try to run phpunit it shows that it is installed. But when I try to run a test with phpunit
it gives an error which I mentioned above and I haven't found any solution for this.


Argument #1 of PHPUnit_Util_Fileloader:checkAndLoad() is no existing file
what is the problem? and how to fix it?
Did you try adding your PHP and Pear directory to your path?

What tests are you trying to run?

Ian

devlabs
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Jan 23, 2009 10:39 pm

Re: how to setup environment for phpunit for joomla testing?

Post by devlabs » Tue Sep 22, 2009 3:17 pm

ianmac wrote:
devlabs wrote:
ooffick wrote:There are a couple of tutorials which explain how to install phpunit on http://www.google.com/search?q=phpunit+wamp

Olaf
Will try to explain you one more time:
1. Yes I do have installed wamp->pear->phpunit. Yes I do have used google and searched a lot.
2. when I try to run phpunit it shows that it is installed. But when I try to run a test with phpunit
it gives an error which I mentioned above and I haven't found any solution for this.


Argument #1 of PHPUnit_Util_Fileloader:checkAndLoad() is no existing file
what is the problem? and how to fix it?
Did you try adding your PHP and Pear directory to your path?

What tests are you trying to run?

Ian

before doing
#command2:
php phpunit Alltests.php

I do
#command1:
cd C:\wamp\bin\php\

so I am already in the php folder

I am trying to run some default test(if any) to see how it works.

C:\wamp\bin\php\php5.3.0\tests\PHPUnit\PHPUnit\Tests\Alltests.php

Code: Select all

<?php

error_reporting(E_ALL | E_STRICT);

require_once 'PHPUnit/Util/Filter.php';

PHPUnit_Util_Filter::addFileToFilter(__FILE__);

require_once 'PHPUnit/Framework/TestSuite.php';
require_once 'PHPUnit/Extensions/PhptTestSuite.php';

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Framework' . DIRECTORY_SEPARATOR . 'AllTests.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Extensions' . DIRECTORY_SEPARATOR . 'AllTests.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Runner' . DIRECTORY_SEPARATOR . 'AllTests.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Util' . DIRECTORY_SEPARATOR . 'AllTests.php';

PHPUnit_Util_Filter::$filterPHPUnit = FALSE;


class AllTests
{
    public static function suite()
    {
        $suite = new PHPUnit_Framework_TestSuite('PHPUnit');

        $suite->addTest(Framework_AllTests::suite());
        $suite->addTest(Extensions_AllTests::suite());
        $suite->addTest(Runner_AllTests::suite());
        $suite->addTest(Util_AllTests::suite());
        $suite->addTest(new PHPUnit_Extensions_PhptTestSuite(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Regression'));
        $suite->addTest(new PHPUnit_Extensions_PhptTestSuite(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'TextUI'));

        return $suite;
    }
}
?>
I asume that this should work.

User avatar
ianmac
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4784
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: how to setup environment for phpunit for joomla testing?

Post by ianmac » Tue Sep 22, 2009 3:35 pm

devlabs wrote:
ianmac wrote: Did you try adding your PHP and Pear directory to your path?

What tests are you trying to run?

Ian

before doing
#command2:
php phpunit Alltests.php

I do
#command1:
cd C:\wamp\bin\php\

so I am already in the php folder

I am trying to run some default test(if any) to see how it works.

C:\wamp\bin\php\php5.3.0\tests\PHPUnit\PHPUnit\Tests\Alltests.php

Code: Select all

<?php

error_reporting(E_ALL | E_STRICT);

require_once 'PHPUnit/Util/Filter.php';

PHPUnit_Util_Filter::addFileToFilter(__FILE__);

require_once 'PHPUnit/Framework/TestSuite.php';
require_once 'PHPUnit/Extensions/PhptTestSuite.php';

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Framework' . DIRECTORY_SEPARATOR . 'AllTests.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Extensions' . DIRECTORY_SEPARATOR . 'AllTests.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Runner' . DIRECTORY_SEPARATOR . 'AllTests.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Util' . DIRECTORY_SEPARATOR . 'AllTests.php';

PHPUnit_Util_Filter::$filterPHPUnit = FALSE;


class AllTests
{
    public static function suite()
    {
        $suite = new PHPUnit_Framework_TestSuite('PHPUnit');

        $suite->addTest(Framework_AllTests::suite());
        $suite->addTest(Extensions_AllTests::suite());
        $suite->addTest(Runner_AllTests::suite());
        $suite->addTest(Util_AllTests::suite());
        $suite->addTest(new PHPUnit_Extensions_PhptTestSuite(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Regression'));
        $suite->addTest(new PHPUnit_Extensions_PhptTestSuite(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'TextUI'));

        return $suite;
    }
}
?>
I asume that this should work.
Hmm... right now I'm only using the standard phpunit runner. I have a basic test like:

Code: Select all

<?php
require_once 'PHPUnit/Framework.php';

class StackTest extends PHPUnit_Framework_TestCase
{
    public function testPushAndPop()
    {
        $stack = array();
        $this->assertEquals(0, count($stack));

        array_push($stack, 'foo');
        $this->assertEquals('foo', $stack[count($stack)-1]);
        $this->assertEquals(1, count($stack));

        $this->assertEquals('foo', array_pop($stack));
        $this->assertEquals(0, count($stack));
    }
}
That runs. I have that file in a folder called tests. I run it by doing:
phpunit tests

I haven't gotten into the complexities though that you are trying to wade through.

Ian

devlabs
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Jan 23, 2009 10:39 pm

Re: how to setup environment for phpunit for joomla testing?

Post by devlabs » Tue Sep 22, 2009 3:48 pm

ianmac wrote: That runs. I have that file in a folder called tests. I run it by doing:
phpunit tests

I haven't gotten into the complexities though that you are trying to wade through.

Ian
Can you tell me the
1.full path to the file?
1.full path to the phpunit?
1.full path to the localhost website?

Is it
C:\wamp\bin\php\php5.3.0\tests\PHPUnit\PHPUnit\Tests\tests.php
or
C:\wamp\www\tests.php
or
it's in some another folder? where to create this file?


when you run in cmd
php phpunit
where is your location or it doesn't matter from what folder to run that command?

User avatar
ianmac
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4784
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: how to setup environment for phpunit for joomla testing?

Post by ianmac » Tue Sep 22, 2009 4:40 pm

devlabs wrote:
ianmac wrote: That runs. I have that file in a folder called tests. I run it by doing:
phpunit tests

I haven't gotten into the complexities though that you are trying to wade through.

Ian
Can you tell me the
1.full path to the file?
1.full path to the phpunit?
1.full path to the localhost website?

Is it
C:\wamp\bin\php\php5.3.0\tests\PHPUnit\PHPUnit\Tests\tests.php
or
C:\wamp\www\tests.php
or
it's in some another folder? where to create this file?


when you run in cmd
php phpunit
where is your location or it doesn't matter from what folder to run that command?
Well, I'm not on wamp server, so it may be different

I don't run php phpunit. I just run phpunit.

My full path to phpunit is /usr/bin/phpunit.

The localhost website doesn't matter, as PHPUnit doesn't run in the browser, it runs from the cli.

I would advise you to find your php executable and your phpunit executable and put those in your path. Then start working from there.

Ian

User avatar
ianmac
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4784
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: how to setup environment for phpunit for joomla testing?

Post by ianmac » Tue Sep 22, 2009 4:47 pm

Try looking at:

http://jsdoodnauth.wordpress.com/2008/1 ... n-windows/

That may offer some assistance.

Ian


Locked

Return to “Joomla! 1.5 Coding”