Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CommandRendererBackgroundTest.php
Go to the documentation of this file.
1 <?php
7 
8 use \Magento\Framework\Shell\CommandRendererBackground;
9 
10 class CommandRendererBackgroundTest extends \PHPUnit\Framework\TestCase
11 {
17  protected $testCommand = 'php -r test.php';
18 
22  protected $osInfo;
23 
24  protected function setUp()
25  {
26  $this->osInfo = $this->getMockBuilder(\Magento\Framework\OsInfo::class)->getMock();
27  }
28 
34  public function testRender($isWindows, $expectedResults)
35  {
36  $this->osInfo->expects($this->once())
37  ->method('isWindows')
38  ->will($this->returnValue($isWindows));
39 
40  $commandRenderer = new CommandRendererBackground($this->osInfo);
41  $this->assertEquals(
42  $expectedResults,
43  $commandRenderer->render($this->testCommand)
44  );
45  }
46 
52  public function commandPerOsTypeDataProvider()
53  {
54  return [
55  'windows' => [true, 'start /B "magento background task" ' . $this->testCommand . ' 2>&1'],
56  'unix' => [false, $this->testCommand . ' > /dev/null &'],
57  ];
58  }
59 }