Visualphpunit\Core\Test::store PHP Method

store() public static method

Store a test suite result
public static store ( Doctrine\DBAL\Connection $connection, mixed[] $result ) : boolean
$connection Doctrine\DBAL\Connection
$result mixed[]
return boolean
    public static function store(Connection $connection, $result)
    {
        $sql = "INSERT INTO tests (name, class, status, executed) VALUES (?, ?, ?, ?);";
        $date = new DateTime();
        foreach ($result['tests'] as $test) {
            $stmt = $connection->prepare($sql);
            $stmt->bindValue(1, $test['name']);
            $stmt->bindValue(2, $test['class']);
            $stmt->bindValue(3, $test['status']);
            $stmt->bindValue(4, $date->format('Y-m-d H:i:s'));
            $stmt->execute();
        }
    }

Usage Example

Example #1
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>');
         }
     }
 }
All Usage Examples Of Visualphpunit\Core\Test::store