Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8081825

Browse filesBrowse files
committed
add tests
1 parent e420814 commit 8081825
Copy full SHA for 8081825

File tree

3 files changed

+55
-0
lines changed
Filter options

3 files changed

+55
-0
lines changed
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
use Symfony\Component\Console\Input\InputInterface;
4+
use Symfony\Component\Console\Output\OutputInterface;
5+
use Symfony\Component\Console\Style\SymfonyStyle;
6+
7+
// progressIterate
8+
return function (InputInterface $input, OutputInterface $output) {
9+
$style = new SymfonyStyle($input, $output);
10+
11+
foreach ($style->progressIterate(\range(1, 10)) as $step) {
12+
// noop
13+
}
14+
15+
$style->writeln('end of progressbar');
16+
};
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
0/10 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0%
2+
10/10 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
3+
4+
end of progressbar

‎src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php
+35Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Console\Command\Command;
16+
use Symfony\Component\Console\Exception\RuntimeException;
1617
use Symfony\Component\Console\Formatter\OutputFormatter;
1718
use Symfony\Component\Console\Input\ArrayInput;
1819
use Symfony\Component\Console\Input\InputInterface;
1920
use Symfony\Component\Console\Output\ConsoleOutputInterface;
21+
use Symfony\Component\Console\Output\ConsoleSectionOutput;
2022
use Symfony\Component\Console\Output\NullOutput;
2123
use Symfony\Component\Console\Output\OutputInterface;
2224
use Symfony\Component\Console\Style\SymfonyStyle;
@@ -106,6 +108,39 @@ public function testGetErrorStyle()
106108
$io->getErrorStyle()->write('');
107109
}
108110

111+
public function testCreateTableWithConsoleOutput()
112+
{
113+
$input = $this->createMock(InputInterface::class);
114+
$output = $this->createMock(ConsoleOutputInterface::class);
115+
$output
116+
->method('getFormatter')
117+
->willReturn(new OutputFormatter());
118+
$output
119+
->expects($this->once())
120+
->method('section')
121+
->willReturn($this->createMock(ConsoleSectionOutput::class));
122+
123+
$style = new SymfonyStyle($input, $output);
124+
125+
$style->createTable();
126+
}
127+
128+
public function testCreateTableWithoutConsoleOutput()
129+
{
130+
$input = $this->createMock(InputInterface::class);
131+
$output = $this->createMock(OutputInterface::class);
132+
$output
133+
->method('getFormatter')
134+
->willReturn(new OutputFormatter());
135+
136+
$style = new SymfonyStyle($input, $output);
137+
138+
$this->expectException(RuntimeException::class);
139+
$this->expectDeprecationMessage('Output should be an instance of "Symfony\Component\Console\Output\ConsoleSectionOutput"');
140+
141+
$style->createTable()->appendRow(['row']);
142+
}
143+
109144
public function testGetErrorStyleUsesTheCurrentOutputIfNoErrorOutputIsAvailable()
110145
{
111146
$output = $this->createMock(OutputInterface::class);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.