phpunit

Dynamic input in Selenium/PHPUnit

I want to take dynamic input for values in my unit tests. How can I do this? Thanks! ...

Can we save the result of PHPUnit test

Is it possible to save the result generated from a PHPUnit test as a text file or as a html file so that we can review it later and send it to concerned person through email? Simply my requirement is to save the out put,that we get in an IDE (Netbean or Eclipse) or in the command prompt into a file in the local system(the system where i ...

Exception not tested with phpUnit?

Hi, I'm writing some unit test with phpUnit to test a Zend Framework application and I've got some issues with testing an exception in the changePassword function. The test doesn't fail, but in the coverage tool which generates html the "throw new Exception($tr->translate('userOldPasswordIncorrect'));" line isn't tested. public functio...

Set a test timeout duration with PHPUnit

I have some test cases that can go into an infinite loop upon failure. Is there a built-in way to set a test timeout duration with PHPUnit? If not, what would be the most unobtrusive way of adding this feature to a test case? ...

PHPUnit provider not working with dependencies

I'm using PHPUnit 3.4.9, but I'm having some problems with the @depends annotation. It works like in the examples, but breaks when the producer reliers on a provider. I don't know if this is meant to work or not, but my code is basically in the form: <?php class StackTest extends PHPUnit_Framework_TestCase { /** * @da...

What is the best approach to write testunit in framework such as wordpress ?

i'm starting a new project. And what to know how to write a good testunits in existing framework such as wordpress ? is it possible to use phpunits or selenium RC ? ...

How to generate session varibles while testing with phpunit

While testing a piece of code(written as per codeigniter mvc) with PHPUnit i got the error PHP Fatal error: Call to a member function getPermissionObject() on a non-object. The code is as below and the part of it producing error is indented. class Some_model extends Model { var $userid; var $permisson_object; var $username; va...

PHPUnit: continue after die, expect "die" or somehow handle die() ?

Hi all. I'm writing some unit tests. The system I'm currently testing is a web-app in an MVC framework. If we want to render pages without the site-skin system we've traditionally run our code as usual, but printed a "die();" statement at the end of the function to exit before the rest of the website renders. Well now that we're addi...

Unit testing with Zend Framework/Doctrine 2.0

I wanted to write unit tests for my Zend Framework/Doctrine 2.0 application, but I don't quite understand how to set up unit testing in ZF. Also, I would like to include Doctrine 2.0 in those unit tests. How would I go about setting this up? Can you point me to an example? Thank You ...

ZF, ZFDoctrine and PHPUnit setup

Hi, Does anyone here use Zend Framework, ZFDoctrine and PHPUnit together? How to rebuild the database on each test run? How to separate local/production/testing environments? Would you share your unit testing setup? I have been trying something like that: // /tests/bootstrap.php // ... setup paths and constants here require_once 'Ze...

Unit testing a class that returns SQL

I'm trying to use PHPUnit to unit test some class methods that return SQL. These classes should work with any Zend_Db adapter, so I would like the tests to do the same. My tests look a little like this: public function testEtcGeneratesCorrectSQL() { $model = new ClassBeingTested(); // do some stuff $sql = $model->__toStrin...

How to handle type and input into WYSWYG editor such as tinymce when testing using selenium RC?

is there any solution to this problem i use : $this->type('contentform', 'i need to print this and go on with my testing'); but after i do submit it failed while when i do it manually it work. i'm using this code for submit: $this->click("publish"); i test my app via selenium RC + phpunit ps: it work in selenium IDE but fai...

PHPUnit inclusion path issues

This one's got me stumped. I've been working with PHPUnit for a couple of months now, so I'm not that green...but I look forward to being pointed in the direction of the obvious mistake I'm making! The initialisation process outlined below works fine if I run the "app" from a browser - but PHPUnit is choking...can any one put me out of m...

Convert from SimpleTest to PHPUnit $this->UnitTestCase('message .....');

Hi, Which action/method is in PHPUnit equal to in simpleTest: $this->UnitTestCase('message .....') Edit: Sorry for my mistake I think what I asking about not exist in simple test directly its just our extended class. But this method display message in begining of test- how its done with PHPUnit? Thanks ...

Zend Framework, Zend_Test & PHPUnit - Class Zend_Test_PHPUnit_ControllerTestCase could not be found

Hi I have been going mad with this, I have found some threads on this but none of them solve my problem. I have my bootstrap.php file for testing which looks like this define("PHPUNIT", true); require_once("/Applications/XAMPP/xamppfiles/htdocs/Common/test/public/index.php"); My index.php file does not call run() on the application ...

Zend_Test - Setting redirect in Controller Plugin for PHPUnit

Hi I have been trying to use PHPUnit to test an application. I have it all working, but cannot test redirects. My redirects are occurring inside an Acl Controller Plugin, not inside an Action in a Controller. I have changed them to use the suggested format of $r = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $r...

PHPUnit and DBUnit - getting started

Does anyone have a link to a good, working tutorial or book on how to get started with adding the DBUnit layer to my PHPUNit tests? I've tried following the code in protected function getDatabaseTester() { $pdo = new PDO('mysql:host=localhost;dbname=test', 'user', 'pass'); $connection = new PHPUnit_Extensions_Database_DB_Defau...

PHPunit - Errors

When an error that the PHPunit framework does not expect to occur happens, the testing stops, and PHP throws the error, but PHPunit does not record that it was an error. How do I make sure PHPunit records it as an error. ...

How to create a mock object of a doctrine entity?

Hi, I'm trying to write a unit test with phpunit for a model that uses doctrine 2. I want to mock the doctrine entities but I really don't have a clue of how to do this. Can anyone explain to me how I need to do this? I'm using Zend Framework. The model that needs to be tested class Country extends App_Model { public function find...

How we load a external class using selenium RC+PHPunits

Maybe this a easy question. but frankly, i have problem to find them out. I want to do unit testing using external class, a database-related php class, that i usually use. What is the best way to use external class in phpunit that use selenium RC. ...