phpunit

Selenium test doesn't like certain URL

I don't know if this is strictly a programming question but here goes. I have a test that looks like this: public function testNewCoupon() { $this->open("coupon/new/".$this->bank_code); $this->open(""); } When I run the test, I get this error: 1) Backend::testNewCoupon PHPUnit_Framework_Exception: Response from Selenium RC serve...

How to present a Selenium test written in spec or PHPUnit on Hudson

Hi there, I am setting up Selenium tests on Hudson and looking for an easy way to present nice results such as Project summary and build summary on Hudson. Currently I have written Selenium test cases in Rspec and PHPUnit's extension for Selenium (I prefer working on Rspec over PHP). What is the best way to present detailed report for S...

PHPUnit: assert two arrays are equal, but order of elements not important

What is a good way to assert that two arrays of objects are equal, when the order of the elements in the array is unimportant, or even subject to change? ...

PHPUnit : Fatal error handling

Hi all, I use PHPUnit for unit tests, but when a fatal error is triggered, the script dies and I have no correct PHPUnit output. I'd like that the PHPUnit output stays correctly formated, because it is read by a plugin for Eclipse. Actually the fatal error stops PHPUnit and in Eclipse the plugin can't interpret anything (because the PH...

PHPUnit_Framework_Exception: Could not connect to the Selenium RC server when I run with Hudson

Hi there, I have set up Hudson CI Server and running PHPUnit test with Selenium (big thanks to this post!). Now I am running Hudson server and Selenium server on my localhost. I set up Hudson as port 8080 (default) and Selenium -port 1234 as it conflicts otherwise. However, every time I run Selenium test, I get a following error: P...

PHPUnit gets segmentation fault

Hi- Trying to get started using phpunit and can't get it installed/setup properly. When I run it command line I get a segmentation fault. Environment: OSX 10.6.4 PHP 5.3.2 (cli) (built: Aug 7 2010 00:04:41) About pear.phpunit.de/PHPUnit-3.4.9 I tried disabling xdebug in php.ini and still got the error - the only difference was it ...

PHPUnit StackTest::assertEmpty() deprecated.

I am learning building php unit tests using PHPUnit . There they have a manual and I encountered this example Where they use assertEmpty(), but when I run this code in command line I get this error : Call to undefined method StackTest::assertEmpty() in /var/www/.../tests/StackTest.php on line 20. So if this method is deprecated or someth...

how to test PUT request parsing in PHPUnit

Hello all, I'm parsing a PUT query this way : $raw = file_get_contents('php://input'); $params = array(); parse_str($raw, $params); and I'd like to inject some test content into php://input to test it (and for some non-unit tests too). I tried to google a bit the matter, but 'put' is a short keyword and I didn't get anything r...

PHPUnit + Kohana: Undefined index: HTTP_HOST

Trying to run PHPUnit on my Kohana 2.3.4 install: phpunit --colors --bootstrap=index.php ../../modules/phpunit/libraries/Tests.php Getting an error at one of my modules: <p><tt>modules/core/helpers/MY_url.php <strong>[118]:</strong></tt></p> <p><code class="block">Undefined index: HTTP_HOST</code></p> I realize this is happening si...

PHPUnit: "Invalid value passed to setPost()" when passing Zend_Db_Table_Row_Abstract converted using toArray()

The following code fails throws a Zend_Controller_Exception ("Invalid value passed to setPost(); must be either array of values or key/value pair") /** Model_Audit_Luminaire */ $luminaireModel = new Model_Audit_Luminaire(); if (!$fixture = $luminaireModel->getScheduleItem($scheduleId)) { $this->fail('Could not retrieve fixture from ...

phpunit runs test twice - gets two answers. Why?

This is my phpunit test file <?php // DemoTest - test to prove the point function __autoload($className) { // pick file up from current directory $f = $className.'.php'; require_once $f; } class DemoTest extends PHPUnit_Framework_TestCase { // call same test twice - det different results function test01() { ...

Hudson failing build w/o revealing cause

Every build has failed as of Tuesday. I'm not exactly sure what happened. The Phing targets (clean/prepare) are being executed properly. Additionally, the unit tests are passing with flying colors, with only a warning for duplicate code (not a reason for a fail). I tried removing the phpDoc target to see if that was causing the error...

PHPUnit - alternative to Selenium?

Is it possible to use PHPUnit as an alternative to Selenium to do GUI testing? My impression is that it is just a generic testing framework and can't handle javascript, dom and other GUI aspects. Right now I am running php+selenium rc+firefox and the overhead of the java selenium server och actually running the firefox gui makes me worr...

PHPUnit code coverage generation causing memory exhaustion

I'm currently using Zend Framework in conjunction with PHPUnit to conduct unit testing on an application. When Hudson executes the PHPUnit shell command, the maximum PHP memory limit is reached sometime during code coverage generation. I currently have a total of 41 tests with 334 assertions. I have successfully eliminated this error ...

Save doctrine record without persisting

Hi, within my Unit-tests i would like to have the following behavior: $myNewDoctrineRecord = new Dto_MyRecord(); $myNewDoctrineRecord->pk = 1; //the primary key ... $myNewDoctrineRecord->save(); Now this record shouldnt really persist to the database. But i would like to do $myFetchedDoctrineRecord = Doctrine::getTable('Dto_MyRecord'...

Global constants in PHPUnit

Is there a way to define constants in PHPUnit that can be used in all your test suites? For example, say I want to be able to test on jason.dev.mysite.com sometimes and jim.dev.mysite.com sometimes, and maybe specify when I run the command on which site I want to test. Is anything like this possible? The closest thing I found was this: ...

PHPUnit:: How can function that set and get cookies, tested?

Hi, PHPUnit:: How can function that set and get cookies, tested without get error : headers already sent by? Example that give error: PHPUnit_Framework_Error_Warning: Cannot modify header information - headers already sent by MyCookie.php class MyCookie{ public static function createCookie(){ $uid = null; $cookieName...

integration testing command line PHP

I've got a PHP script that runs at the command line, executing classes that are already unit tested with PHPUnit. However, I'd like to verify that the script itself has no logical errors and runs properly. // require classes require_once 'injectedClass.php'; require_once 'DBClass.php'; require_once 'taskEngine.php'; $injectedObj = n...

How to indicate that a PHPUnit test is expected to fail?

Is it possible to mark a test as "expected to fail" with PHPUnit? This would be useful when performing TDD, and you want to distinguish between genuinely failed tests, and tests that happen to fail because the associated code hasn't been written yet. ...

Where can I find PHPUnit_Extensions_SeleniumTestCase?

I have Selenium IDE/RC, and PHPUnit 3.5 (PEAR) installed, but I can't seem to find PHPUnit_Extensions_SeleniumTestCase. When I type pear install phpunit/PHPUnit_Selenium, I get the following error: phpunit/PHPUnit_Selenium is already installed and is the same as the released version 1.0.0 install failed It appears that PHPUn...