<?php require 'vendor/autoload.php'; $app = new \Testify\Testify(new \Testify\CommandHandler()); $loop = React\EventLoop\Factory::create(); $socket = new React\Socket\Server($loop); // This event triggers every time a new connection comes in $socket->on('connection', function ($conn) use($app) { $conn->write($app->welcome()); $conn->on('data', function ($data, $conn) use($app) { $app->handle($data, $conn); }); }); // Listen on port 1337 $socket->listen(1337); $loop->run();
<?php include "vendor/autoload.php"; $tf = new \Testify\Testify("wikiLingo test suite"); //Test Expressions $tf->test("WikiLingo Expressions", function ($tf) { (new WikiLingo\Test\TypeNamespace("Expression"))->run($tf); }); //Test Expression Error Recovery $tf->test("WikiLingo Expression Error Recovery", function ($tf) { (new WikiLingo\Test\TypeNamespace("ExpressionErrorRecovery"))->run($tf); }); //Test Plugins $tf->test("WikiLingo Plugins", function ($tf) { (new WikiLingo\Test\TypeNamespace("Plugin"))->run($tf); }); //Test WYSIWYGWikiLingo Syntax Generator $tf->test("WYSIWYGWikiLingo Syntax Generator", function ($tf) { (new WYSIWYGWikiLingo\Test\TypeNamespace("SyntaxGenerator"))->run($tf); }); ob_start(); $tf();
<?php namespace Happen; /** * Tests for \Happen\Callback */ include 'common.php'; $tf = new \Testify\Testify('Happen\\Callback'); /** * Check closures are wrapped correctly. */ $tf->test('\\Closure wrapping', function ($tf) { $callback = new \Happen\Callback(function ($x) { return $x + 1; }); $result = $callback(123); $tf->assertEqual($result, 124); }); /** * Check functions are wrapped correctly. */ $tf->test('Function wrapping', function ($tf) { $callback = new \Happen\Callback('\\Happen\\Test\\addOne'); $result = $callback(123); $tf->assertEqual($result, 124); // Check we can't set context on a function. try { $callback->bind((object) array()); $tf->fail(); } catch (\Exception $e) {
<?php namespace Happen; /** * Tests for \Happen\Eventspace */ include 'common.php'; $tf = new \Testify\Testify('Happen\\Eventspace'); // Create the root Eventspace. $tf->beforeEach(function ($tf) { $tf->data->ev_space = new \Happen\Eventspace(); }); $tf->test('Add child eventspace with callback', function ($tf) { // Get the root Eventspace. $child_name = 'john'; $root_ev_space = $tf->data->ev_space; // Create a Callback. $callback = new \Happen\Callback('\\Happen\\Test\\onJohn'); // Add the Callback to a child eventspace $child_ev_space = $root_ev_space->addChild($child_name, array($callback)); // Check a new Eventspace was created. $tf->assertTrue($child_ev_space instanceof \Happen\Eventspace); // Check the Eventspace name was set. $tf->assertEquals($child_ev_space->name, $child_name); // Check the Eventspace parent was set. $tf->assertIdentical($child_ev_space->parent, $root_ev_space); // Check the callback was added to the child Eventspace. $tf->assertInArray($callback, $child_ev_space->callbacks); $tf->assertInArray($callback, $child_ev_space->getCallbacks()); // Check the callback is removed from the child.
<?php namespace Happen; /** * Tests for \Happen\Emitter */ include 'common.php'; $tf = new \Testify\Testify("Happen\\Emitter"); // Create the Emitter. $tf->beforeEach(function ($tf) { $tf->data->emitter = new \Happen\Emitter(); }); /** * Check closures are bound. */ $tf->test('Bind a closure', function ($tf) { $emitter = $tf->data->emitter; // Check we can bind a closure $emitter->on('ev_a', function ($tf) { }); $emitter->trigger('ev_a', array($tf)); // Why not eh? $tf->pass(); }); \Happen\Happen::run(function () use($tf) { $tf->run(); });