コード例 #1
0
ファイル: OutputTest.php プロジェクト: yamildiego/JY
 public function testWrite()
 {
     $fooStyle = new OutputFormatterStyle('yellow', 'red', array('blink'));
     $output = new TestOutput(Output::VERBOSITY_QUIET);
     $output->writeln('foo');
     $this->assertEquals('', $output->output, '->writeln() outputs nothing if verbosity is set to VERBOSITY_QUIET');
     $output = new TestOutput();
     $output->writeln(array('foo', 'bar'));
     $this->assertEquals("foo\nbar\n", $output->output, '->writeln() can take an array of messages to output');
     $output = new TestOutput();
     $output->writeln('<info>foo</info>', Output::OUTPUT_RAW);
     $this->assertEquals("<info>foo</info>\n", $output->output, '->writeln() outputs the raw message if OUTPUT_RAW is specified');
     $output = new TestOutput();
     $output->writeln('<info>foo</info>', Output::OUTPUT_PLAIN);
     $this->assertEquals("foo\n", $output->output, '->writeln() strips decoration tags if OUTPUT_PLAIN is specified');
     $output = new TestOutput();
     $output->setDecorated(false);
     $output->writeln('<info>foo</info>');
     $this->assertEquals("foo\n", $output->output, '->writeln() strips decoration tags if decoration is set to false');
     $output = new TestOutput();
     $output->getFormatter()->setStyle('FOO', $fooStyle);
     $output->setDecorated(true);
     $output->writeln('<foo>foo</foo>');
     $this->assertEquals("foo\n", $output->output, '->writeln() decorates the output');
     try {
         $output->writeln('<foo>foo</foo>', 24);
         $this->fail('->writeln() throws an \\InvalidArgumentException when the type does not exist');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\InvalidArgumentException', $e, '->writeln() throws an \\InvalidArgumentException when the type does not exist');
         $this->assertEquals('Unknown output type given (24)', $e->getMessage());
     }
     $output->clear();
     $output->write('<bar>foo</bar>');
     $this->assertEquals('<bar>foo</bar>', $output->output, '->write() do nothing when a style does not exist');
     $output->clear();
     $output->writeln('<bar>foo</bar>');
     $this->assertEquals("<bar>foo</bar>\n", $output->output, '->writeln() do nothing when a style does not exist');
 }
コード例 #2
0
ファイル: OutputTest.php プロジェクト: duxor/GUSLE
 public function testWriteWithInvalidStyle()
 {
     $output = new TestOutput();
     $output->clear();
     $output->write('<bar>foo</bar>');
     $this->assertEquals('<bar>foo</bar>', $output->output, '->write() do nothing when a aj does not exist');
     $output->clear();
     $output->writeln('<bar>foo</bar>');
     $this->assertEquals("<bar>foo</bar>\n", $output->output, '->writeln() do nothing when a aj does not exist');
 }
コード例 #3
0
ファイル: OutputTest.php プロジェクト: saj696/pipe
 /**
  * @dataProvider verbosityProvider
  */
 public function testWriteWithVerbosityOption($verbosity, $expected, $msg)
 {
     $output = new TestOutput();
     $output->setVerbosity($verbosity);
     $output->clear();
     $output->write('1', false);
     $output->write('2', false, Output::VERBOSITY_QUIET);
     $output->write('3', false, Output::VERBOSITY_NORMAL);
     $output->write('4', false, Output::VERBOSITY_VERBOSE);
     $output->write('5', false, Output::VERBOSITY_VERY_VERBOSE);
     $output->write('6', false, Output::VERBOSITY_DEBUG);
     $this->assertEquals($expected, $output->output, $msg);
 }