PHPUnit is the de facto standard for writing unit tests for PHP code.

learn more… | top users | synonyms

83
votes
9answers
16k views

Simple test vs PHPunit

I was wondering if anyone that have experience in both these stuff can shed some light on the significant difference between the two, if any? Any specific strength of each that makes it suitable for ...
70
votes
9answers
21k views

Best practices to test protected methods with PHPUnit [closed]

I found the discussion on Do you test private method informative. I have decided, that in some classes, I want to have protected methods, but test them. Some of these methods are static and short. ...
52
votes
15answers
35k views

phpunit require_once() error

I recently installed phpunit on my server via the pear installer. When I go to run a test I get the following error: PHP Warning: require_once(PHPUnit/Util/Filter.php): failed to open stream: No ...
49
votes
11answers
30k views

Installing PHPUnit via PEAR

I have problems installing PHPUnit 3.4.6 via PEAR 1.9.0. After I discover channel pear.phpunit.de and try to use one of following commands: pear install phpunit/PHPUnit pear install --alldeps ...
44
votes
6answers
9k views

Testing Abstract Classes

How do I test the concrete methods of an abstract class with PHPUnit? I'd expect that I'd have to create some sort of object as part of the test. Though, I've no idea the best practice for this or if ...
34
votes
6answers
15k views

Call to undefined method PHP_CodeCoverage_Filter::getInstance()

I've got a fresh copy of PHPUnit installed on my system (Ubuntu 11), but whenever I type phpunit in the console I get the following error: PHP Fatal error: Call to undefined method ...
34
votes
6answers
19k views

How do I use PHPUnit with Zend Framework?

I would like to know how to write PHPUnit tests with Zend_Test and in general with PHP.
32
votes
7answers
12k views

How can I get PHPUnit MockObjects to return differernt values based on a parameter?

I've got a PHPUnit mock object that returns "return value" no matter what its arguments: // From inside a test... $mock = $this->getMock('myObject', 'methodToMock'); ...
32
votes
9answers
9k views

PHPUnit - Unit Testing with items that need to send headers

I'm currently working with PHPUnit to try and develop tests alongside what I'm writing, however, I'm currently working on writing the Session Manager, and am having issues doing so... The constructor ...
31
votes
9answers
8k views

“Web interface” to PHPUnit tests?

Is there a simple "Web interface" to running PHPUnit test suites? i.e. a PHP script that runs the test on the command line, and outputs a nicely formatted HTML result. I develop web applications, and ...
28
votes
7answers
13k views

Selenium 2 (WebDriver) and Phpunit?

Any one know how to use Selenium 2 with Phpunit? Are there any Selenium 2 samples in PHP?
27
votes
1answer
6k views

How to test a second parameter in a PHPUnit mock object

This is what I have: $observer = $this->getMock('SomeObserverClass', array('method')); $observer->expects($this->once()) ->method('method') ...
25
votes
6answers
10k views

phpunit avoid constructor arguments for mock

What is the way to avoid phpunit having to call the constructor for a mock object? Otherwise I would need a mock object as constructor argument, another one for that etc. The api seems to be like ...
25
votes
5answers
3k views

Mock in PHPUnit - multiple configuration of the same method with different arguments

Is it possible to configure PHPUnit mock in this way? $context = $this->getMockBuilder('Context') ->getMock(); $context->expects($this->any()) ->method('offsetGet') ...
25
votes
2answers
4k views

How do I use PHPUnit with CodeIgniter?

I have read and read article on PHPUnit, SimpleTest and other Unit Testing frameworks. They all sound so great. I finally got PHPUnit working with Codeigniter thanks to ...

1 2 3 4 5 158
15 30 50 per page