phpunit

phpunits for dummies (howto and documentation) ?

i would like to have a documentation on how to use phpunits for dummies. is there any ? or do you have a great reference website that provide how to use phpunits on daily basis ? ...

phpunit clover from some particular directories, not full clover. Is it possible?

Why do I need this? I'm running the tests on symfony project (and using Zend fw) and phpunit generates clover for all affected files. But I don't want see coverage for symfony and Zend libs (and all another third party ones). I wish see coverage for my code only. Or may be this should do clover viewer? I'm using the clover plugin for hud...

PHPUnit how to mock newly created model

Hi All, How I'm stuck with writing a test for the following code. I want to mock the $userModel but how can I add this to the test? class PC_Validate_UserEmailDoesNotExist extends Zend_Validate_Abstract { public function isValid($email, $context = NULL) { $userModel = new Application_Model_User(); $user = $userM...

PHPUnit code coverage not working with configuration

I have my PHPUnit setup and coverage report working fine without a white list filter. Once I add one however, the report seems to only partially generate as if PHPUnit quit unexpectedly. I do not get any errors or warnings. My configuratoon looks like this: <?xml version="1.0" encoding="UTF-8"?> <phpunit bootstrap="./bootstrap.php" ...

PHPUnit: Failed asserting last controller used <"error">

Hi, I am working on a ZF project wich use a postgre database, on my local server (ubuntu 10.04 LTS Lucid Lynx). I'm trying to run a very simple test with phpunit: public function testIndexAction() { $this->dispatch('/'); $this->assertController('index'); $this->assertAction('index'); $this->asse...

Zend Framework Testing controller Zend_Controller_Exception: No default module defined for this application

Hello. I try to write test for controller. I use OS Windows, zend framewokr and my libraries are in C:/library which is added to the include_path of php.ini. When I run test testLoginAction I get an error No default moudulde define for the application. But I don't use modules at all. Do you know how to solve this problem? IndexController...

phpunit test exception if http answer code is 403

I have my test code PHPUnit with selenium RC extension: class LinkTest extends WebTestCase { public function testShow() { $this->open('?r=link'); } Expression in open() return 403 HTTP code (Forbidden) and then PHPUnit call exception. This is not what i want. I want to check is my url in open() is Forbidden or not. How can i d...

Using PDO Sqlite in-memory Db for PHPUnit tests

Hello I recently got PHPUnit working with xDebug for testing my Zend Framework applications. The fact I use ZF shouldn't make any difference to this question- just mentioned it for completeness. Anyway, it all works fine, but now I want to set up an in-memory database using PDO SQLite. I have done this successfully and have created tab...

Symfony Unit Testing and Excessive Memory Leaks?

We're currently having issues with memory leaks when using unit tests with Symfony 1.x to the magnitude of a decent number of tests eating 512MB of memory. Currently we've tried: Using a phpunit plugin Using lime Restricting the tests to a few sfPropelData loads + functional tests repeated a few times Switching to PHP 5.3.3 to handle...

Anyone have any experience setting up scalable tests using multiple browser/system configurations using Selenium RC/PHPUnit?

Hello. I'm attempting to set-up some tests in Selenium RC that I can quickly specify which browsers I want to target, without having to copy/paste into each test. Here is a sample test: class WebTest extends PHPUnit_Extensions_SeleniumTestCase { public static $browsers = array( array( 'name' => 'Firefox on ...

PhpUnit for Wordpress

How can I use phpunit to test a wordpress module in different WP versions ? I found this tutorial : http://codex.wordpress.org/Automated_Testing but i don't think you can select the right WP version. Also I would like to run PhpUnit directly not using wp-test.php. ...

How to check whether Selenium Server is running

I have bunch of phpunit tests, part of them using selenium, and i need to know wheteher selenium server is running or not (windows). Is there way to check it from php? ...

Calling php code from php code on different server

Hi, The situation is following. I have a local (development) PHP server (Win + IIS) on my computer and I would like to call a function on a remote server because there is an executable file on the remote server (linux) that does not run on my local computer. So on the remote server would be a simple PHP page which calls the executable wi...

How to run a specific phpunit xml testsuite?

how can i choose a specific testsuite to be executed? $ phpunit --configuration config.xml config.xml: <testsuites> <testsuite name="Library"> <directory>library</directory> </testsuite> <testsuite name="XXX_Form"> <file>library/XXX/FormTest.php</file> <directory>library/XXX/Form</directory> ...

phing and phpunit + bootstrap

How to run PHPUnit test suite with bootstrap file with phing? My app structure: application/ library/ tests/ application/ library/ bootstrap.php phpunit.xml build.xml phpunit.xml: <phpunit bootstrap="./bootstrap.php" colors="true"> <testsuite name="Application Test Suite"> <directory>./</directory> </testsuit...

How to test inner arrays with phpunit

I have to test an array with inner arrays. my array looks like the following. $testdata=Array ( [0] => Array ( [label] => 'Ammy' [idr] => 'user7' [rel] => 7 ) [1] => Array ( [label] => 'sidh' [idr] =>...

how to test a function with phpunit where input parameters are extracted from $_POST

i have stuck at a point for quite some time i have to test a function where the parameters are extracted from the $_POST global array. look at the following for a better clarification my function looks like this function getUsers() { extract($_POST); $usersQry=$this->db->query("select user from user_table wh...

Best practices for database testing with PHPUnit

PHPUnit's own manual has some as-yet-unwritten sections entitled "Operations" and "Database Testing Best Practices." What are best practices for testing a database with PHPUnit, particularly in MySQL? ...

[unit-testing] Distinquish between 0 and some datasets from db (both valid cases)

Hi, currently I'm using phpunit to write tests for some functions that access a mysql-database. Now I'm unsure what to do to distinguish when a function returns some datasets or nothing (which both are valid function results). Should I use different tests (so that one of them will fail in any case) or is it in this case ok to use an if t...

PHPUnit :: get message: OK, but incomplete or skipped tests! without any information where is happen.

Hi, Get message: OK, but incomplete or skipped tests! without any information where is happen. Only the: ..I........ How can i find where is the problem? Thanks ...