Exemplo n.º 1
0
 public function testGetBus_DefaultBusSet()
 {
     $mockBus = new MockBus(new ClassMapCommandHandlerLoader(), new ClassMapEventListenerLoader(), new ClassMapQueryHandlerLoader());
     $anotherBus = new \Malocher\CqrsTest\Coverage\Mock\Bus\MockAnotherBus(new ClassMapCommandHandlerLoader(), new ClassMapEventListenerLoader(), new ClassMapQueryHandlerLoader());
     $this->gate->attach($mockBus);
     $this->gate->attach($anotherBus);
     $this->gate->setDefaultBusName($mockBus->getName());
     $this->assertEquals($this->gate->getBus()->getName(), $mockBus->getName());
 }
Exemplo n.º 2
0
 /**
  * initialize
  *
  * @param array $configuration
  * @throws ConfigurationException
  */
 public function initialize(array $configuration)
 {
     if (is_null($this->gate)) {
         throw ConfigurationException::initializeError('Gate not initialized. Create a new Gate() and pass it to setGate()');
     }
     if (isset($configuration['default_bus'])) {
         $this->gate->setDefaultBusName($configuration['default_bus']);
     }
     foreach ($configuration['adapters'] as $adapterClass => $adapterConfiguration) {
         $adapter = $this->loadAdapter($adapterClass, $adapterConfiguration);
         foreach ($adapterConfiguration['buses'] as $busClass => $busAdapterConfiguration) {
             $bus = $this->loadBus($busClass);
             $adapter->pipe($bus, $busAdapterConfiguration);
         }
     }
 }
 public function testUninstall()
 {
     $this->fs->ensureDirectoryExists($this->pluginDir);
     $installer = new GingerInstaller($this->io, $this->composer);
     $repository = new ComposerRepositoryMock();
     $package = new Package('gingerwfms/wf-configurator-backend', '1.0.0', '1.0.0');
     $package->setType('ginger-backend-plugin');
     $package->setExtra(array('plugin-namespace' => 'WfConfiguratorBackend'));
     $repository->addPackage($package);
     $gate = new Gate();
     $mockBus = new CqrsBusMock();
     $pluginNamespace = '';
     $pluginName = '';
     $pluginType = '';
     $pluginVersion = '';
     $mockBus->mapCommand('GingerPluginInstaller\\Cqrs\\UninstallPluginCommand', function (UninstallPluginCommand $command) use(&$pluginNamespace, &$pluginName, &$pluginType, &$pluginVersion) {
         $pluginNamespace = $command->getPluginNamespace();
         $pluginName = $command->getPluginName();
         $pluginType = $command->getPluginType();
         $pluginVersion = $command->getPluginVersion();
     });
     $gate->attach($mockBus);
     $gate->setDefaultBusName($mockBus->getName());
     Bootstrap::getServiceManager()->setAllowOverride(true);
     Bootstrap::getServiceManager()->setService('malocher.cqrs.gate', $gate);
     $installer->uninstall($repository, $package);
     $this->assertSame('WfConfiguratorBackend', $pluginNamespace);
     $this->assertSame('gingerwfms/wf-configurator-backend', $pluginName);
     $this->assertSame('ginger-backend-plugin', $pluginType);
     $this->assertSame('1.0.0', $pluginVersion);
 }