<?php
use Testify\Testify;
$testify = new Testify('test of global values $str and $num');
$testify->test('first test', function($testify) {
$num = $testify->data->num;
$str = $testify->data->str;
$testify->assertEquals($num, 2);
$testify->assertEquals($str, '-');
});
$testify->test('second test', function($testify) {
$num = $testify->data->num;
$str = $testify->data->str;
$testify->assertEquals($num, 3);
$testify->assertEquals($str, '--');
});
// called before the tests
$testify->before(function($testify) {
$testify->data->num = 1;
$testify->data->str = '-';
});
// called before every test
$testify->beforeEach(function($testify) {
++$testify->data->num;
});
// called after every test
$testify->afterEach(function($testify) {
$testify->data->str .= '-';
});
// called after tests
$testify->after(function($testify) {
$num = $testify->data->num;
$str = $testify->data->str;
echo 'Values at the end of tests: ' .
$str . ' and ' . $num . PHP_EOL;
});
// run the tests and echo results
$testify->run();