PHPackages                             jonathrg/proposition - 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. jonathrg/proposition

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

jonathrg/proposition
====================

Lightweight property-based testing for PHP

v0.9(8y ago)0241[4 issues](https://github.com/jonathangjertsen/Proposition/issues)MITPHPPHP &gt;=5.6CI failing

Since Jun 18Pushed 5y ago1 watchersCompare

[ Source](https://github.com/jonathangjertsen/Proposition)[ Packagist](https://packagist.org/packages/jonathrg/proposition)[ Docs](https://github.com/jonathangjertsen/Proposition)[ RSS](/packages/jonathrg-proposition/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

Proposition
===========

[](#proposition)

Lightweight property-based testing library for PHP. Inspired by Python's Hypothesis library.

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

[](#installation)

Because the API is not fully stable yet, you must specify dev-master to composer install:

```
composer install jonathrg/proposition:dev-master

```

What is property-based testing?
-------------------------------

[](#what-is-property-based-testing)

According to [the first blog post I found about it](http://blog.jessitron.com/2013/04/property-based-testing-what-is-it.html),

> Property-based tests make statements about the output of your code based on the input, and these statements are verified for many different possible inputs. A property-based testing framework runs the same test over and over with generated input.

This is in contrast to example-based testing, where you have to hand-write your inputs. A property-based testing library like Proposition lets you test your code with thousands and thousands of input combinations (including all sorts of edge cases) with just a few lines of code. As an example, Proposition uses itself to test itself, and does so with about 4000 assertions per line of test code.

Documentation
-------------

[](#documentation)

See the [Wiki](https://github.com/jonathangjertsen/Proposition/wiki), especially the [Quick reference](https://github.com/jonathangjertsen/Proposition/wiki/Quick-Reference)

Example usage
-------------

[](#example-usage)

There are some examples of the values Proposition generates in the `examples` folder. Run them with PHP from the command line (see the readme.md there)

Here's a toy example showing how you would use Proposition to check whether your awesome reimplementation of `abs($a) == abs($b)` actually works.

```
use Proposition/Proposition;

function equal_magnitude($a, $b)
{
    return ($a = $b) || ($a == -$b);
}

$proposition = new Proposition();

$proposition
    ->given(Proposition::integers(), Proposition::integers())
    ->call(function($a, $b) {
        if(equal_magnitude($a, $b) != (abs($a) == abs($b))) {
            echo "ERROR!! equal_magnitude is wrong when \$a is $a and \$b is $b!\n";
        }
    });

```

Oops! We're getting a lot of error messages. We will quickly discover that we used a `=` where we should have used a `==` in our function.

In practice, you will be using this to pass a huge, automatically generated range of values into your functions and check that some property *always* holds. You might for example want to check that the output of a function has a certain relationship to your input, that the function did or did not throw an exception, and so on.

Project goals
-------------

[](#project-goals)

- Extremely lightweight and easy to use
    - You only need to `use` **one** class.
        - A simple trait for PHPUnit tests may be included in the future.
    - Dead simple API, which reads like English when you use good variable names.
    - Uses generators to produce randomized values which fulfill the given constraints.
    - Pragmatic: common use-cases already included like integers, integers within a range, strings, "garbage" data, etc.
        - But we do not need generators for every possible use-case. You are free to transform your values however you want in the callback to `call`, and you can use the `Proposition::stream()` method to generate values your own way.
    - Other than generators and callbacks, no use of "advanced" or "frameworky" features (there shall be no `Proposition\Interfaces\PropositionableIterators\PropositionableIteratorInterface`).
    - no packages in "require"
- Easy to integrate with PHPUnit but there should be NO functionality specific to that in the main `Proposition` class.
- Compatible with PHP v.7.0 and up but also v.5.6. Probably not below that.

Status
------

[](#status)

Most core functionality and documentation is complete. The plan is to fix issue #1 and issue #3, make some PHPUnit tests which test it with itself, then release it on packagist.

Contributors are welcome!

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52% 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

Unknown

Total

1

Last Release

3253d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/222c9600a0622ff7469ef4898525ca932f78a04829c18087e107d3908e976596?d=identicon)[jonathrg](/maintainers/jonathrg)

---

Top Contributors

[![jonathrg](https://avatars.githubusercontent.com/u/10761808?v=4)](https://github.com/jonathrg "jonathrg (26 commits)")[![jonathangjertsen](https://avatars.githubusercontent.com/u/7355797?v=4)](https://github.com/jonathangjertsen "jonathangjertsen (22 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (2 commits)")

---

Tags

phpphp-libraryproperty-based-testingtestingtesting-toolspropertyproperty based testingQuickCheckhypothesis

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

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

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[pdepend/pdepend

Official version of pdepend to be handled with Composer

954110.9M815](/packages/pdepend-pdepend)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

78268.9M1.5k](/packages/phpstan-phpstan-symfony)

PHPackages © 2026

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