First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
42
vendor/symfony/console/Tests/Output/ConsoleOutputTest.php
vendored
Normal file
42
vendor/symfony/console/Tests/Output/ConsoleOutputTest.php
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Output;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Output\Output;
|
||||
|
||||
class ConsoleOutputTest extends TestCase
|
||||
{
|
||||
public function testConstructor()
|
||||
{
|
||||
$output = new ConsoleOutput(Output::VERBOSITY_QUIET, true);
|
||||
$this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument');
|
||||
$this->assertSame($output->getFormatter(), $output->getErrorOutput()->getFormatter(), '__construct() takes a formatter or null as the third argument');
|
||||
}
|
||||
|
||||
public function testSetFormatter()
|
||||
{
|
||||
$output = new ConsoleOutput();
|
||||
$outputFormatter = new OutputFormatter();
|
||||
$output->setFormatter($outputFormatter);
|
||||
$this->assertSame($outputFormatter, $output->getFormatter());
|
||||
}
|
||||
|
||||
public function testSetVerbosity()
|
||||
{
|
||||
$output = new ConsoleOutput();
|
||||
$output->setVerbosity(Output::VERBOSITY_VERBOSE);
|
||||
$this->assertSame(Output::VERBOSITY_VERBOSE, $output->getVerbosity());
|
||||
}
|
||||
}
|
88
vendor/symfony/console/Tests/Output/NullOutputTest.php
vendored
Normal file
88
vendor/symfony/console/Tests/Output/NullOutputTest.php
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Output;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
use Symfony\Component\Console\Output\Output;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class NullOutputTest extends TestCase
|
||||
{
|
||||
public function testConstructor()
|
||||
{
|
||||
$output = new NullOutput();
|
||||
|
||||
ob_start();
|
||||
$output->write('foo');
|
||||
$buffer = ob_get_clean();
|
||||
|
||||
$this->assertSame('', $buffer, '->write() does nothing (at least nothing is printed)');
|
||||
$this->assertFalse($output->isDecorated(), '->isDecorated() returns false');
|
||||
}
|
||||
|
||||
public function testVerbosity()
|
||||
{
|
||||
$output = new NullOutput();
|
||||
$this->assertSame(OutputInterface::VERBOSITY_QUIET, $output->getVerbosity(), '->getVerbosity() returns VERBOSITY_QUIET for NullOutput by default');
|
||||
|
||||
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
|
||||
$this->assertSame(OutputInterface::VERBOSITY_QUIET, $output->getVerbosity(), '->getVerbosity() always returns VERBOSITY_QUIET for NullOutput');
|
||||
}
|
||||
|
||||
public function testSetFormatter()
|
||||
{
|
||||
$output = new NullOutput();
|
||||
$outputFormatter = new OutputFormatter();
|
||||
$output->setFormatter($outputFormatter);
|
||||
$this->assertNotSame($outputFormatter, $output->getFormatter());
|
||||
}
|
||||
|
||||
public function testSetVerbosity()
|
||||
{
|
||||
$output = new NullOutput();
|
||||
$output->setVerbosity(Output::VERBOSITY_NORMAL);
|
||||
$this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity());
|
||||
}
|
||||
|
||||
public function testSetDecorated()
|
||||
{
|
||||
$output = new NullOutput();
|
||||
$output->setDecorated(true);
|
||||
$this->assertFalse($output->isDecorated());
|
||||
}
|
||||
|
||||
public function testIsQuiet()
|
||||
{
|
||||
$output = new NullOutput();
|
||||
$this->assertTrue($output->isQuiet());
|
||||
}
|
||||
|
||||
public function testIsVerbose()
|
||||
{
|
||||
$output = new NullOutput();
|
||||
$this->assertFalse($output->isVerbose());
|
||||
}
|
||||
|
||||
public function testIsVeryVerbose()
|
||||
{
|
||||
$output = new NullOutput();
|
||||
$this->assertFalse($output->isVeryVerbose());
|
||||
}
|
||||
|
||||
public function testIsDebug()
|
||||
{
|
||||
$output = new NullOutput();
|
||||
$this->assertFalse($output->isDebug());
|
||||
}
|
||||
}
|
176
vendor/symfony/console/Tests/Output/OutputTest.php
vendored
Normal file
176
vendor/symfony/console/Tests/Output/OutputTest.php
vendored
Normal file
|
@ -0,0 +1,176 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Output;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Output\Output;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
|
||||
class OutputTest extends TestCase
|
||||
{
|
||||
public function testConstructor()
|
||||
{
|
||||
$output = new TestOutput(Output::VERBOSITY_QUIET, true);
|
||||
$this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument');
|
||||
$this->assertTrue($output->isDecorated(), '__construct() takes the decorated flag as its second argument');
|
||||
}
|
||||
|
||||
public function testSetIsDecorated()
|
||||
{
|
||||
$output = new TestOutput();
|
||||
$output->setDecorated(true);
|
||||
$this->assertTrue($output->isDecorated(), 'setDecorated() sets the decorated flag');
|
||||
}
|
||||
|
||||
public function testSetGetVerbosity()
|
||||
{
|
||||
$output = new TestOutput();
|
||||
$output->setVerbosity(Output::VERBOSITY_QUIET);
|
||||
$this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '->setVerbosity() sets the verbosity');
|
||||
|
||||
$this->assertTrue($output->isQuiet());
|
||||
$this->assertFalse($output->isVerbose());
|
||||
$this->assertFalse($output->isVeryVerbose());
|
||||
$this->assertFalse($output->isDebug());
|
||||
|
||||
$output->setVerbosity(Output::VERBOSITY_NORMAL);
|
||||
$this->assertFalse($output->isQuiet());
|
||||
$this->assertFalse($output->isVerbose());
|
||||
$this->assertFalse($output->isVeryVerbose());
|
||||
$this->assertFalse($output->isDebug());
|
||||
|
||||
$output->setVerbosity(Output::VERBOSITY_VERBOSE);
|
||||
$this->assertFalse($output->isQuiet());
|
||||
$this->assertTrue($output->isVerbose());
|
||||
$this->assertFalse($output->isVeryVerbose());
|
||||
$this->assertFalse($output->isDebug());
|
||||
|
||||
$output->setVerbosity(Output::VERBOSITY_VERY_VERBOSE);
|
||||
$this->assertFalse($output->isQuiet());
|
||||
$this->assertTrue($output->isVerbose());
|
||||
$this->assertTrue($output->isVeryVerbose());
|
||||
$this->assertFalse($output->isDebug());
|
||||
|
||||
$output->setVerbosity(Output::VERBOSITY_DEBUG);
|
||||
$this->assertFalse($output->isQuiet());
|
||||
$this->assertTrue($output->isVerbose());
|
||||
$this->assertTrue($output->isVeryVerbose());
|
||||
$this->assertTrue($output->isDebug());
|
||||
}
|
||||
|
||||
public function testWriteWithVerbosityQuiet()
|
||||
{
|
||||
$output = new TestOutput(Output::VERBOSITY_QUIET);
|
||||
$output->writeln('foo');
|
||||
$this->assertEquals('', $output->output, '->writeln() outputs nothing if verbosity is set to VERBOSITY_QUIET');
|
||||
}
|
||||
|
||||
public function testWriteAnArrayOfMessages()
|
||||
{
|
||||
$output = new TestOutput();
|
||||
$output->writeln(array('foo', 'bar'));
|
||||
$this->assertEquals("foo\nbar\n", $output->output, '->writeln() can take an array of messages to output');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideWriteArguments
|
||||
*/
|
||||
public function testWriteRawMessage($message, $type, $expectedOutput)
|
||||
{
|
||||
$output = new TestOutput();
|
||||
$output->writeln($message, $type);
|
||||
$this->assertEquals($expectedOutput, $output->output);
|
||||
}
|
||||
|
||||
public function provideWriteArguments()
|
||||
{
|
||||
return array(
|
||||
array('<info>foo</info>', Output::OUTPUT_RAW, "<info>foo</info>\n"),
|
||||
array('<info>foo</info>', Output::OUTPUT_PLAIN, "foo\n"),
|
||||
);
|
||||
}
|
||||
|
||||
public function testWriteWithDecorationTurnedOff()
|
||||
{
|
||||
$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');
|
||||
}
|
||||
|
||||
public function testWriteDecoratedMessage()
|
||||
{
|
||||
$fooStyle = new OutputFormatterStyle('yellow', 'red', array('blink'));
|
||||
$output = new TestOutput();
|
||||
$output->getFormatter()->setStyle('FOO', $fooStyle);
|
||||
$output->setDecorated(true);
|
||||
$output->writeln('<foo>foo</foo>');
|
||||
$this->assertEquals("\033[33;41;5mfoo\033[39;49;25m\n", $output->output, '->writeln() decorates the output');
|
||||
}
|
||||
|
||||
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 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');
|
||||
}
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
|
||||
public function verbosityProvider()
|
||||
{
|
||||
return array(
|
||||
array(Output::VERBOSITY_QUIET, '2', '->write() in QUIET mode only outputs when an explicit QUIET verbosity is passed'),
|
||||
array(Output::VERBOSITY_NORMAL, '123', '->write() in NORMAL mode outputs anything below an explicit VERBOSE verbosity'),
|
||||
array(Output::VERBOSITY_VERBOSE, '1234', '->write() in VERBOSE mode outputs anything below an explicit VERY_VERBOSE verbosity'),
|
||||
array(Output::VERBOSITY_VERY_VERBOSE, '12345', '->write() in VERY_VERBOSE mode outputs anything below an explicit DEBUG verbosity'),
|
||||
array(Output::VERBOSITY_DEBUG, '123456', '->write() in DEBUG mode outputs everything'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TestOutput extends Output
|
||||
{
|
||||
public $output = '';
|
||||
|
||||
public function clear()
|
||||
{
|
||||
$this->output = '';
|
||||
}
|
||||
|
||||
protected function doWrite($message, $newline)
|
||||
{
|
||||
$this->output .= $message.($newline ? "\n" : '');
|
||||
}
|
||||
}
|
61
vendor/symfony/console/Tests/Output/StreamOutputTest.php
vendored
Normal file
61
vendor/symfony/console/Tests/Output/StreamOutputTest.php
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Output;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Output\Output;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
|
||||
class StreamOutputTest extends TestCase
|
||||
{
|
||||
protected $stream;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->stream = fopen('php://memory', 'a', false);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->stream = null;
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
$output = new StreamOutput($this->stream, Output::VERBOSITY_QUIET, true);
|
||||
$this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument');
|
||||
$this->assertTrue($output->isDecorated(), '__construct() takes the decorated flag as its second argument');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage The StreamOutput class needs a stream as its first argument.
|
||||
*/
|
||||
public function testStreamIsRequired()
|
||||
{
|
||||
new StreamOutput('foo');
|
||||
}
|
||||
|
||||
public function testGetStream()
|
||||
{
|
||||
$output = new StreamOutput($this->stream);
|
||||
$this->assertEquals($this->stream, $output->getStream(), '->getStream() returns the current stream');
|
||||
}
|
||||
|
||||
public function testDoWrite()
|
||||
{
|
||||
$output = new StreamOutput($this->stream);
|
||||
$output->writeln('foo');
|
||||
rewind($output->getStream());
|
||||
$this->assertEquals('foo'.PHP_EOL, stream_get_contents($output->getStream()), '->doWrite() writes to the stream');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue