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?

Answers


PHPUnit is the de-facto standard for UnitTesting in PHP. It can do BD Testing to a limited extent:

The PHPUnit_Extensions_Story_TestCase class adds a story framework that faciliates the definition of a Domain-Specific Language for Behaviour-Driven Development. Inside a scenario, given(), when(), and then() each represent a step. and() is the same kind as the previous step. The following methods are declared abstract in PHPUnit_Extensions_Story_TestCase and need to be implemented:

runGiven(&$world, $action, $arguments)
...

runWhen(&$world, $action, $arguments)
...

runThen(&$world, $action, $arguments)
...

Edit: An more sophisticated alternative might be Cucumber with Behat


PHPSpec is a Behaviour-Driven Development framework for php. I've not used it myself yet, though, so I can't comment on it specifically.


Behat! Built on top of Symfony 2 components. Syntactically, not as nice as Ruby implementation but still get the benefits of BDD.

I just stumbled upon it myself and haven't used it yet. From a glance, it looks like it's using closures (which it would need to do to work like RSpec/Cucumber) which is a PHP 5.3 addition.

http://behat.org/


There are few of RSpec clones in PHP.

PHPSpec Spectrum

Also there is an original testing framework Codeception


If you are only intrested in the output of tests, you could use phpunit-progress which makes your tests results look exactly like RSpecs' results.


Bee is very similar, it is still very young, but i use it for some projects.

Hope this helps...


Selenium is another one worth to mention here.


Need Your Help

Can you catch a native exception in C# code?

c# .net exception

In C# code can you catch a native exception thrown from deep in some unmanaged library? If so do you need to do anything differently to catch it or does a standard try...catch get it?

How to get the minimum crop-able dimension of an image using PHP with aspect ratio?

javascript php jquery image

I am looking to limit the minimum width and height of the cropping selection area in aspect ratio, so that the user cannot take a very very small section of an image.