10000 minor #19111 [Console] simplified tests (fabpot) · symfony/symfony@92d80c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 92d80c9

Browse files
committed
minor #19111 [Console] simplified tests (fabpot)
This PR was merged into the 3.2-dev branch. Discussion ---------- [Console] simplified tests | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | no | Fixed tickets | n/a | License | MIT | Doc PR | n/a Commits ------- 85e5060 [Console] simplified tests
2 parents 88cf87e + 85e5060 commit 92d80c9

File tree

15 files changed

+29
-46
lines changed

15 files changed

+29
-46
lines changed

src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_0.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
use Symfony\Component\Console\Input\InputInterface;
44
use Symfony\Component\Console\Output\OutputInterface;
5-
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
5+
use Symfony\Component\Console\Style\SymfonyStyle;
66

77
//Ensure has single blank line at start when using block element
88
return function (InputInterface $input, OutputInterface $output) {
9-
$output = new SymfonyStyleWithForcedLineLength($input, $output);
9+
$output = new SymfonyStyle($input, $output);
1010
$output->caution('Lorem ipsum dolor sit amet');
1111
};

src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_1.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
use Symfony\Component\Console\Input\InputInterface;
44
use Symfony\Component\Console\Output\OutputInterface;
5-
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
5+
use Symfony\Component\Console\Style\SymfonyStyle;
66

