コード例 #1
0
 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());
 }
コード例 #2
0
ファイル: Run.php プロジェクト: NilsLangner/LiveTest
 /**
  * This function runs all test sets defined in the properties file.
  *
  * @notify LiveTest.Run.PostRun
  * @notify LiveTest.Run.PreRun
  */
 public function run()
 {
     $this->eventDispatcher->simpleNotify('LiveTest.Run.PreRun', array('properties' => $this->properties));
     // @todo move timer to runner.php
     $timer = new Timer();
     foreach ($this->properties->getTestSets() as $sessionName => $testSets) {
         foreach ($testSets as $testSet) {
             $this->runTestSet($testSet, $sessionName);
         }
     }
     $information = new Information($timer->stop(), $this->properties->getDefaultDomain());
     $this->eventDispatcher->simpleNotify('LiveTest.Run.PostRun', array('information' => $information));
 }
コード例 #3
0
ファイル: Runner.php プロジェクト: nicolas-lang/LiveTest2
 private function getClients($sessions)
 {
     $clients = array();
     foreach ($sessions as $sessionName => $session) {
         $client = new Zend();
         if ($session->areCookiesAllowed()) {
             $client->setCookieJar(new CookieJar());
         }
         $client->setAdapter(new Curl());
         $this->eventDispatcher->simpleNotify('LiveTest.Runner.InitHttpClient', array('client' => $client, 'sessionName' => $sessionName));
         $clients[$sessionName] = $client;
     }
     return $clients;
 }
コード例 #4
0
ファイル: Properties.php プロジェクト: nicolas-lang/LiveTest2
 /**
  * Creates a properties object that was created using a yaml file.
  *
  * @todo is this method neccessary? If yes: Where to put it? At the moment it is only used to make testing easier
  *
  * @param String $filename The file name of the yaml file
  * @param Uri $defaultUri The default uri
  */
 public static function createByYamlFile($filename, Uri $defaultUri, Dispatcher $eventDispatcher)
 {
     try {
         $yamlConfig = new Yaml($filename);
     } catch (\Zend\Config\Exception $e) {
         throw new ConfigurationException('Unable to load test suite yaml file (filename: ' . $filename . ')');
     }
     $testSuiteConfig = new TestSuite();
     $testSuiteConfig->setBaseDir(dirname($filename));
     $testSuiteConfig->setDefaultDomain($defaultUri);
     $parser = new Parser('LiveTest\\Config\\Tags\\TestSuite\\');
     try {
         $testSuiteConfig = $parser->parse($yamlConfig->toArray(), $testSuiteConfig);
     } catch (UnknownTagException $e) {
         throw new ConfigurationException('Error parsing testsuite configuration (' . $filename . '): ' . $e->getMessage(), null, $e);
     }
     $testSuiteConfig->resolveSessionGroups();
     $eventDispatcher->simpleNotify('LiveTest.TestRun.Properties.PostTestSuiteInit', array('config' => $testSuiteConfig));
     return new self($testSuiteConfig, $defaultUri);
 }
コード例 #5
0
ファイル: runner.php プロジェクト: NilsLangner/LiveTest
use LiveTest\Packages\Runner\Listeners\Help;
include_once __DIR__ . '/version.php';
include_once __DIR__ . '/bootstrap.php';
$exitStatusCode = 1;
try {
    $converter = new Base\Cli\ArgumentConverter($_SERVER['argv'], '--');
    // @todo this should be done in another class/function
    if ($converter->hasArgument('bootstrap')) {
        $bootstrapFile = $converter->getArgument('bootstrap');
        if (file_exists(getcwd() . DIRECTORY_SEPARATOR . $bootstrapFile) && $bootstrapFile != '') {
            include_once $converter->getArgument('bootstrap');
        } else {
            echo '  Bootstrap file (' . $converter->getArgument('bootstrap') . ') not found.' . "\n\n";
        }
    }
    $dispatcher = new LiveTest\Event\Dispatcher();
    $runner = new LiveTest\Cli\Runner($converter->getArguments(), $dispatcher);
    if ($runner->isRunAllowed()) {
        $runner->run();
    }
    $exitStatusCode = 0;
} catch (Livetest\ConfigurationException $e) {
    $dispatcher->simpleNotify('LiveTest.Configuration.Exception', array('exception' => $e));
} catch (Exception $e) {
    $event = new phmLabs\Components\Annovent\Event\Event('LiveTest.Runner.Error', array('exception' => $e));
    $dispatcher->notify($event);
    if (!$event->isProcessed()) {
        echo 'An error occured: ' . $e->getMessage() . '(' . get_class($e) . ')';
    }
}
echo "\n\n";