Quick reference
jonathangjertsen edited this page Jun 18, 2017
·
2 revisions
Include the library:
use Proposition\Proposition;
Create a new Proposition object:
$num_tests = 100;
$proposition = new Proposition($num_tests);
Describe your inputs:
$max_strlen = 10;
$proposition->given(Proposition::integers(), Proposition::letterStrings($max_strlen));
Define a function to call with those inputs. Let's say you want to check the constructor of your User
class:
$proposition->call(function($user_id, $username) {
$user = new User($user_id, $username);
// ...assertions etc.
});
You can reuse the Proposition
instance after it has been called.
You can also chain given
and call
like so (calling given
multiple times is like calling it once with the combined parameters):
$proposition->given(...$generators)->given(...$more_generators)->call($callback);