<?php /** * Copyright 2010-12 Nickolas Whiting. All rights reserved. * Use of this source code is governed by the Apache 2 license * that can be found in the LICENSE file. */ require_once '__init__.php'; xp_import('unittest'); unittest\test(function ($test) { $db = new \XPSPL\database\Processes(); $p1 = new \XPSPL\Process(null); $p2 = xp_high_priority(new \XPSPL\Process(null)); $db->install($p1); $db->install($p2); $db->delete($p1); $test->equal($db->count(), 1); $test->equal($db->current()->get_priority(), 0); }, "process delete");
<?php // Handle Foo xp_signal(XP_SIG('foo'), function ($signal) { echo $signal->bar; }); // When foo is emitted insert bar into the event xp_before(XP_SIG('foo'), function ($signal) { echo "I RAN" . PHP_EOL; $signal->bar = 'foo'; }); xp_before(XP_SIG('foo'), xp_high_priority(function ($signal) { echo "I RAN BEFORE" . PHP_EOL; })); // After foo is emitted unset bar in the event xp_after(XP_SIG('foo'), function ($signal) { unset($signal->bar); }); $signal = xp_emit(XP_SIG('foo')); var_dump(isset($signal->bar));
<?php /** * Copyright 2010-12 Nickolas Whiting. All rights reserved. * Use of this source code is governed by the Apache 2 license * that can be found in the LICENSE file. */ require_once dirname(realpath(__FILE__)) . '/../__init__.php'; xp_import('unittest'); unittest\test(function ($test) { $process = xp_high_priority(null); $test->equal(0, $process->get_priority()); }, 'API High Priority');
$test->count($eval, 1); $test->processor->delete_signal($evl); $test->null($test->processor->evaluate_signals(new \XPSPL\SIG('test'))); }, 'evaluate_signals'); $suite->test(function ($test) { // Simple $test->processor->signal(new \XPSPL\SIG('before_after_test'), new \XPSPL\Process(function ($signal) use($test) { $test->isset('count', $signal); $test->equal($signal->count, 1); ++$signal->count; })); $test->processor->before(new \XPSPL\SIG('before_after_test'), new \XPSPL\Process(function ($signal) { $signal->count = 1; })); $test->processor->after(new \XPSPL\SIG('before_after_test'), xp_high_priority(function ($signal) use($test) { $test->equal($signal->count, 2); })); $test->processor->after(new \XPSPL\SIG('before_after_test'), new \XPSPL\Process(function ($signal) { ++$signal->count; })); $result = $test->processor->emit(new \XPSPL\SIG('before_after_test')); $test->isset('count', $result); $test->equal($result->count, 3); }, 'before,after'); // NOT IMPLEMENTED // $suite->test(function($test){ // $test->processor->register_signal(new \XPSPL\SIG('test')); // $test->notnull($test->processor->find_signal_database(new \XPSPL\SIG('test'))); // $test->instanceof( // $test->processor->find_signal_database(new \XPSPL\SIG('test')), // new \XPSPL\database\Processes()