Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CommandRendererTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class CommandRendererTest extends \PHPUnit\Framework\TestCase
11 {
18  public function testRender($expectedCommand, $actualCommand, $testArguments)
19  {
20  $commandRenderer = new CommandRenderer();
21  $this->assertEquals(
22  $expectedCommand,
23  $commandRenderer->render($actualCommand, $testArguments)
24  );
25  }
26 
30  public function commandsDataProvider()
31  {
32  $testArgument = 'argument';
33  $testArgument2 = 'argument2';
34 
35  $expectedCommand = "php -r %s 2>&1 | grep %s 2>&1";
36  $expectedCommandArgs = "php -r '" . $testArgument . "' 2>&1 | grep '" . $testArgument2 . "' 2>&1";
37 
38  return [
39  [$expectedCommand, 'php -r %s | grep %s', []],
40  [$expectedCommand, 'php -r %s 2>&1 | grep %s', []],
41  [$expectedCommand, 'php -r %s 2>&1 2>&1 | grep %s', []],
42  [$expectedCommandArgs, 'php -r %s | grep %s', [$testArgument, $testArgument2]],
43  [$expectedCommandArgs, 'php -r %s 2>&1 | grep %s', [$testArgument, $testArgument2]],
44  [$expectedCommandArgs, 'php -r %s 2>&1 2>&1 | grep %s', [$testArgument, $testArgument2]],
45  ];
46  }
47 }
testRender($expectedCommand, $actualCommand, $testArguments)