phpunit

Selenium RC: Selecting elements using the CSS :contains pseudo-class

I would like to assert that a table row contains the data that I expect in two different tables. Using the following HTML as an example: <table> <tr> <th>Table 1</th> </tr> <tr> <td>Row 1 Col 1</td> <td>Row 1 Col 2</td> </tr> </table> <table> <tr> <th>Table 2</th> </tr> <tr> ...

cruisecontrol phpunit creates no output

I cannot seem to figure out why the phpunit target does not output any test results even though I have tests in position. The problem I am finding is there is no indication as to what the problem is! Incredibly frustrating. The output is as follows: <build error="C:\Program Files (x86)\CruiseControl\projects\myProject\build.xml:46: ex...

PHPUnit+ZendFramework ::How I can test multu users session in the same time?

Hi, I beginer programmer,and don't have any QA experience (only simple test that i write without PHPUnit or other tool) How I can create test for testing multi users sessions in the same time? (PHPUnit+ZendFramework) basic tests examples that I thinking to do (I am not QA - I soory if i wrong): users logins in the same time use...

Automation : Selenium - PHPUnit performance problem in linux

I am using the PHPUnit framework to write testcases for execution on the Selenium RC server. The PHP scripts and the selenium server are running in the same machine. I have written some functions like reading of XML files, command like parameters, XLIFF integration etc by extending the PHPUnit_Extensions_SeleniumTestCase class. But the p...

how to log failures in php unit?

How to log only failures in an external file, from php unit? I want the complete information, including actual value, expected value, line number etc. Right now I am using fwrite and logging all pass and fail tests into a file, is there a better way to do it? ...

Customizing setUp in PHPUnit

Hey all, I'm looking to run a bunch of tests with one object with different parameters in the setUp function. How do I do this? I tried using the @dataProvider, but that doesn't work with setUp I quickly found out.. Here's what I'd like to do (using @dataProvider): /* * @dataProvider provider */ function setUp($namespace, $args) { ...

About unit testing a function in the zend framework and unit testing in general

Hello people, I am diving into the world of unit testing. And i am sort of lost. I learned today that unit testing is testing if a function works. I wanted to test the following function: public function getEventById($id) { return $this->getResource('Event')->getEventById($id); } So i wanted to test this function as follows: p...

Questions regarding PHPUnit mock feature

Can someone provide me a reference to a good PHPUnit mock guide? The one in the official documentation doesn't seem to be detailed enough. I am trying to study PHPUnit by reading the source code, but I am not familiar with the term matcher, invocation mocker, stub return, etc. I need to know about the following: 1) How to expect multi...

Using PHPUnit to test cookies and sessions, how?

With PHPUnit it's quite easy to test raw PHP code, but what about code that heavily relies on cookies? Sessions could be a good example. Is there a method that doesn't require me to setup $_COOKIE with data during my test? It feels like a hacky way of doing things. ...

Zend Framework: How to start PHPUnit testing Forms?

I am having trouble getting my filters/validators to work correctly on my form, so I want to create a Unit test to verify that the data I am submitting to my form is being filtered and validated correctly. I started by auto-generating a PHPUnit test in Zend Studio, which gives me this: <?php require_once 'PHPUnit/Framework/TestCase.php...

"No such file or directory" SQLSTATE error using PHPUnit with XAMPP & Zend Framework

The error I'm getting is below. Zend_Db_Adapter_Exception: SQLSTATE[HY000] [2002] No such file or directory I've tried setting the xampp php to be the php in my PATH, hoping that it's a configuration file, but I had no luck with that. I'm not really sure why else it would say no such file or directory. Does anyone have any ideas? Up...

Zend Framework/PHPUnit: How to Stub/Mock an object method that connects to a database?

In my Zend Framework project, I have a form that I am testing. In my form, a multi-select element gets its options from a model, which gets the data from the database. public function init() { $this->addElement('select', 'Region_ID', array('multiOptions' => $this->getRegions())); } protected function getRegions() { $mapper = ne...

Zend Form: How to pass parameters into the constructor?

I'm trying to test my form. It will be constructing other objects, so I need a way to mock them. I tried passing them into the constructor... class Form_Event extends Zend_Form { public function __construct($options = null, $regionMapper = null) { $this->_regionMapper = $regionMapper; parent::__construct($options...

PHPUnit reporting "Aborted" no matter what tests are run

Having a weird problem with PHPUnit. We're using PHPUnit as part of a continuous integration environment, that contains one app written using Zend Framework and one app written using CodeIgniter. Unit tests run just fine under Zend Framework, but whenever I run the tests for CodeIgniter using fooStack's CIUnit bridge, I always get the ...

PHPUnit Stubbing Class methods declared as "final"

Hi, I'm writing a unit test for a class method that calls another class's method using a mock, only the method that needs to be called is declared as final, so PHPUnit is unable to mock it. Is there a different approach I can take? example: class to be mocked class Class_To_Mock { final public function needsToBeCalled($options) ...

Wordpress MU 2.92 Test Suite Errors

I'm trying to run the WordPress test suite (http://svn.automattic.com/wordpress-tests/) against wordpress MU by running "php wp-test.php -v mu" on the command line, and I get a whole slew of errors related to database tables being missing: WordPress database error Table 'wordpress_test.wp_sitemeta' doesn't exist for query SELECT meta_va...

Testing controller with Zend_Test

Hi there, I asked the same question in another forum, but I don't yet have any luck there. So please allow me to ask the same question here. I want to setup Zend_Test to test my controller code (I am using PHP, Zend Framework). Everything seems to be correct and according to the official documentation, but I kept getting an error. For...

json_decode() returns null issues

Hey all, I've an issue with my JSON. It works returns correctly in PHP 5.3 (so I can't use json_last_error()), and it returns successfully when I copy string explicitly into json_decode (json_decode('{...}'). It only returns null in when I pass the result as a variable and I'm using php 5.2, which is what I need it for. The output come...

[PHPUnit] Trying to run a test, but get a fatal error

I configured the external tool correctly. As soon as I start to run a test case I get this error: Failed loading C:\PHP\5.2.13\ext\php_xdebug.dll PHP Warning: PHP Startup: Unable to load dynamic library 'C:/PHP/5.2.13/ext\php_oci8.dll' - The specified module could not be found. in Unknown on line 0 PHP Warning: require_once(../../.....

Anyone knows something like RSPec for PHP?

RSPec is a great ruby test framework (for test driven development), anyone knows something like rspec but, for PHP? ...