Is there a way to get the tests inside of a TestCase to run in a certain order? For example, I want to seperate the lifecycle of an object from creation to use to destruction but need to make sure that the object is set up first before I run the other tests.
...
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 any specific case?
...
I'm starting to learn how to use PHPUnit to test the website I'm working on. The problem I'm running into is that I have five different user types defined and I need to be able to test every class with the different types. I currently have a user class and I would like to pass this to each function but I can't figure out how to pass th...
I'm a longtime Java programmer working on a PHP project, and I'm trying to get PHPUnit up and working. When unit testing in Java, it's common to put test case classes and regular classes into separate directories, like this -
/src
MyClass.java
/test
MyClassTest.java
and so on.
When unit testing with PHPUnit, is it common to foll...
I am trying to run a SeleniumTestCase with phpunit but I cannot get it to run with the phpunit.bat script.
My goal is to use phpunit with Selenium RC in CruiseControl & phpUnderControl. This is what the test looks like:
require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
class WebTest extends PHPUnit_Extensions_SeleniumTestCase
{...
When you use composition, then you can mock the other objects
from which your class-under-test depends, but when you use
inheritance, you can't mock the base class. (Or can you?)
I generally try to prefer composition over inheritance,
but sometimes inheritance really seems like the best tool
for the job - well, at least until it comes t...
I am searching for a tutorial (optimally with Zend Framework) on how to use PHPUnit.
I have found a couple on google but have not quiet understood it yet.
...
What's the best way to test $_GET and $_POST inputs in PHPUnit?
I have a class that sanitises input and want to check that it works correctly when processing bogus data. Is there an easy way to set up the form variables in PHPUnit or should I just pass off the validation to a secondary class/functions that are fed the form variables so...
We currently use a hand-rolled setup and configuration script and a hand-rolled continuous integration script to build and deploy our application. I am looking at formalizing this somewhat with a third party system designed for these purposes.
I have looked into Phing before, and I get that it's basically like Ant. But, my Ant experienc...
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 for the Session handling class is
private function __construct()
{
if (!headers_sent())
{
session_start();
self::$session_id = sess...
How do I test an abstract class works in 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 phpunit allows for this
...
Hello,
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. Because most of the public methods make use of them, I will probably be able to safely remove the tests later. But for starting with ...
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');
$mock->expects($this->any))
->method('methodToMock')
->will($this->returnValue('return value'));
What I want to be able to do is return a different value based ...
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 this:
getMock($className, $methods = array(), array $arguments = array(),
$mockClassName = '', $callOriginalConstructor = TRUE,
...
I'm a big fan of simpletest because it's what I know. It has excellent support for mocking and web-testing.
But I'm always scared of stagnating so any compelling arguments to switch would be appreciated.
...
I'm just starting to try out phpunit on some existing code. The naming convention we use is that the MyClass class should be in MyClass.class.php. PHPUnit seems to require that the file should be called MyClass.php.
Is there any way around this?
I noticed it while trying to generate a skeleton test class:
phpunit --skeleton-test MyCl...
I'm starting to try and test my Doctrine objects with PHPUnit, and would like to reload the DB from my model objects afresh each time.
My first attempt looks something like this:
class Tests_User extends PHPUnit_Framework_TestCase
{
public function setUp()
{
Doctrine_Manager::connection('mysql://user:pass@localhost/te...
This is what I have:
$observer = $this->getMock('SomeObserverClass', array('method'));
$observer->expects($this->once())
->method('method')
->with($this->equalTo($arg1));
But the method should take two parameters. I am only testing that the first parameter is being passed correctly (as $arg1).
How do test the second...
I am trying to test a class that manages data access in the database (you know, CRUD, essentially). The DB library we're using happens to have an API wherein you first get the table object by a static call:
function getFoo($id) {
$MyTableRepresentation = DB_DataObject::factory("mytable");
$MyTableRepresentation->get($id);
... do s...
Hi,
I use phpUnit on a integration server to run all tests and if I lauch phpunit command from the command line, I receive
PHPUnit 3.2.18 by Sebastian Bergmann.
F..III..I......I.IIII...
Time: 6 seconds
There was 1 failure:
1) Warning(PHPUnit_Framework_Warning)
No tests found in class "TU".
FAILURES
Tests: 24, Failures: 1, Incomplete: ...