PHPackages                             odota/odota - 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. odota/odota

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

odota/odota
===========

Programmed dialogue with interactive programs for system testing, written in PHP

0131PHP

Since Sep 23Pushed 9y agoCompare

[ Source](https://github.com/odota-php/odota)[ Packagist](https://packagist.org/packages/odota/odota)[ RSS](/packages/odota-odota/feed)WikiDiscussions develop Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Odota [![stability-experimental](https://cloud.githubusercontent.com/assets/1734555/18616629/a740d892-7dbf-11e6-8718-64afa66fac0d.png)](https://cloud.githubusercontent.com/assets/1734555/18616629/a740d892-7dbf-11e6-8718-64afa66fac0d.png) [![Travis build status](https://camo.githubusercontent.com/849f4c3ac408953482bbb06b3b321ceea955070bcaf547fd822089a959dc6ed3/68747470733a2f2f7472617669732d63692e6f72672f6f646f74612d7068702f6f646f74612e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/odota-php/odota)
===================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#odota--)

> **o‧do‧ta** — Imperative form of Finnish **odottaa**: *to wait for, await, expect, anticipate*.

Programmed dialogue with interactive programs for system testing using PHP 5.6, PHP 7.x and HHVM. Written in PHP, it is easily integrated in your testing framework of choice.

---

- [Installation](#installation)
- [API](#api)
- [Limitations](#limitations)
- [Caveats](#caveats)
- [Platform support](#platform-support)
- [Why...](#why)
    - [... not test against the PHP CLI application in user-land?](#-not-test-against-the-php-cli-application-in-user-land)
    - [... create a PHP library when there are tools like `expect` and `empty`?](#-create-a-php-library-when-there-are-tools-like-expect-and-empty)

---

Installation
------------

[](#installation)

```
$ composer require --dev odota/odota

```

API
---

[](#api)

Examples explain it all.

```
use function Odota\Odota\spawn;

// Programmed dialogue with an interactive program.
spawn('echo -n " > "; read name; sleep 2; echo "Hello, $name!"')
    ->expect(' > ')
    ->sendln('Bob')
    ->timeoutAfter(3)
    ->expect('Hello, Bob!')
    ->expectExitCode(0);

// Expectation time-outs default to 100ms, but can be adjusted.
spawn('sleep 2; echo OK')
    ->timeoutAfter(1)
    ->expect('OK');
// Odota\Odota\ExpectationTimedOutException

// Expect programs to fail.
spawn('test -e non-existent-file')
    ->expectExitCode(1);

// Expect output on standard error
spawn('echo LOG >&2')
    ->expectError('LOG');
```

Limitations
-----------

[](#limitations)

Currently, the communication to the system-under-test happens via pipes. Programs may determine that their input doesn't come from a terminal—or pseudo-terminal for that matter—and disable interactivity. Other implementations come to mind, and these may be implemented as different drivers in the future:

- `proc_open()` with pty descriptors instead of pipes. Pseudo-terminal support in PHP, however, is undocumented and not supported by Travis at the time of writing (Sep 2016).
- Writing a script to STDIN of the [`expect`](http://linux.die.net/man/1/expect) binary.
- Using the [`empty`](http://manpages.ubuntu.com/manpages/trusty/man1/empty.1.html) command.

When testing Symfony CLI applications, set the [`SHELL_INTERACTIVE`](https://github.com/symfony/symfony/pull/14102) environment variable to true to force interactivity.

Caveats
-------

[](#caveats)

To pass the test caller's environment variables on to the system under test, the ini setting `variables_order` must include `E` to fill the `$_ENV`superglobal. Any easy fix is by including this ini setting on the command line when calling your test framework:

```
$ php -d variables_order=EGPCS vendor/bin/phpunit
```

Platform support
----------------

[](#platform-support)

Odota is tested against PHP 5.6, 7.x and HHVM 3.6 on Ubuntu-like systems. It should work on common Unixy systems, including Mac OS. Windows is not supported, because `stream_select()` on file descriptors returned by `proc_open()`[will fail](http://php.net/manual/en/function.stream-select.php "Documentation for the PHP function `stream_select()` (php.net)") under Windows.

Why...
------

[](#why)

### ... not test against the PHP CLI application in user-land?

[](#-not-test-against-the-php-cli-application-in-user-land)

A simpler way of testing PHP CLI applications would be to boot the application in the same execution context as the test, and, perhaps, mock the unit that abstracts interactivity like asking questions. There are a couple of reasons for testing against the final executable. Let's start with a remark by Nat Price:

> System tests exercise the entire system end-to-end, driving the system through its published remote interfaces and user interface. They also exercise the packaging, deployment and startup of the system. ([source](http://www.natpryce.com/articles/000772.html "Nat Pryce on System Tests (natpryce.com)"), as of September 17, 2016)

So testing against the final executable (the “production” executable), you get closer to the “production” state of your application, namely as a PHP script called from the shell. The difference is even greater when you package your application as a [Phar](http://php.net/manual/en/book.phar.php "Documentation about PHP Archives (php.net)").

### ... create a PHP library when there are tools like `expect` and `empty`?

[](#-create-a-php-library-when-there-are-tools-like-expect-and-empty)

- To enable testing with a more familiar language, PHP. `expect` uses Tcl.
- To enable testing with your favourite PHP testing framework.
- To provide a testing API, rather than just interactive dialogue.
- To allow testing your system-under-test's side-effects, like file system changes, in the same test context.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1734555?v=4)[Reinier Kip](/maintainers/rjkip)[@rjkip](https://github.com/rjkip)

---

Top Contributors

[![rjkip](https://avatars.githubusercontent.com/u/1734555?v=4)](https://github.com/rjkip "rjkip (66 commits)")

### Embed Badge

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

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

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14228.7M341](/packages/dms-phpunit-arraysubset-asserts)[phpbenchmark/phpbenchmark

Easy to use benchmark toolkit for your PHP-application. This library contains classes for comparing algorithms as well as benchmarking application responses

8011.5k2](/packages/phpbenchmark-phpbenchmark)

PHPackages © 2026

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