Author: Johannes Skov Frandsen (localgod@heaven.dk)
Beispiel #1
0
 /**
  * Get graph data
  *
  * Get graph data from test resuts
  *
  * @param string $unit
  * @param string $start
  * @param string $end
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @param \Silex\Application $app
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function index($unit, $start, $end, Request $request, Application $app)
 {
     $start = DateTime::createFromFormat('Y-m-d', $start);
     $start->setTime(0, 0, 0);
     $end = DateTime::createFromFormat('Y-m-d', $end);
     $end->setTime(23, 59, 59);
     $data = null;
     switch ($unit) {
         case 'h':
             $data = Test::getTests($app['db'], $start, $end, Test::GROUP_BY_HOUR);
             break;
         case 'd':
             $data = Test::getTests($app['db'], $start, $end, Test::GROUP_BY_DAY);
             break;
         case 'm':
             $data = Test::getTests($app['db'], $start, $end, Test::GROUP_BY_MONTH);
             break;
         case 'y':
             $data = Test::getTests($app['db'], $start, $end, Test::GROUP_BY_YEAR);
             break;
         default:
             break;
     }
     $data = static::explodeTests($data);
     return $this->ok($data);
 }
Beispiel #2
0
 /**
  *
  * {@inheritDoc}
  *
  * @see \Symfony\Component\Console\Command\Command::execute()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->config = json_decode(file_get_contents($input->getOption('config')), true);
     $this->appRoot = dirname(realpath($input->getOption('config')));
     $output->setFormatter(new OutputFormatter(true));
     if ($input->getOption('start')) {
         $this->start();
         $output->writeln('<comment>VPU started</comment>');
     } elseif ($input->getOption('stop')) {
         $this->stop($output);
         $output->writeln('<comment>VPU stopped</comment>');
     } else {
         if (!empty($input->getArgument('files'))) {
             $parser = new Parser();
             $result = $parser->run($input->getArgument('files'));
             Test::createTable($this->getDbConnection());
             Test::store($this->getDbConnection(), $result);
             if ($input->getOption('archive')) {
                 Suite::createTable($this->getDbConnection());
                 Suite::store($this->getDbConnection(), $result);
                 if ($output->isVerbose()) {
                     $output->writeln('<comment>Test suite archived</comment>');
                 }
             }
         } else {
             $output->writeln('<error>No files where supplied. Use -h for help.</error>');
         }
     }
 }
Beispiel #3
0
 /**
  * Run the selected test files
  *
  * Run the selected test with phpunit
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @param \Silex\Application $app
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function index(Request $request, Application $app)
 {
     Suite::createTable($app['db']);
     Test::createTable($app['db']);
     $data = json_decode($request->getContent(), true);
     if (count($data['files'])) {
         $parser = new Parser();
         $result = $parser->run($data['files']);
         if ($data['config']['snapshot']) {
             Suite::store($app['db'], $result);
         }
         Test::store($app['db'], $result);
         return $this->ok([$result]);
     }
     return $this->ok(['nofiles']);
 }