phpunit

How to Install phpunit 3.5 on mac with MAMP

Hi All, I'm trying to install PHPUnit 3.5 on Mac OS X with MAMP. I did install PHPUnit 3.5 via PEAR of MAMP. This is all correctly and phpunit is located /Applications/MAMP/bin/php5.3/lib/php/PEAR/PHPUnit. The executable is located in /Applications/MAMP/bin/php5.3/bin/. But when I want to execute phpunit it doesn't do anything, even wh...

Apache decoding encoded URL instead of passing encoded URL?

I have a Selenium/PHPUnit test that needs to open a URL that contains an encoded URL. $redirectToLocation = urlencode('/myothercontroller/action'); // %2Fmyothercontroller%2Faction $this->openAndWait('/controller/action/thenRedirectTo/' . $redirectToLocation); But when I run my test, the browser tried opening the decoded URL: /contro...

How to wrap PHPUnit to control command line reporting?

So I've got a lot of PHPUnit tests (they are actually Selenium tests running as PHPUnit tests). When I run them from the command line, I get this sort of reporting as the tests complete: ..E..F..E.FF... Then I have to wait until all the tests finish running before it will tell me the errors and what failed. I would like to be able to ...

phpunit data provider

I am working on PHPunit tests and so far everything is great. There is one issue, however, and it is with the following setup. Ideally I'd like to select the next value in the sequence (postgreSQL) and pass that into the function so I can validate it against the array returned from my class being tested (new row in database). The issue ...

How can I make PHPUnit + Selenium run faster?

Hi, I'm using PHPUnit's Selenium extension to do web testing. I'm finding it very slow, taking seconds for a single test method. Part of the issue appears to be that its starting a new Selenium session between each test method (getNewBrowserSession), as part of runTest(). This is expensive. I'm ok with running a class or even a whole...

Extending testcases from PHPUnit_Framework_TestCase instead of Zend_Test_PhpUnit_ControllerTestCase in a Zend project

Hi. I'm using Zend Framework in one of my projects and I'm using PHPUnit for unit testing. I know that Zend_Test_PhpUnit_ControllerTestCase class is good for testing controllers with its dispatch() method and all. But I also have a few simple classes like ones used for some calculations and so on. These classes do not require the entire ...

phpunit and selenium: run javascript and check return

I need to run a javascript function from a phpunit test with selenium and check the javascript returns true. I've looked into using runScript but it never seems to run (I've tested this by adding an alert to the code, but it never shows..). My javascript needs to check the opacity of an element is 1, if not use setTimeout to run the fun...

error after running a test in selenium rc+phpunit

Hi, I'm running the following test in selenium-rc: <?php require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; class Example extends PHPUnit_Extensions_SeleniumTestCase { protected function setUp() { $this->setBrowser("*firefox /usr/bin/firefox"); $this->setBrowserUrl("http://www.google.com"); } public function te...

Overwritting PHPUnit test files with updated ones in NetBeans

Hello, Using NetBeans 6.9.1, when I update my source files with additional unit tests for PHPUnit, I always have to delete the old PHPUnit test files and generate new ones. If I choose to generate without deleting them, generation will fail and the old files won't be updated. Is there a "smart" way to force NetBeans to automatically over...

PHPUnit configuration (phpunit.xml) -- loading in a bootstrap?

Situation We're using PHPUnit in our project and are using a phpunit.xml to ensure things like backupGlobals is turned off. To further ensure the include path is set and autoloading is active, we also cascade our test bootstraps. That is to say, every test and alltests-suite has a require_once(__DIR__ . '/../bootstrap.php'); at the top...

How to have PHPUnit do something if an assertion fails

I'm testing that a function properly adds data to a db, but I want the test data removed after the test is finished. If the test fails, it quits at the failure and never gets the chance to delete the test rows. It's the only test that hits the db, so I don't really want to do anything in the tearDown() method. I'm testing an $obj->sav...

How to stub data for PHPUnit with plugin using Zend_Auth that redirects on failed authentication

I'm still a newb to phpunit so I hope to be explaining this correctly. I'm trying to run a controller test with PHPUnit, however the plugin that is using Zend_Auth is redirecting back to the login. How do I create the stub data? I tried placing it in my setUp but Zend_Auth appears to be reinstantiated after setUp. Thanks for any help ...

Zend Framework, HelperBroker PHPUnit Test

Hello, This is a very specific question and I have googled lots for a potential solution but nothing that points me in the right direction. I have written a Zend_Controller_Action_Helper to help me process some forms in my application. Now in the application it works fine but it seams to of broke my tests. If I comment out the lines ...

How do I run PHPUnit Selenium tests over a ssh connection?

I'm using the yii framework and trying to get its unit tests running while connected over ssh on a CentOS server. When I run phpunit, it tries to launch Firefox, which fails with the error "no display specifiied" ...

How to test a custom Zend_Form with PHPUnit?

Does anyone have an example of how to test a custom Zend_Form that extend from that class with PHPUnit?? I may need to test the construct and the init... where i'm adding elements to the My_Custom_Zend_Form. ...

What's the correct way to stub functionality for PHPUnit testing?

Hi, I'm trying to write some unit tests for a class that connects to an API. What I want to do is alter the class so that instead of actually connecting to the API, it instead loads a pre-fetched constant fixture. The method within the class that actually does the cURL request and returns the data is protected, and this is the one I wa...

How to build Exception Logger system in PHP that can have different Logger implementations e.g. File/DB and is testable

I'm building a PHP library that throws various custom Exceptions when it encounters errors. I need to log those exceptions and provide various implementations of the Logger so they could be logged in a file or a database. The exceptions need to be logged whether they are caught or not, so that excludes implementing any of this in a cust...

How can i get phpunit to run tests from all files in a folder?

From what I've read, it seems like I should be able to set up a folder, e.g. tests/ , put a few files in it with unit test classes, and then run phpunit on that file and have it find and run the tests. For whatever reason, in my installation (on OS X), it thinks the folder tests/ is a file, or so it would seem: $ ls tests test1.php tes...

Selenium/PHPUnit tests always run twice, fail on second pass

The problem I am having is that I have setup runners for my Selenium/PHPUnit tests and they are always being run twice, per test, one after the other. And then it will move onto the next test. I found http://www.phpunit.de/ticket/688 that bug seems to be exactly what is happening to me -- so I removed all references to PHPUnit_MAIN_MET...