<?php define('testing', true); require_once '../modules/index.php'; use Testify\Testify; use Enpowi\App; use RedBeanPHP\R; $tf = new Testify(App::$config->siteName . ' Test Suite'); $tf->beforeEach(function () { R::nuke(); }); $di = new RecursiveDirectoryIterator('server', RecursiveDirectoryIterator::SKIP_DOTS); foreach (new RecursiveIteratorIterator($di) as $filename => $file) { require $filename; } $tf();
<?php /* * A more complex example using beforeEach and data * */ require '../vendor/autoload.php'; use Testify\Testify; $tf = new Testify("A bit more advanced test suite"); // Before each is called before every test case $tf->beforeEach(function ($tf) { // Use the data property to share variables across tests $tf->data->arr = array('a', 'b', 'c', 'd', 'e', 'f'); }); $tf->test("Testing Array Pop", function ($tf) { $arr =& $tf->data->arr; $tf->assertEquals(array_pop($arr), 'f'); $tf->assertEquals(array_pop($arr), 'e'); $tf->assertEquals(array_pop($arr), 'd'); $tf->assertEquals(array_pop($arr), 'c'); }); $tf->test("Testing In Array", function ($tf) { // beforeEach has restored the array $arr =& $tf->data->arr; $tf->assertInArray('a', $arr); $tf->assertInArray('b', $arr); $tf->assertInArray('c', $arr); $tf->assertInArray('d', $arr); $tf->assertInArray('e', $arr); $tf->assertInArray('f', $arr); $tf->assertNotInArray('g', $arr);