public function testDisableSystemBus() { if (is_null($this->gate->getSystemBus())) { $this->gate->enableSystemBus(); } $this->gate->disableSystemBus(); $systemBus = $this->gate->getSystemBus(); $this->assertNull($systemBus); }
/** * */ public function __construct() { // The gate manages the bus system $this->gate = new Gate(); // Create a bus and attach it to the gate $this->bus = new Iteration4Bus(); $this->bus->setCommandHandlerLoader(new ClassMapCommandHandlerLoader()); $this->bus->setEventListenerLoader(new ClassMapEventListenerLoader()); $this->bus->setQueryHandlerLoader(new ClassMapQueryHandlerLoader()); $this->gate->attach($this->bus); // Use of AnnotationAdapter, adapters always us pipe $adapter = new AnnotationAdapter(); $adapter->pipe($this->bus, array('Iteration\\Iteration4\\Iteration4Handler')); // Enable the SystemBus and pipe it to some Monitoring $this->gate->enableSystemBus(); $adapter->pipe($this->gate->getSystemBus(), array('Iteration\\Iteration4\\Iteration4Monitor')); // Send a command to the bus // Iteration4Handler::editCommand is mapped against this command and will be called $this->bus->invokeCommand(new Iteration4Command('Hello')); }
public function testInvokeNonMappedEvent() { $gate = new Gate(); $gate->enableSystemBus(); $mockEvent = new MockEvent(); $this->assertFalse($gate->getSystemBus()->publishEvent($mockEvent)); }