| @@ 33-74 (lines=42) @@ | ||
| 30 | * @group legacy |
|
| 31 | * @expectedDeprecation The Symfony\Component\Process\ProcessBuilder class is deprecated since version 3.4 and will be removed in 4.0. Use the Process class instead |
|
| 32 | */ |
|
| 33 | public function testCreateProcess() |
|
| 34 | { |
|
| 35 | $phpUnitConfig = $this->prophesize(PHPUnitConfig::class); |
|
| 36 | $cliCommand = $this->prophesize(CommandLine::class); |
|
| 37 | $cliCommand->getExecutable()->willReturn(['sapi', 'executable']); |
|
| 38 | $cliCommand |
|
| 39 | ->getOptions($phpUnitConfig->reveal()) |
|
| 40 | ->shouldBeCalled() |
|
| 41 | ->willReturn(['--configuration=config.xml']); |
|
| 42 | $cliCommand |
|
| 43 | ->getSpecificOptions('TestTest.php') |
|
| 44 | ->shouldBeCalled() |
|
| 45 | ->willReturn(['--specific=value-for-TestTest.php']); |
|
| 46 | $cliCommand |
|
| 47 | ->getSpecificOptions('TestTest2.php') |
|
| 48 | ->shouldBeCalled() |
|
| 49 | ->willReturn(['--specific=value-for-TestTest2.php']); |
|
| 50 | ||
| 51 | $tempFilenameFactory = $this->prophesize(TempFilenameFactory::class); |
|
| 52 | $tempFilenameFactory->getPathForLog() |
|
| 53 | ->willReturn('/path/for/log/'); |
|
| 54 | ||
| 55 | $factory = new ProcessBuilderFactory( |
|
| 56 | $cliCommand->reveal(), |
|
| 57 | $phpUnitConfig->reveal(), |
|
| 58 | $tempFilenameFactory->reveal() |
|
| 59 | ); |
|
| 60 | ||
| 61 | $processBuilder = $factory->create('TestTest.php'); |
|
| 62 | ||
| 63 | $this->assertInstanceOf(AbstractParaunitProcess::class, $processBuilder); |
|
| 64 | $commandLine = $processBuilder->getCommandLine(); |
|
| 65 | $this->assertContains('TestTest.php', $commandLine); |
|
| 66 | $this->assertContains('--specific=value-for-TestTest.php', $commandLine); |
|
| 67 | ||
| 68 | $processBuilder = $factory->create('TestTest2.php'); |
|
| 69 | ||
| 70 | $this->assertInstanceOf(AbstractParaunitProcess::class, $processBuilder); |
|
| 71 | $commandLine = $processBuilder->getCommandLine(); |
|
| 72 | $this->assertContains('TestTest2.php', $commandLine); |
|
| 73 | $this->assertContains('--specific=value-for-TestTest2.php', $commandLine); |
|
| 74 | } |
|
| 75 | } |
|
| 76 | ||
| @@ 31-72 (lines=42) @@ | ||
| 28 | parent::setUp(); |
|
| 29 | } |
|
| 30 | ||
| 31 | public function testCreateProcess() |
|
| 32 | { |
|
| 33 | $phpUnitConfig = $this->prophesize(PHPUnitConfig::class); |
|
| 34 | $cliCommand = $this->prophesize(CommandLine::class); |
|
| 35 | $cliCommand->getExecutable()->willReturn(['sapi', 'executable']); |
|
| 36 | $cliCommand |
|
| 37 | ->getOptions($phpUnitConfig->reveal()) |
|
| 38 | ->shouldBeCalled() |
|
| 39 | ->willReturn(['--configuration=config.xml']); |
|
| 40 | $cliCommand |
|
| 41 | ->getSpecificOptions('TestTest.php') |
|
| 42 | ->shouldBeCalledTimes(1) |
|
| 43 | ->willReturn(['--specific=value-for-TestTest.php']); |
|
| 44 | $cliCommand |
|
| 45 | ->getSpecificOptions('TestTest2.php') |
|
| 46 | ->shouldBeCalledTimes(1) |
|
| 47 | ->willReturn(['--specific=value-for-TestTest2.php']); |
|
| 48 | ||
| 49 | $tempFilenameFactory = $this->prophesize(TempFilenameFactory::class); |
|
| 50 | $tempFilenameFactory->getPathForLog() |
|
| 51 | ->willReturn('/path/for/log/'); |
|
| 52 | ||
| 53 | $factory = new ProcessFactory( |
|
| 54 | $cliCommand->reveal(), |
|
| 55 | $phpUnitConfig->reveal(), |
|
| 56 | $tempFilenameFactory->reveal() |
|
| 57 | ); |
|
| 58 | ||
| 59 | $processWrapper = $factory->create('TestTest.php'); |
|
| 60 | ||
| 61 | $this->assertInstanceOf(AbstractParaunitProcess::class, $processWrapper); |
|
| 62 | $commandLine = $processWrapper->getCommandLine(); |
|
| 63 | $this->assertContains('TestTest.php', $commandLine); |
|
| 64 | $this->assertContains('--specific=value-for-TestTest.php', $commandLine); |
|
| 65 | ||
| 66 | $processWrapper = $factory->create('TestTest2.php'); |
|
| 67 | ||
| 68 | $this->assertInstanceOf(AbstractParaunitProcess::class, $processWrapper); |
|
| 69 | $commandLine = $processWrapper->getCommandLine(); |
|
| 70 | $this->assertContains('TestTest2.php', $commandLine); |
|
| 71 | $this->assertContains('--specific=value-for-TestTest2.php', $commandLine); |
|
| 72 | } |
|
| 73 | } |
|
| 74 | ||