Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

phpunit/phpunit 11.0.9

The PHP Unit Testing framework.
Package summary
Share
0
issues
0
licenses
Package created
18 Sep 2012
Version published
28 Mar 2024
Maintainers
1
Total deps
0
Direct deps
0
License
BSD-3-Clause
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does phpunit/phpunit do?

PHPUnit is a programmer-oriented testing framework for PHP. It follows an instance of the xUnit architecture for unit testing frameworks, serving as a robust system designed to facilitate easy and efficient testing of the individual units of source code in your PHP applications. This ensures that your code is thoroughly vetted and expected to perform optimally.

How do you use phpunit/phpunit?

To use PHPUnit, first you'll need to install it. There are primarily two ways to do this:

Using PHAR:

You can download a PHP Archive (PHAR) that contains all the required dependencies of PHPUnit in a single file. Here's how to do it:

$ wget https://phar.phpunit.de/phpunit-X.Y.phar
$ php phpunit-X.Y.phar --version

Please replace X.Y with the version of PHPUnit you are interested in.

Using Composer:

Another way to install PHPUnit is by using Composer, a tool for dependency management in PHP.

$ composer require --dev phpunit/phpunit ^10

After installation, you can write PHPUnit tests for your PHP applications. For example:

use PHPUnit\Framework\TestCase;

class SomeClassTest extends TestCase
{
    public function testPerform()
    {
        $instance = new SomeClass();

        $result = $instance->perform('action');

        $this->assertSame('expected', $result);
    }
}

And then run them using the PHPUnit PHAR or vendor/bin/phpunit:

$ ./phpunit-X.Y.phar tests
or
$ ./vendor/bin/phpunit tests

Where are the phpunit/phpunit docs?

The documentation for PHPUnit is available on the official PHPUnit website and it provides an in-depth guide on getting started with PHPUnit and its various modules. You can also check the documentation and contribution guidelines on their official GitHub repository. The contributors to the documentation can be found here.