Ejemplo n.º 1
0
 public function testExecute()
 {
     // Arrange
     $event = new NamedEvent('event');
     $scene = new Scene();
     $scene->addEvent($event);
     $scene->addEvent($event);
     // Act
     $result = $scene->execute('event');
     // Assert
     $this->assertEquals(1, $result);
 }
Ejemplo n.º 2
0
 public function testSerializeConnectedEvent()
 {
     $action = new EchoAction();
     $event = new NamedEvent('dispatch');
     $event->bind(NamedEvent::SOCKET_OUT, $action);
     $scene = new Scene();
     $scene->addEvent($event);
     $serializer = new JsonSerializer();
     $this->assertStringEqualsFile(__DIR__ . '/TestAsset/scene-connected-event.json', $serializer->serialize($scene));
 }
Ejemplo n.º 3
0
<?php

/**
 * NextFlow (http://github.com/nextflow)
 *
 * @link http://github.com/nextflow/nextflow-php for the canonical source repository
 * @copyright Copyright (c) 2014-2016 NextFlow (http://github.com/nextflow)
 * @license https://raw.github.com/nextflow/nextflow-php/master/LICENSE MIT
 */
use NextFlow\Core\Event\NamedEvent;
use NextFlow\Core\Scene\Scene;
use NextFlow\Php\Action\EchoAction;
use NextFlow\Php\Variable\StringVariable;
require __DIR__ . '/../vendor/autoload.php';
$variable = new StringVariable();
$variable->setValue('Hello world');
$action = new EchoAction();
$action->bind(EchoAction::SOCKET_DATA, $variable);
$event = new NamedEvent('demo');
$event->bind(NamedEvent::SOCKET_OUT, $action);
$scene = new Scene();
$scene->addEvent($event);
$scene->execute('demo');