Ejemplo n.º 1
0
<?php

require_once __DIR__ . '/../../Event/GenericEvent.php';
require_once __DIR__ . '/../../Data/Types/Null.php';
require_once __DIR__ . '/../../Data/Types/Set.php';
use Falcraft\Event;
use Falcraft\Patterns;
use Falcraft\Data\Types;
echo "Falcraft\\Event\\GenericEvent.php Test\n";
echo "------------------------------------\n\n";
echo "Basic Instantiation -- \n\n";
$success = true;
try {
    $null = new Types\Null();
    echo "event = new EventResource\\GenericEvent( \$null, \n" . "testFunction, \n    testClass, \n    testNamespace, \n    null, \n    " . "array( tag1, tag2 ), \n    array( cat1, cat2 ), \n" . "    array( options => strict ) );\n";
    $event = new Event\GenericEvent($null, 'testFunction', 'testClass', 'testNamespace', null, array('tag1', 'tag2'), array('cat1', 'cat2'), array('strict' => true));
} catch (\Exception $e) {
    $success = false;
}
if ($success) {
    echo "Success!\n\n";
} else {
    echo "Failure...\n\n";
}
echo "Basic Operations -- \n\n";
$success = true;
try {
    echo "    event->getState(): \n\n";
    var_dump($event->getState());
    echo "\n";
} catch (\Exception $e) {
Ejemplo n.º 2
0
    echo $filter->isApplicable($event) ? "True\n" : "False\n";
} catch (\Exception $e) {
    $success = false;
}
if ($success) {
    echo "Success!\n\n";
} else {
    echo "Failure...\n\n";
}
echo "Tags and Categories -- \n";
echo "    Reset Filter and Event -> ";
$success = true;
$filter = $event = null;
try {
    $filter = new Event\Filter();
    $event = new Event\GenericEvent(null, null, null, null);
} catch (\Exception $e) {
    $success = false;
}
if ($success) {
    echo "Success!\n\n";
} else {
    echo "Failure...\n";
}
$success = true;
try {
    echo "    event-addTag( tag1 )\n";
    $event->addTag('tag1');
    echo "    filter->isApplicable( event ) -> ";
    echo $filter->isApplicable($event) ? "True\n" : "False\n";
} catch (\Exception $e) {
Ejemplo n.º 3
0
 /**
  * Initialize the filter with values
  * 
  * This mimics the constructor to initialize the filter with the
  * passed arguments
  * 
  * @see Falcraft\Event\Resource\Generc
  * 
  * @param object $target
  * @param string $function
  * @param string $class
  * @param string $namespace
  * @param mixed $data
  * @param array $tags
  * @param array $cats
  * @param array $options
  */
 public function build($target, $function, $class, $namespace, $data, array $tags = array(), array $cats = array())
 {
     parent::__construct($target, $function, $class, $namespace, $data, $tags, $cats);
 }