예제 #1
0
<?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();
예제 #2
0
<?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) {
예제 #3
0
$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.
    $child_ev_space->removeCallback($callback);
    $tf->assertNotInArray($callback, $child_ev_space->getCallbacks());
    // Check the root Eventspace sees the child.
    $tf->assertTrue($root_ev_space->hasChild($child_name));
    // Check the child is removed from the root.
    $root_ev_space->removeChild($child_name);
    $tf->assertFalse($root_ev_space->hasChild($child_name));
});
$tf->test('Add deep child eventspace with callbacks', function ($tf) {
    // Get the root Eventspace.
    $child_name = 'john';
예제 #4
0
<?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();
});