Beispiel #1
0
 public function testSetListener()
 {
     $config = new ConfigConfig();
     $listener = new Listener(array('test' => array('class' => 'testSetListener')), $config, new Parser('/'));
     $listener->process();
     $listeners = $config->getListeners();
     $this->assertEquals($listeners['test']['className'], 'testSetListener');
 }
 public function testSetDefaultDomain()
 {
     $domain = 'http://test.test.test/';
     $config = new ConfigConfig();
     $defaultDomain = new DefaultDomain($domain, $config, new Parser('/'));
     $defaultDomain->process();
     $this->assertEquals($config->getDefaultDomain()->toString(), $domain);
 }
Beispiel #3
0
 public function testSetListener()
 {
     $config = new ConfigConfig();
     $http = new Http(array(), $config, new Parser('/'));
     $http->process();
     $listeners = $config->getListeners();
     $this->assertEquals($listeners['httpListener']['className'], 'LiveTest\\Packages\\Http\\Listeners\\ClientConfiguration');
 }
 public function testAddListener()
 {
     $config = new ConfigConfig();
     $config->addListener('MyName', 'MyClassName', array('foo' => 'bar'));
     $listeners = $config->getListeners();
     $this->assertArrayHasKey('MyName', $listeners);
     $listener = $listeners['MyName'];
     $this->assertEquals('MyClassName', $listener['className']);
     $this->assertArrayHasKey('foo', $listener['parameters']);
 }
 public function testRegisterByConfig()
 {
     $dispatcher = new Dispatcher();
     $config = new ConfigConfig();
     $config->addListener('myListener', 'Unit\\LiveTest\\Listener\\MockUp', array('foo' => 'bar'));
     $dispatcher->registerByConfig($config, '');
     $listeners = $dispatcher->getListeners('Test');
     $listener = $listeners[0];
     $this->assertTrue($listener[0] instanceof \Unit\LiveTest\Listener\MockUp);
     $this->assertEquals('bar', $listener[0]->getFoo());
 }
Beispiel #6
0
 /**
  * This function is used to register listeners using a global configuration file
  *
  * @param ConfigConfig $config
  * @param string $runId
  */
 public function registerByConfig(ConfigConfig $config, $runId)
 {
     foreach ($config->getListeners() as $listener) {
         $className = $listener['className'];
         if (!class_exists($className)) {
             throw new \LiveTest\ConfigurationException('Listener not found (' . $className . ').');
         }
         $listenerObject = new $className($runId, $this);
         \LiveTest\Functions::initializeObject($listenerObject, $listener['parameters']);
         $this->connectListener($listenerObject, $listener['priority']);
     }
 }
Beispiel #7
0
 /**
  * @see LiveTest\Config\Tags\Config.Base::doProcess()
  */
 protected function doProcess(ConfigConfig $config, $parameters)
 {
     foreach ($parameters as $name => $listener) {
         if (!array_key_exists('class', $listener) || $listener['class'] == '') {
             throw new \Exception('The class name for the "' . $name . '" listener is missing. Please check your configuration.');
         }
         if (!array_key_exists('priority', $listener)) {
             $listener['priority'] = 0;
         }
         if (!array_key_exists('parameter', $listener)) {
             $listener['parameter'] = array();
         }
         $config->addListener($name, $listener['class'], $listener['parameter'], $listener['priority']);
     }
 }
Beispiel #8
0
 /**
  * Initializes the test run.
  */
 private function initTestRun()
 {
     $this->eventDispatcher->simpleNotify('LiveTest.Runner.InitTestRun');
     try {
         $properties = Properties::createByYamlFile($this->getArgument('testsuite'), $this->config->getDefaultDomain(), $this->eventDispatcher);
     } catch (\Zend\Config\Exception\InvalidArgumentException $e) {
         throw new ConfigurationException('The given testsuite configuration file ("' . $this->getArgument('testsuite') . '") was not found.', null, $e);
     } catch (\InvalidArgumentException $e) {
         throw new ConfigurationException('Error parsing testsuite configuration: ' . $e->getMessage(), null, $e);
     }
     if (!$properties->hasSessions()) {
         throw new ConfigurationException('No sessions were defined in the testsuite configuration');
     }
     $clients = $this->getClients($properties->getSessions());
     $this->testRun = new Run($properties, $clients, $this->eventDispatcher);
 }
Beispiel #9
0
 /**
  * This function sets the defaultDomain (if set) in the current config
  * 
  * @Event("LiveTest.Runner.ConfigInitialized")
  */
 public function runnerConfigInitialized(ConfigConfig $config)
 {
     if (!is_null($this->defaultDomain)) {
         $config->setDefaultDomain($this->defaultDomain);
     }
 }
Beispiel #10
0
 /**
  * @see LiveTest\Config\Tags\Config.Base::doProcess()
  */
 protected function doProcess(ConfigConfig $config, $parameters)
 {
     $config->addListener('httpListener', 'LiveTest\\Packages\\Http\\Listeners\\ClientConfiguration', $parameters);
 }
Beispiel #11
0
 /**
  * @see LiveTest\Config\Tags\Config.Base::doProcess()
  */
 protected function doProcess(ConfigConfig $config, $parameters)
 {
     $config->setDefaultDomain(new Uri($parameters));
 }