Skip to content
No description or website provided.
Pull request Compare This branch is 108 commits behind funkatron:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


A simple test suite for PHP 5.3+, partially inspired by QUnit.


  • Simple to write tests and get output – start writing tests fast
  • Short, straightforward syntax
  • Can be run from the CLI – no web server required
  • Fancy colored output in terminal


use \FUnit\fu;
require __DIR__ . '/FUnit.php';

fu::test("this is a test", function() {
    fu::ok(1, "the integer '1' is okay");
    fu::ok(0, "the integer '0' is not okay"); // this will fail!


Will output:

Running test 'this is a test...'
TEST: this is a test (1/2):
 * PASS ok() the integer '1' is okay
 * FAIL ok() the integer '0' is not okay

TOTAL ASSERTIONS: 1 pass, 1 fail, 0 expected fail, 2 total
TESTS: 1 run, 0 pass, 1 total

See the example.php file for more.


  • fu::test($name, \Closure $test)
    Add a test with the name $name and an anonymous function $test. $test would contain various assertions, like fu::ok()

  • fu::ok($a, $msg = null)
    Assert that $a is truthy. Optional $msg describes the test

  • fu::equal($a, $b, $msg = null)
    Assert that $a == $b. Optional $msg describes the test

  • fu::not_equal($a, $b, $msg = null)
    Assert that $a != $b. Optional $msg describes the test

  • fu::strict_equal($a, $b, $msg = null)
    Assert that $a === $b. Optional $msg describes the test

  • fu::not_strict_equal($a, $b, $msg = null)
    Assert that $a !== $b. Optional $msg describes the test

  • fu::has($needle, $haystack, $msg = null)
    Assert that an array or object ($haystack) has a key or property ($needle)

  • fu::fail($msg = null, [$expected = null])
    Force a failed assertion. If $expected === true, it's marked as an expected failure

  • fu::expect_fail($msg = null)
    Assets an expected failure. Equivalent to fu::fail('msg', true)

  • fu::setup(\Closure $setup)
    Register a function to run at the start of each test. See fu::fixture()

  • fu::teardown(\Closure $setup)
    Register a function to run at the end of each test. See fu::fixture() and fu::reset_fixtures()

  • fu::fixture($key, [$val])
    Retrieve or register a fixture. Use this in fu::setup() to assign fixtures to keys, and retrieve those fixtures in your tests

  • fu::reset_fixtures()
    Clears out all fixtures in the fu::$fixtures array. This doesn't guarantee clean shutdown/close

  • fu::run($report = true)
    Runs the registered tests. If false is passed, the report output is suppressed


Install with Composer

If you're using Composer to manage dependencies, you can add FUnit with it.

    "require": {
        "funkatron/funit": ">=1.0"

Note that FUnit has not yet reached 1.0!

Install source from GitHub

To install the source code:

git clone git://

And include it in your scripts:

require_once '/path/to/FUnit/FUnit.php';

Install source from zip/tarball

Alternatively, you can fetch a tarball or zipball:

$ curl | tar xzv
$ wget -O - | tar xzv

Using a Class Loader

If you're using a class loader (e.g., Symfony Class Loader) for PSR-0-style class loading:

$loader->registerNamespace('FUnit', 'path/to/vendor/FUnit');
Something went wrong with that request. Please try again.