How To Install phpunit-dbunit on Debian 9

In this tutorial we learn how to install phpunit-dbunit on Debian 9. phpunit-dbunit is DbUnit port for PHP/PHPUnit to support database interaction testing

Introduction

In this tutorial we learn how to install phpunit-dbunit on Debian 9.

What is phpunit-dbunit

phpunit-dbunit is:

DBUnit is an extension to PHPUnit, that “has been created to provide an easy way to place your database in a known state, execute your database-affecting code, and ensure that the expected data is found in the database.”, quoting the PHPUnit manual.

PHPUnit is a unit testing suite for the PHP language, modelled on the xUnit testing framework, designed by Kent Beck and Erich Gamma. If you’ve used JUnit (for Java), PyUnit (for Python), CxxUnit (for C++), or any of the other equivalents for other languages, the API for this package should seem fairly familiar. If you’ve never written unit tests before, the PHPUnit API is simple to learn and use.

There are three methods to install phpunit-dbunit on Debian 9. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install phpunit-dbunit Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install phpunit-dbunit using apt-get by running the following command:

sudo apt-get -y install phpunit-dbunit

Install phpunit-dbunit Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install phpunit-dbunit using apt by running the following command:

sudo apt -y install phpunit-dbunit

Install phpunit-dbunit Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Debian. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install phpunit-dbunit using aptitude by running the following command:

sudo aptitude -y install phpunit-dbunit

How To Uninstall phpunit-dbunit on Debian 9

To uninstall only the phpunit-dbunit package we can use the following command:

sudo apt-get remove phpunit-dbunit

Uninstall phpunit-dbunit And Its Dependencies

To uninstall phpunit-dbunit and its dependencies that are no longer needed by Debian 9, we can use the command below:

sudo apt-get -y autoremove phpunit-dbunit

Remove phpunit-dbunit Configurations and Data

To remove phpunit-dbunit configuration and data from Debian 9 we can use the following command:

sudo apt-get -y purge phpunit-dbunit

Remove phpunit-dbunit configuration, data, and all of its dependencies

We can use the following command to remove phpunit-dbunit configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge phpunit-dbunit

Dependencies

phpunit-dbunit have the following dependencies:

References

Summary

In this tutorial we learn how to install phpunit-dbunit package on Debian 9 using different package management tools: apt, apt-get and aptitude.