Ejemplo n.º 1
0
    /**
     * testTableRenderer.
     */
    public function testListRenderer()
    {
        $renderer = RendererFactory::create('list', $this->io);
        $renderer->render($this->createResultCollection());
        $output = <<<LIST
[OK][200] Example - 0.42

LIST;
        $this->assertInstanceOf(RendererInterface::class, $renderer);
        $this->assertSame($output, $this->io->fetchOutput());
    }
Ejemplo n.º 2
0
    /**
     * testCsvRenderer.
     */
    public function testCsvRenderer()
    {
        $renderer = RendererFactory::create('csv', $this->io);
        $renderer->render($this->createResultCollection());
        $output = <<<CSV
"Global Status","Status Code",Name,"Reponse Time","Http Error Log","Validator Error Log"
OK,200,Example,0.42,,

CSV;
        $this->assertInstanceOf(RendererInterface::class, $renderer);
        $this->assertSame($output, $this->io->fetchOutput());
    }
Ejemplo n.º 3
0
    /**
     * testTableRenderer.
     */
    public function testTableRenderer()
    {
        $renderer = RendererFactory::create('table', $this->io);
        $renderer->render($this->createResultCollection());
        $output = <<<TABLE
+--------+--------+---------+----------+----------------+---------------------+
| Global | Status | Name    | Response | Http Error Log | Validator Error Log |
| Status | Code   |         | Time     |                |                     |
+--------+--------+---------+----------+----------------+---------------------+
| OK     | 200    | Example | 0.42     |                |                     |
+--------+--------+---------+----------+----------------+---------------------+

TABLE;
        $this->assertInstanceOf(RendererInterface::class, $renderer);
        $this->assertSame($output, $this->io->fetchOutput());
    }
Ejemplo n.º 4
0
 /**
  * handle.
  *
  * @param Args $args
  * @param IO   $io
  *
  * @return int
  */
 public function handle(Args $args, IO $io)
 {
     $this->configurationLoader->setRootDirectory($args->getOption('config'));
     $config = $this->configurationLoader->loadConfiguration();
     try {
         $urlProvider = new UrlProvider($config);
         $runner = new Runner($urlProvider, GuzzleClient::createClient($io));
         $renderer = RendererFactory::create($args->getOption('format'), $io);
         $results = $runner->run();
         $renderer->render($results);
         if (isset($config['hogosha_portal']['metric_update']) || isset($config['hogosha_portal']['incident_update'])) {
             $pusher = new PusherManager($config, $io);
             $pusher->push($results);
         }
     } catch (BadResponseException $e) {
         $io->writeLine(sprintf('<error>Exception:</error> "%s"', $e->getMessage()));
     } catch (ConfigurationLoadingException $e) {
         $io->writeLine(sprintf('<info>There is no configuration file in</info> "%s"', $this->configurationLoader->getRootDirectory()));
     }
 }