diff --git a/Tests/ProcessFailedExceptionTest.php b/Tests/ProcessFailedExceptionTest.php index 4a0812c7..d6d7bfb0 100644 --- a/Tests/ProcessFailedExceptionTest.php +++ b/Tests/ProcessFailedExceptionTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Process\Exception\ProcessFailedException; +use Symfony\Component\Process\Process; /** * @author Sebastian Marek @@ -24,7 +25,7 @@ class ProcessFailedExceptionTest extends TestCase */ public function testProcessFailedExceptionThrowsException() { - $process = $this->getMockBuilder(\Symfony\Component\Process\Process::class)->setMethods(['isSuccessful'])->setConstructorArgs([['php']])->getMock(); + $process = $this->getMockBuilder(Process::class)->setMethods(['isSuccessful'])->setConstructorArgs([['php']])->getMock(); $process->expects($this->once()) ->method('isSuccessful') ->willReturn(true); @@ -48,7 +49,7 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput( $errorOutput = 'FATAL: Unexpected error'; $workingDirectory = getcwd(); - $process = $this->getMockBuilder(\Symfony\Component\Process\Process::class)->setMethods(['isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock(); + $process = $this->getMockBuilder(Process::class)->setMethods(['isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock(); $process->expects($this->once()) ->method('isSuccessful') ->willReturn(false); @@ -96,7 +97,7 @@ public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput() $exitText = 'General error'; $workingDirectory = getcwd(); - $process = $this->getMockBuilder(\Symfony\Component\Process\Process::class)->setMethods(['isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock(); + $process = $this->getMockBuilder(Process::class)->setMethods(['isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock(); $process->expects($this->once()) ->method('isSuccessful') ->willReturn(false); diff --git a/Tests/ProcessTest.php b/Tests/ProcessTest.php index 4fd0df20..7338e4e4 100644 --- a/Tests/ProcessTest.php +++ b/Tests/ProcessTest.php @@ -12,7 +12,10 @@ namespace Symfony\Component\Process\Tests; use PHPUnit\Framework\TestCase; +use Symfony\Component\Process\Exception\InvalidArgumentException; use Symfony\Component\Process\Exception\LogicException; +use Symfony\Component\Process\Exception\ProcessFailedException; +use Symfony\Component\Process\Exception\ProcessSignaledException; use Symfony\Component\Process\Exception\ProcessTimedOutException; use Symfony\Component\Process\Exception\RuntimeException; use Symfony\Component\Process\InputStream; @@ -78,13 +81,13 @@ public function testThatProcessDoesNotThrowWarningDuringRun() public function testNegativeTimeoutFromConstructor() { - $this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->getProcess('', null, null, null, -1); } public function testNegativeTimeoutFromSetter() { - $this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $p = $this->getProcess(''); $p->setTimeout(-1); } @@ -292,7 +295,7 @@ public function testSetInputWhileRunningThrowsAnException() */ public function testInvalidInput($value) { - $this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('"Symfony\Component\Process\Process::setInput" only accepts strings, Traversable objects or stream resources.'); $process = $this->getProcess('foo'); $process->setInput($value); @@ -555,7 +558,7 @@ public function testSuccessfulMustRunHasCorrectExitCode() public function testMustRunThrowsException() { - $this->expectException(\Symfony\Component\Process\Exception\ProcessFailedException::class); + $this->expectException(ProcessFailedException::class); $process = $this->getProcess('exit 1'); $process->mustRun(); } @@ -707,7 +710,7 @@ public function testProcessIsSignaledIfStopped() public function testProcessThrowsExceptionWhenExternallySignaled() { - $this->expectException(\Symfony\Component\Process\Exception\ProcessSignaledException::class); + $this->expectException(ProcessSignaledException::class); $this->expectExceptionMessage('The process has been signaled with signal "9".'); if (!\function_exists('posix_kill')) { $this->markTestSkipped('Function posix_kill is required.'); @@ -1485,7 +1488,7 @@ public function testPreparedCommandWithQuoteInIt() public function testPreparedCommandWithMissingValue() { - $this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Command line is missing a value for parameter "abc": echo "${:abc}"'); $p = Process::fromShellCommandline('echo "${:abc}"'); $p->run(null, ['bcd' => 'BCD']); @@ -1493,7 +1496,7 @@ public function testPreparedCommandWithMissingValue() public function testPreparedCommandWithNoValues() { - $this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Command line is missing a value for parameter "abc": echo "${:abc}"'); $p = Process::fromShellCommandline('echo "${:abc}"'); $p->run(null, []);