Exemple #1
0
 public function writeln($message)
 {
     if ($this->handle) {
         $message = sprintf('%s %s', date('h:i:s'), $message);
     }
     $this->output->writeln($message);
 }
 public function render(array $nodes, array $extraData = array())
 {
     $this->loadTemplatingEngine();
     $result = $this->templatingEngine->render('layout.console.twig', array_merge(array('nodes' => $nodes), $extraData));
     $result = preg_replace('/\\s/', '', $result);
     $tags = array_merge($this->tags, $this->theme->getCliTags());
     foreach ($tags as $tag => $replacement) {
         $result = str_replace(sprintf('<%s>', $tag), $replacement, $result);
     }
     // @todo: clean
     $result = str_replace('<t_>', '', $result);
     $result = str_replace('</t_>', '', $result);
     return $this->console->writeln($result);
 }
 function it_should_handling_the_log_as_bubble(ConsoleOutputInterface $output, ConsoleOutputInterface $errorOutput)
 {
     $output->writeln(Argument::any())->willReturn(null);
     $output->getVerbosity()->shouldBeCalled()->willReturn(OutputInterface::VERBOSITY_DEBUG);
     $output->write('<info>[16:21:54] app.INFO:</info> My info message' . "\n")->shouldBeCalled();
     $this->beConstructedWith(null, false);
     $this->setOutput($output);
     $infoRecord = array('message' => 'My info message', 'context' => array(), 'level' => Logger::INFO, 'level_name' => Logger::getLevelName(Logger::INFO), 'channel' => 'app', 'datetime' => new \DateTime('2013-05-29 16:21:54'), 'extra' => array());
     $this->handle($infoRecord)->shouldReturn(true);
     $output->getErrorOutput()->willReturn($errorOutput)->shouldBeCalled();
     $errorOutput->write('<error>[16:21:54] app.ERROR:</error> My error message' . "\n")->shouldBeCalled();
     $errorRecord = array('message' => 'My error message', 'context' => array(), 'level' => Logger::ERROR, 'level_name' => Logger::getLevelName(Logger::ERROR), 'channel' => 'app', 'datetime' => new \DateTime('2013-05-29 16:21:54'), 'extra' => array());
     $this->handle($errorRecord)->shouldReturn(true);
 }
Exemple #4
0
 /**
  * @dataProvider getVerbosity
  *
  * @param string $method
  * @param int $verbosity
  * @param bool $expected
  */
 public function testIsVerbosity($method, $verbosity, $expected)
 {
     // set
     $this->output->expects($this->once())->method('getVerbosity')->will($this->returnValue($verbosity));
     $condition = call_user_func([$this->windows, $method]);
     if ($expected) {
         $this->assertTrue($condition);
     } else {
         $this->assertFalse($condition);
     }
 }
Exemple #5
0
 /**
  * @param string $url
  * @param string $method
  * @param string $body
  * @return string
  * @throws ErrorException
  */
 protected function request($url, $method = Method::GET, $body = null)
 {
     $this->output->writeln(sprintf('<fg=white>%s %s</>', $method, $url));
     /** @var $response Unirest\Response */
     $response = strtoupper($method) === Method::POST ? Request::post($url, [], $body) : Request::get($url);
     $result = (string) $response->body;
     $document = new \DOMDocument();
     $document->loadHTML($result);
     $xpath = new \DomXpath($document);
     $errors = $xpath->query('//div[contains(@class, "errorwrap")]');
     if ($errors->length) {
         throw new \ErrorException($errors->item(0)->getElementsByTagName('p')->item(0)->textContent);
     }
     return $result;
 }
 public function onQueueEmpty(Event $event)
 {
     $this->output->writeln("Queue is empty");
 }
 public function onPurge(Event $event)
 {
     $this->output->writeln("Queue purged");
 }
Exemple #8
0
 /**
  * @param OutputInterface $error
  */
 public function setErrorOutput(OutputInterface $error)
 {
     $this->output->setErrorOutput($error);
 }
 /**
  * @param PassResult $result
  */
 public function handlePass(PassResult $result)
 {
     $this->output->write(sprintf('<pass>%s</pass>', $this->formatter->formatPass($result)));
 }