77
//Ensure has single blank line between titles and blocks
88
return function (InputInterface $input, OutputInterface $output) {
9-
$output = new SymfonyStyleWithForcedLineLength($input, $output);
9+
$output = new SymfonyStyle($input, $output);
1010
$output->title('Title');
1111
$output->warning('Lorem ipsum dolor sit amet');
1212
$output->title('Title');

src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_10.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
use Symfony\Component\Console\Input\InputInterface;
44
use Symfony\Component\Console\Output\OutputInterface;
5-
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
5+
use Symfony\Component\Console\Style\SymfonyStyle;
66

77
//Ensure that all lines are aligned to the begin of the first line in a very long line block
88
return function (InputInterface $input, OutputInterface $output) {
9-
$output = new SymfonyStyleWithForcedLineLength($input, $output);
9+
$output = new SymfonyStyle($input, $output);
1010
$output->block(
1111
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum',
1212
'CUSTOM',

src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
use Symfony\Component\Console\Input\InputInterface;
44
use Symfony\Component\Console\Output\OutputInterface;
5-
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
5+
use Symfony\Component\Console\Style\SymfonyStyle;
66

77
// ensure long words are properly wrapped in blocks
88
return function (InputInterface $input, OutputInterface $output) {
99
$word = 'Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophattoperisteralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygon';
10-
$sfStyle = new SymfonyStyleWithForcedLineLength($input, $output);
10+
$sfStyle = new SymfonyStyle($input, $output);
1111
$sfStyle->block($word, 'CUSTOM', 'fg=white;bg=blue', ' § ', false);
1212
};

src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
use Symfony\Component\Console\Input\InputInterface;
44
use Symfony\Component\Console\Output\OutputInterface;
5-
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
5+
use Symfony\Component\Console\Style\SymfonyStyle;
66

77
// ensure that all lines are aligned to the begin of the first one and start with '//' in a very long line comment
88
return function (InputInterface $input, OutputInterface $output) {
9-
$output = new SymfonyStyleWithForcedLineLength($input, $output);
9+
$output = new SymfonyStyle($input, $output);
1010
$output->comment(
1111
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum'
1212
);

src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_2.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
use Symfony\Component\Console\Input\InputInterface;
44
use Symfony\Component\Console\Output\OutputInterface;
5-
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
5+
use Symfony\Component\Console\Style\SymfonyStyle;
66

77
//Ensure has single blank line between blocks
88
return function (InputInterface $input, OutputInterface $output) {
9-
$output = new SymfonyStyleWithForcedLineLength($input, $output);
9+
$output = new SymfonyStyle($input, $output);
1010
$output->warning('Warning');
1111
$output->caution('Caution');
1212
$output->error('Error');

src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_3.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
use Symfony\Component\Console\Input\InputInterface;
44
use Symfony\Component\Console\Output\OutputInterface;
5-
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
5+
use Symfony\Component\Console\Style\SymfonyStyle;
66

77
//Ensure has single blank line between two titles
88
return function (InputInterface $input, OutputInterface $output) {
9-
$output = new SymfonyStyleWithForcedLineLength($input, $output);
9+
$output = new SymfonyStyle($input, $output);
1010
$output->title('First title');
1111
$output->title('Second title');
1212
};

src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
use Symfony\Component\Console\Input\InputInterface;
44
use Symfony\Component\Console\Output\OutputInterface;
5-
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
5+
use Symfony\Component\Console\Style\SymfonyStyle;
66

77
//Ensure has single blank line after any text and a title
88
return function (InputInterface $input, OutputInterface $output) {
9-
$output = new SymfonyStyleWithForcedLineLength($input, $output);
9+
$output = new SymfonyStyle($input, $output);
1010

1111
$output->write('Lorem ipsum dolor sit amet');
1212
$output->title('First title');

src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_5.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
use Symfony\Component\Console\Input\InputInterface;
44
use Symfony\Component\Console\Output\OutputInterface;
5-
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
5+
use Symfony\Component\Console\Style\SymfonyStyle;
66

77
//Ensure has proper line ending before outputing a text block like with SymfonyStyle::listing() or SymfonyStyle::text()
88
return function (InputInterface $input, OutputInterface $output) {
9-
$output = new SymfonyStyleWithForcedLineLength($input, $output);
9+
$output = new SymfonyStyle($input, $output);
1010

1111
$output->writeln('Lorem ipsum dolor sit amet');
1212
$output->listing(array(

src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_6.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
use Symfony\Component\Console\Input\InputInterface;
44
use Symfony\Component\Console\Output\OutputInterface;
5-
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
5+
use Symfony\Component\Console\Style\SymfonyStyle;
66

77
//Ensure has proper blank line after text block when using a block like with SymfonyStyle::success
88
return function (InputInterface $input, OutputInterface $output) {
9-
$output = new SymfonyStyleWithForcedLineLength($input, $output);
9+
$output = new SymfonyStyle($input, $output);
1010

1111
$output->listing(array(
1212
'Lorem ipsum dolor sit amet',

src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_7.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
use Symfony\Component\Console\Input\InputInterface;
44
use Symfony\Component\Console\Output\OutputInterface;
5-
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
5+
use Symfony\Component\Console\Style\SymfonyStyle;
66

77
//Ensure questions do not output anything when input is non-interactive
88
return function (InputInterface $input, OutputInterface $output) {
9-
$output = new SymfonyStyleWithForcedLineLength($input, $output);
9+
$output = new SymfonyStyle($input, $output);
1010
$output->title('Title');
1111
$output->askHidden('Hidden question');
1212
$output->choice('Choice question with default', array('choice1', 'choice2'), 'choice1');

src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_8.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use Symfony\Component\Console\Input\InputInterface;
44
use Symfony\Component\Console\Output\OutputInterface;
5-
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
5+
use Symfony\Component\Console\Style\SymfonyStyle;
66
use Symfony\Component\Console\Helper\TableCell;
77

88
//Ensure formatting tables when using multiple headers with TableCell
@@ -21,6 +21,6 @@
2121
array('978-0804169127', 'Divine Comedy'),
2222
);
2323

24-
$output = new SymfonyStyleWithForcedLineLength($input, $output);
24+
$output = new SymfonyStyle($input, $output);
2525
$output->table($headers, $rows);
2626
};

src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_9.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
use Symfony\Component\Console\Input\InputInterface;
44
use Symfony\Component\Console\Output\OutputInterface;
5-
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
5+
use Symfony\Component\Console\Style\SymfonyStyle;
66

77
//Ensure that all lines are aligned to the begin of the first line in a multi-line block
88
return function (InputInterface $input, OutputInterface $output) {
9-
$output = new SymfonyStyleWithForcedLineLength($input, $output);
9+
$output = new SymfonyStyle($input, $output);
1010
$output->block(array('Custom block', 'Second custom block line'), 'CUSTOM', 'fg=white;bg=green', 'X ', true);
1111
};

src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/interactive_command_1.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
use Symfony\Component\Console\Input\InputInterface;
44
use Symfony\Component\Console\Output\OutputInterface;
5-
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
5+
use Symfony\Component\Console\Style\SymfonyStyle;
66

77
//Ensure that questions have the expected outputs
88
return function (InputInterface $input, OutputInterface $output) {
9-
$output = new SymfonyStyleWithForcedLineLength($input, $output);
9+
$output = new SymfonyStyle($input, $output);
1010
$stream = fopen('php://memory', 'r+', false);
1111

1212
fputs($stream, "Foo\nBar\nBaz");

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

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
use PHPUnit_Framework_TestCase;
1515
use Symfony\Component\Console\Command\Command;
16-
use Symfony\Component\Console\Input\InputInterface;
17-
use Symfony\Component\Console\Output\OutputInterface;
1816
use Symfony\Component\Console\Style\SymfonyStyle;
1917
use Symfony\Component\Console\Tester\CommandTester;
2018

@@ -27,6 +25,7 @@ class SymfonyStyleTest extends PHPUnit_Framework_TestCase
2725

2826
protected function setUp()
2927
{
28+
putenv('COLUMNS=121');
3029
$this->command = new Command('sfstyle');
3130
$this->tester = new CommandTester($this->command);
3231
}
@@ -73,19 +72,3 @@ public function inputCommandToOutputFilesProvider()
7372
return array_map(null, glob($baseDir.'/command/command_*.php'), glob($baseDir.'/output/output_*.txt'));
7473
}
7574
}
76-
77-
/**
78-
* Use this class in tests to force the line length
79-
* and ensure a consistent output for expectations.
80-
*/
81-
class SymfonyStyleWithForcedLineLength extends SymfonyStyle
82-
{
83-
public function __construct(InputInterface $input, OutputInterface $output)
84-
{
85-
parent::__construct($input, $output);
86-
87-
$ref = new \ReflectionProperty(get_parent_class($this), 'lineLength');
88-
$ref->setAccessible(true);
89-
$ref->setValue($this, 120);
90-
}
91-
}

0 commit comments

Comments
 (0)
0