You can conduct visual and usability testing manually, but for functionality, acceptance and unit testing, cross-browser testing, an automated PHP framework can help speed the test cycles substantially. So here are some of the best PHP frameworks that I have come across. I have also provided their pros and cons to help you decide better (as mentioned in Best PHP automated frameworks)
PHPUnit is considered one of the best PHP frameworks for test automation, meant for unit testing of an application developed using PHP language. Just like JUnit, it is an instance of xUnit and works almost in a similar manner.
- Just like other test automation frameworks meant for unit testing,
PHPUnit helps you in developing a code that performs well and is
easy to maintain.
- It also helps you to identify defects that may arise before the code
is pushed to further testing phases.
- Issues are detected early during the development phase since the
testing is carried out by developers only.
- Unit testing helps in detecting issues and fixing the code at a
certain fragment of the application, thereby leaving other fragments
intact and without any chance of breakage.
- Debugging process is made simpler. Debugging is required only when a
the certain unit test fails.
The only disadvantage of PHPUnit is that, for testing multiple functions, the developer is required to add cover annotations. By any chance, if you change the name of the method or function without updating the @covers annotation, testing is skipped for that certain method or function.
Codeception is an automation testing framework having multiple features apart from only Unit testing. The framework is derived from PHPUnit and has the ability to manage Functional, Unit as well as Acceptance testing of a web application.
- First of all, you will get the best way to write test cases in PHP
language. Syntax highlighting also eliminates the chance of mistakes
- Writing the test cases are very simple.
- You can do not only unit testing but also others like Acceptance or
functional testing just by adding suites.
- Supports multiple frameworks without any need of an extension or
changing the code. If your project is migrating, your old test cases
written using Codeception will work just the same way.
- The Db module of Codeception helps the tester to fetch whatever you
need from the database and clean up the data from your test module.
Isolating the tests thus becomes much easier.
- You can run complex test cases by using XPath locators or CSS
selectors. REST and SOAP web services can also be tested simply
- The tests are simple and readable enough to be clearly understood by
a person coming from a non-technical background.
- Since the framework emulates a browser, the chances of getting a
false-positive result increase.
- Requires a framework to start testing.
Laravel task is a browser-based test automation tool for testing PHP based web applications. This tool also helps you to automate repetitive tasks. Using this framework, you can either test the applications you developed or any other published website using Google Chrome.
- You can develop the best authentication and authorization script.
- Presentation views like HTML and business logic like SQL queries can
be easily separated.
- The migration feature of Laravel allows you to create database
tables of standard format. For developers, Laravel can be used with
Angular JS for developing large single-page web applications.
- The tool can also be used to create dynamic HTML elements since it
supports Vue js as well.
- Asset compilation can also be done with elixir or gulp that minifies
js and CSS files, resulting in the faster performance of the
The only disadvantage of Laravel is that it cannot be used on other browsers except Chrome. Nowadays when customers demand a website that is cross-browser compatible, this is certainly a drawback.
Behat is a behavior-driven testing tool for applications developed using PHP. The aim of the tool is to aid the nonverbal communication between stakeholders, management, and developers during the software development life cycle.
- Test cases are written in a human-readable manner, the features
describe the specs of individual sites and the test suite provides
very clear documentation consisting of the web application’s
- Helps in maintaining an application having a stable deployment
cycle. All you need to do is run the tests, detect and fix the bugs
and repeat the process until the project passes all the test cases,
resulting in a stable application.
- The acceptance criteria being easy to understand, developers get
clarity regarding what the customer wants. Without any blockage,
they can start developing and add new functionality. Once the
functionality successfully passes the test cases, it gets ready for
- It helps you to work closely with the customer until you two
mutually agree on how a product should work. Thereby, forcing you to
follow the standard protocols of behavior-driven development.
- Behat takes quite some time for implementation.
- You will also have to rethink and restructure the entire development
- Discussion with stakeholders and developers may extend a lot until
you come to a mutual understanding of how a feature will be
PHPSpec is a popular BDD tool which helps you to write clean code using PHP. The development works by first describing how the object behaves. Once that is approved by the stakeholders, the next phase is to start coding.
- While starting test case execution, PHPSpec generates skeletons of
classes or methods based on the usage of the methods inside the test
cases. Any additional edge that you face can be covered by writing
an additional test case.
- By refactoring, you can restructure the entire code without changing
how it behaves externally.
- You can also use PHPSpec to test applications developed using
- PHPSpec has a mocking framework known as prophecy. Prophecy ensures
that for every test, the required class’s mock instance is passed to
- Testing private methods is a limitation.
- Let’s suppose your public method returns a value. It is not a part
of your object API. You cannot test that.
- Integration testing cannot be performed using PHPSpec.
- No Matter how useful Prophecy is, it cannot mock abstract methods.
Atoum is an automated framework meant for unit testing of an application that is developed using PHP language. Although it behaves a bit like PHPUnit, it is much more modern, simple and a standalone framework. Unlike PHPUnit, the test cases written using Atoum are easily readable and much simplified. Also, the asserters of Atoum enables you to write less code and test more functionalities.
- It has a flexible structure. It allows you to rename directory, test
cases or suites and whatever you like.
- There are 3 engines for executing the test cases. For a single test
case, you can define a specific engine apart from the engine
provided by default.
- You can write a test case in multiple ways. Either by using the
classic way, by an academic way using empty asserters or a much
better and smarter way by using the asserters of Atoum.
- Test cases are readable and easier to understand since Atoum
provides a set of natural assertions.
- You are no longer required to manipulate real directories. While
running the test cases, Atoum allows you to create a virtual file
system consisting of fake directories, reducing the risk of
mishandling real project files.
- Class constructors can be mocked. Whenever a method is called, you
can control the computational value.
- The best feature is, Atoum can easily integrate with continuous
integration tools like Gitlab, Jenkins, PHPCI, Travis CI, etc. It
can also be used with multiple IDEs like Atom, Netbeans, Sublime
Cons: I haven’t found any which cannot be resolved or creates a roadblock.
- Inclusion of JSpec, RSpec syntax.
- A much better code coverage metrics.
- You can check whether a specific method is called on your class.
- Stubbing system is much more flexible. Prophecy or Mockery is no
- You can replace the core classes and functions easily by monkey
- Icov and Istanbul are built in reporters that allow easy HTML or
- Coveralls, Clobber, Climate are some built in exporters that allow
you to easily push the code.
Cons: Kahlan does not have the ability of Storytelling or developing scenario based BDD.
Peridot is a highly reliable, extensible PHP framework that supports testing of an application developed under behavior driven environment. The framework is lightweight and faster than PHPSpec or other frameworks. Also, the fact that it is event-driven makes it popular since developing plugins are much easier when you are using Peridot.
- Just like Kahlan, it also uses describe-it syntax to write natural
and human readable test cases. Test cases written using Peridot can
be easily understood by someone belonging to a nontechnical
- Provides a painless experience of writing ad hocs since it is
- You can also add custom reporters, helpers and plugins easily.
- If your test cases are bulky, Peridot can run them concurrently
since it is lightweight and faster than other frameworks.
Cons: The only drawback is that it is not suitable to be used in an Agile application since its features are not vast like Behat.
Selenium is the best automation framework for automated cross browser testing of a web application. For an application developed using PHP, you can use PHP bindings for developer browser-based automation test cases. The framework is flexible and the latest version of Selenium web driver runs flawlessly across all the major browsers.
- First of all the framework is open source. Anyone can download the
source code and modify it according to project requirements.
- It supports multiple programming languages. Even if your project
someday migrates from PHP to any other technology, you can still use
Selenium for executing the test cases.
- Selenium can be used on any operating system and it supports all the
major browsers like Chrome, IE, Opera, Safari or Firefox.
- By using very less hardware resources, you can execute multiple test
cases parallely using Selenium.
The framework is a bit difficult and test case creation takes a bit of time. The learning curve is also a bit steep since the framework is evolving day by day.
Since the software is open-source, there is no reliable support if you face any complications.
Setting up the test environment is also complicated and also, it does not have any support for integration with test management tools in case you wish to report bugs.
You can only perform browser compatibility testing on the browsers available on your local machine.
I hope the tools mentioned above will help you choose the best PHP automated frameworks according to your project requirement.