PHPackages                             guitarneck/taphp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. guitarneck/taphp

ActiveLibrary[Testing &amp; Quality](/categories/testing)

guitarneck/taphp
================

TAP producer library for PHP.

1.1.1(3y ago)1693MITPHPPHP &gt;=5.3.0

Since May 19Pushed 3y ago1 watchersCompare

[ Source](https://github.com/guitarneck/taphp)[ Packagist](https://packagist.org/packages/guitarneck/taphp)[ Docs](https://github.com/guitarneck/taphp)[ RSS](/packages/guitarneck-taphp/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (1)Versions (5)Used By (3)

[![cirrus-ci - test php5.6](https://camo.githubusercontent.com/956003d894983da699e5e4322679d54dabca76e9d04f768b589fc27303bd0999/68747470733a2f2f696d672e736869656c64732e696f2f6369727275732f6769746875622f6775697461726e65636b2f74617068703f7461736b3d496e746567726174696f6e2532305465737473253230706870253230352e36)](https://camo.githubusercontent.com/956003d894983da699e5e4322679d54dabca76e9d04f768b589fc27303bd0999/68747470733a2f2f696d672e736869656c64732e696f2f6369727275732f6769746875622f6775697461726e65636b2f74617068703f7461736b3d496e746567726174696f6e2532305465737473253230706870253230352e36) [![cirrus-ci - test php7.4](https://camo.githubusercontent.com/249d68f5bf474e3ae580ba0ca598c395ed5fb5282258730f44b2bf64d4ac4316/68747470733a2f2f696d672e736869656c64732e696f2f6369727275732f6769746875622f6775697461726e65636b2f74617068703f7461736b3d496e746567726174696f6e2532305465737473253230706870253230372e34)](https://camo.githubusercontent.com/249d68f5bf474e3ae580ba0ca598c395ed5fb5282258730f44b2bf64d4ac4316/68747470733a2f2f696d672e736869656c64732e696f2f6369727275732f6769746875622f6775697461726e65636b2f74617068703f7461736b3d496e746567726174696f6e2532305465737473253230706870253230372e34) [![cirrus-ci - test php8.0](https://camo.githubusercontent.com/f2f8c2e690c2bce4c8eb73a0ca60148fe80de6e2b94df6cd1b7139f962d21d8e/68747470733a2f2f696d672e736869656c64732e696f2f6369727275732f6769746875622f6775697461726e65636b2f74617068703f7461736b3d496e746567726174696f6e2532305465737473253230706870253230382e30)](https://camo.githubusercontent.com/f2f8c2e690c2bce4c8eb73a0ca60148fe80de6e2b94df6cd1b7139f962d21d8e/68747470733a2f2f696d672e736869656c64732e696f2f6369727275732f6769746875622f6775697461726e65636b2f74617068703f7461736b3d496e746567726174696f6e2532305465737473253230706870253230382e30)

---

[![](./taphp-logo.svg)](./taphp-logo.svg)

taphp
=====

[](#taphp)

TAP producer library for PHP. Based on tape for node.

This library is not psr-0/4 compliant. Indeed, its contains functions to organize the running tests that make it unfriendly with composer's autoload way.

> Tested on PHP versions : 5.6.9, 7.4.13 ,8.0.0

example
=======

[](#example)

with composer :

```
require dirname(__DIR__).'/vendor/guitarneck/taphp/taphp.lib.php';
```

without composer :

```
require_once 'taphp.lib.php';
```

```
test('timing test', function ($t) {
   $t->plan(2);

   $t->equal(get_class($t), 'TAPHP');
   $start = time();

   sleep(1);
   $t->equal(time() - $start, 0);
});
```

```
$ php .\test.php
TAP version 13
# timing test
ok 1 it should strictly be equal
not ok 2 it should strictly be equal
  ---
  actual  : 1
  expected: 0
  ...
1..2
# tests 2 (1.0868s)
# pass  1
# fail  1

```

TAPHP
=====

[](#taphp-1)

This class is a singleton.

instance()
----------

[](#instance)

Returns the instance for this class. If realy you need it.

discardExit ()
--------------

[](#discardexit-)

This method prevents TAPHP to terminate with an exit code. It can be usefull in some circonstances, when tasks still to be done.

functions
=========

[](#functions)

The functions and methods are nearly the same than in [tape](https://github.com/substack/tape), with some differents due to PHP language.

The so called `deep` methods are here for compliance with `tape`. PHP does it nativly.

only ( \[$name\], \[$options\], $callback )
-------------------------------------------

[](#only--name-options-callback-)

Declare a test that will be the only one to be runned.

skip ( \[$name\], \[$options\], $callback )
-------------------------------------------

[](#skip--name-options-callback-)

Declare a test that will be skipped. It won't run.

test ( \[$name\], \[$options\], $callback )
-------------------------------------------

[](#test--name-options-callback-)

Declare a new test. `$name` and `$options` are optional. `$callback` will be fired after preceding one's, with a parameter giving access to `TAPHP` object's methods.

todo ( \[$name\], \[$options\], $callback )
-------------------------------------------

[](#todo--name-options-callback-)

Declare a test that still needs to do. Failure will be allowed.

options
-------

[](#options)

Available `options` are:

- 'todo' =&gt; true|false. See function [todo](##todo-(-%5B$name%5D,-%5B$options%5D,-$callback-)) and method [todo](##todo-(-%5B$text%5D,-%5B$options%5D-)).
- 'skip' =&gt; true|false. See function [skip](##skip-(-%5B$name%5D,-%5B$options%5D,-$callback-)) and method [skip](##skip-(-%5B$text%5D,-%5B$options%5D-)).
- 'only' =&gt; true|false. See function [only](##only-(-%5B$name%5D,-%5B$options%5D,-$callback-)).
- 'timeout' =&gt; null|integer. Sets a timeout for the test, after which it will fail. See method [timeout](##timeout-(-$callback,-$ms,-%5B$text%5D-)).

methods
=======

[](#methods)

assert ( $condition, \[$text\] )
--------------------------------

[](#assert--condition-text-)

Assert that `condition` is truthy with an optional description of the assertion `$text`.

Aliases: `ok`, `true`

bailout ( \[$text\] )
---------------------

[](#bailout--text-)

Generate an immediate exit and stop of all the tests with and optional `$text` as reason.

comment ( $text )
-----------------

[](#comment--text-)

Generate a comment with a message `$text`.

deepEqual ( $any, $val, \[$text\] )
-----------------------------------

[](#deepequal--any-val-text-)

Assert that `$any === $val` with an optional description of the assertion `$text`.

Aliases: `deepEquals`, `isEquivalent`, `same`, `deep_equal`

deepLooseEqual ( $any, $val, \[$text\] )
----------------------------------------

[](#deeplooseequal--any-val-text-)

Assert that `$any == $val` with an optional description of the assertion `$text`.

Aliases: `deep_loose_equal`

end ( \[$error\] )
------------------

[](#end--error-)

Declare the end of a test, with an optional generated `$error`.

error ( $error, \[$text\] )
---------------------------

[](#error--error-text-)

Generate a failure for a given `$error`, as an object type of Exception, with an optional `$test` description.

Aliases: `ifError`, `ifErr`, `iferror`, `if_error`

exception ( $exception, \[$text\] )
-----------------------------------

[](#exception--exception-text-)

Generate a failure for a given `$exception`, as an object type of Exception, with an optional `$test` description.

Aliases: `ifException`, `ifExcept`, `ifExpt`, `ifExp`, `ifexception`, `if_exception`

fail ( \[$text\], \[$options\] )
--------------------------------

[](#fail--text-options-)

Generate a failing assertion with a message `$text`.

looseEqual ( $any, $val, \[$text\] )
------------------------------------

[](#looseequal--any-val-text-)

Assert that `$any == $val` with an optional description of the assertion `$text`.

Aliases: `looseEquals`, `loose_equal`

no ( $condition, \[$text\] )
----------------------------

[](#no--condition-text-)

Assert that `condition` is falsy with an optional description of the assertion `$text`.

Aliases: `notOK`, `false`, `notok`, `not_ok`

notDeepEqual ( $any, $val, \[$text\] )
--------------------------------------

[](#notdeepequal--any-val-text-)

Assert that `$any !== $val` with an optional description of the assertion `$text`.

Aliases: `notDeepEquals`, `notEquivalent`, `notDeeply`, `notSame`, `isNotDeepEqual`, `isNotDeeply`, `isNotEquivalent`, `isInequivalent`, `not_deep_equal`, `not_same`

notDeepLooseEqual ( $any, $val, \[$text\] )
-------------------------------------------

[](#notdeeplooseequal--any-val-text-)

Assert that `$any != $val` with an optional description of the assertion `$text`.

Aliases: `not_deep_loose_equal`

notLooseEqual ( $any, $val, \[$text\] )
---------------------------------------

[](#notlooseequal--any-val-text-)

Assert that `$any != $val` with an optional description of the assertion `$text`.

Aliases: `notLooseEquals`, `not_loose_equal`

notStrictEqual ( $any, $val, \[$text\] )
----------------------------------------

[](#notstrictequal--any-val-text-)

Assert that `$any !== $val` with an optional description of the assertion `$text`.

Aliases: `notEqual`, `notEquals`, `isNotEqual`, `doesNotEqual`, `isInequal`, `notStrictEquals`, `isNot`, `not`, `not_strict_equal`, `not_equal`, `is_not_equal`, `is_not`

pass ( \[$text\], \[$options\] )
--------------------------------

[](#pass--text-options-)

Generate a passing assertion with a message `$text`.

plan ( $n )
-----------

[](#plan--n-)

Declare the number of assertions that's about to be runned. `end()` will be called automatically after, or an error occurs if the number of assertions doesn't match.

restoreTimeLimit ()
-------------------

[](#restoretimelimit-)

Restore PHP `max_execution_time`.

setTimeLimit ( $seconds )
-------------------------

[](#settimelimit--seconds-)

Change PHP `max_execution_time`.

skip ( \[$text\], \[$options\] )
--------------------------------

[](#skip--text-options-)

Generate a `skip` with and optional `$text` ane leaving the running test.

strictEqual ( $any, $val, \[$text\] )
-------------------------------------

[](#strictequal--any-val-text-)

Assert that `$any === $val` with an optional description of the assertion `$text`.

Aliases: `equal`, `equals`, `isEqual`, `strictEquals`, `is`, `strict_equal`, `is_equal`

test ( \[$name\], \[$options\], $callback )
-------------------------------------------

[](#test--name-options-callback--1)

Generate a new test at run time.

throws ( $thrower, \[$throwed\], \[$text\] )
--------------------------------------------

[](#throws--thrower-throwed-text-)

Assert that the function call `$thrower` throws an exception. `$throwed` can be a string, a regular expression, an exception, an array describing some exception properties, or null.

timeout ( $callback, $ms, \[$text\] )
-------------------------------------

[](#timeout--callback-ms-text-)

Generate an assertion that should run before `$ms` microseconds are elapse. Or it fails with an optional `$text`.

todo ( \[$text\], \[$options\] )
--------------------------------

[](#todo--text-options-)

Generate a `todo` with and optional `$text` inside a test, switching the next assertions to `todo` mode.

---

License
=======

[](#license)

[MIT © guitarneck](./LICENSE)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~199 days

Total

4

Last Release

1228d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7b4bca520f532ba08b5def6e4803e5832f2e04d5008aee310bde0c0cb9db1be1?d=identicon)[guitarneck](/maintainers/guitarneck)

---

Top Contributors

[![guitarneck](https://avatars.githubusercontent.com/u/34680484?v=4)](https://github.com/guitarneck "guitarneck (37 commits)")

---

Tags

phpunit testtesting-toolstaptape

### Embed Badge

![Health badge](/badges/guitarneck-taphp/health.svg)

```
[![Health](https://phpackages.com/badges/guitarneck-taphp/health.svg)](https://phpackages.com/packages/guitarneck-taphp)
```

###  Alternatives

[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[letsdrink/ouzo-goodies

Utility classes, test assertions and mocking framework extracted from Ouzo framework.

132617.9k7](/packages/letsdrink-ouzo-goodies)[yegor256/phprack

Light framework for automation of integration tests

254.7k](/packages/yegor256-phprack)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
