|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| - * Copyright © 2013-2017 Magento, Inc. All rights reserved. |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
6 | 6 | namespace Magento\Framework\Shell\Test\Unit;
|
7 | 7 |
|
8 |
| -use \Magento\Framework\Shell\CommandRenderer; |
| 8 | +use Magento\Framework\Shell\CommandRenderer; |
9 | 9 |
|
10 | 10 | class CommandRendererTest extends \PHPUnit_Framework_TestCase
|
11 | 11 | {
|
12 |
| - public function testRender() |
| 12 | + /** |
| 13 | + * @param $expectedCommand |
| 14 | + * @param $actualCommand |
| 15 | + * @param $testArguments |
| 16 | + * @dataProvider commandsDataProvider |
| 17 | + */ |
| 18 | + public function testRender($expectedCommand, $actualCommand, $testArguments) |
13 | 19 | {
|
14 |
| - $testArgument = 'argument'; |
15 |
| - $testArgument2 = 'argument2'; |
16 | 20 | $commandRenderer = new CommandRenderer();
|
17 | 21 | $this->assertEquals(
|
18 |
| - "php -r " . escapeshellarg($testArgument) . " 2>&1 | grep " . escapeshellarg($testArgument2) . " 2>&1", |
19 |
| - $commandRenderer->render('php -r %s | grep %s', [$testArgument, $testArgument2]) |
| 22 | + $expectedCommand, |
| 23 | + $commandRenderer->render($actualCommand, $testArguments) |
20 | 24 | );
|
21 | 25 | }
|
| 26 | + |
| 27 | + public function commandsDataProvider() |
| 28 | + { |
| 29 | + $testArgument = 'argument'; |
| 30 | + $testArgument2 = 'argument2'; |
| 31 | + |
| 32 | + $expectedCommand = "php -r %s 2>&1 | grep %s 2>&1"; |
| 33 | + $expectedCommandArgs = "php -r '" . $testArgument . "' 2>&1 | grep '" . $testArgument2 . "' 2>&1"; |
| 34 | + |
| 35 | + return [ |
| 36 | + [$expectedCommand, 'php -r %s | grep %s', []], |
| 37 | + [$expectedCommand, 'php -r %s 2>&1 | grep %s', []], |
| 38 | + [$expectedCommand, 'php -r %s 2>&1 2>&1 | grep %s', []], |
| 39 | + [$expectedCommandArgs, 'php -r %s | grep %s', [$testArgument, $testArgument2]], |
| 40 | + [$expectedCommandArgs, 'php -r %s 2>&1 | grep %s', [$testArgument, $testArgument2]], |
| 41 | + [$expectedCommandArgs, 'php -r %s 2>&1 2>&1 | grep %s', [$testArgument, $testArgument2]], |
| 42 | + ]; |
| 43 | + } |
22 | 44 | }
|
0 commit comments