phptest/phptest

Really simple test harness for PHP

dev-master 2014-06-18 23:12 UTC

This package is not auto-updated.

Last update: 2024-04-09 00:05:51 UTC


README

Master build: Master branch build status
Requires: PHP >= 5.4 || HHVM >= 3.0

Note: This is a work in progress. Contributions through feature requests or pull requests are most welcome.

PHPTest is a test framework for PHP, written in the same vein as PHPUnit, SimpleTest, et al. No assumptions are made as to whether you're writing pure unit tests, functional tests, integration tests, or other. There are also no assumptions about the format of the tests, whether they're written in classic PHPUnit style, functional, or other.

The main effort of this library is to make testing easy to write, quick to run and simple to integrate with your development and deployment process, while allowing extensibility through extensions and events.

It can be installed in whichever way you prefer, but I recommend Composer.

{
    "require-dev": {
        "phptest/phptest": "*"
    }
}

APIs

Functional

The functional API adds support for testing with simple closures, as you would with any functional language. Further usage examples can be found in example/functional.

<?php

suite('suite name', function () {

    test('test name', function () {
        // test something
    });

    suite('nested suite', function () {

        test('nested test', function () {
            // test something
        });

        test('nested test with args', function ($arg) {
            // each args array creates a separate test
        }, [['foo'], ['bar']]);

    });

});

Contributing

Contributions are accepted via Pull Request, but passing unit tests must be included before it will be considered for merge. Tests are currently run through PHPUnit and will be updated when PHPTest is more stable.

$ curl -O https://raw.github.com/phptest/vagrant/master/Vagrantfile
$ vagrant up
$ vagrant ssh
...

$ cd /srv
$ composer install --dev
$ vendor/bin/phpunit test

License

The content of this library is released under the MIT License by Andrew Lawson.
You can find a copy of this license in LICENSE or at http://opensource.org/licenses/mit.