Skip to content

Commit 0ff3bf7

Browse files
committed
Merge branch '5.1' into 5.2
* 5.1: Use ::class keyword when possible
2 parents 86970bc + 5a86eff commit 0ff3bf7

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

Tests/ProcessFailedExceptionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ProcessFailedExceptionTest extends TestCase
2424
*/
2525
public function testProcessFailedExceptionThrowsException()
2626
{
27-
$process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful'])->setConstructorArgs([['php']])->getMock();
27+
$process = $this->getMockBuilder(\Symfony\Component\Process\Process::class)->setMethods(['isSuccessful'])->setConstructorArgs([['php']])->getMock();
2828
$process->expects($this->once())
2929
->method('isSuccessful')
3030
->willReturn(true);
@@ -48,7 +48,7 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput(
4848
$errorOutput = 'FATAL: Unexpected error';
4949
$workingDirectory = getcwd();
5050

51-
$process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock();
51+
$process = $this->getMockBuilder(\Symfony\Component\Process\Process::class)->setMethods(['isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock();
5252
$process->expects($this->once())
5353
->method('isSuccessful')
5454
->willReturn(false);
@@ -96,7 +96,7 @@ public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput()
9696
$exitText = 'General error';
9797
$workingDirectory = getcwd();
9898

99-
$process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock();
99+
$process = $this->getMockBuilder(\Symfony\Component\Process\Process::class)->setMethods(['isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock();
100100
$process->expects($this->once())
101101
->method('isSuccessful')
102102
->willReturn(false);

Tests/ProcessTest.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function tearDown(): void
4949

5050
public function testInvalidCwd()
5151
{
52-
$this->expectException('Symfony\Component\Process\Exception\RuntimeException');
52+
$this->expectException(RuntimeException::class);
5353
$this->expectExceptionMessageMatches('/The provided cwd ".*" does not exist\./');
5454
try {
5555
// Check that it works fine if the CWD exists
@@ -78,13 +78,13 @@ public function testThatProcessDoesNotThrowWarningDuringRun()
7878

7979
public function testNegativeTimeoutFromConstructor()
8080
{
81-
$this->expectException('Symfony\Component\Process\Exception\InvalidArgumentException');
81+
$this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class);
8282
$this->getProcess('', null, null, null, -1);
8383
}
8484

8585
public function testNegativeTimeoutFromSetter()
8686
{
87-
$this->expectException('Symfony\Component\Process\Exception\InvalidArgumentException');
87+
$this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class);
8888
$p = $this->getProcess('');
8989
$p->setTimeout(-1);
9090
}
@@ -272,7 +272,7 @@ public function testLiveStreamAsInput()
272272

273273
public function testSetInputWhileRunningThrowsAnException()
274274
{
275-
$this->expectException('Symfony\Component\Process\Exception\LogicException');
275+
$this->expectException(LogicException::class);
276276
$this->expectExceptionMessage('Input can not be set while the process is running.');
277277
$process = $this->getProcessForCode('sleep(30);');
278278
$process->start();
@@ -292,7 +292,7 @@ public function testSetInputWhileRunningThrowsAnException()
292292
*/
293293
public function testInvalidInput($value)
294294
{
295-
$this->expectException('Symfony\Component\Process\Exception\InvalidArgumentException');
295+
$this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class);
296296
$this->expectExceptionMessage('"Symfony\Component\Process\Process::setInput" only accepts strings, Traversable objects or stream resources.');
297297
$process = $this->getProcess('foo');
298298
$process->setInput($value);
@@ -508,7 +508,7 @@ public function testTTYCommandExitCode()
508508

509509
public function testTTYInWindowsEnvironment()
510510
{
511-
$this->expectException('Symfony\Component\Process\Exception\RuntimeException');
511+
$this->expectException(RuntimeException::class);
512512
$this->expectExceptionMessage('TTY mode is not supported on Windows platform.');
513513
if ('\\' !== \DIRECTORY_SEPARATOR) {
514514
$this->markTestSkipped('This test is for Windows platform only');
@@ -555,7 +555,7 @@ public function testSuccessfulMustRunHasCorrectExitCode()
555555

556556
public function testMustRunThrowsException()
557557
{
558-
$this->expectException('Symfony\Component\Process\Exception\ProcessFailedException');
558+
$this->expectException(\Symfony\Component\Process\Exception\ProcessFailedException::class);
559559
$process = $this->getProcess('exit 1');
560560
$process->mustRun();
561561
}
@@ -707,7 +707,7 @@ public function testProcessIsSignaledIfStopped()
707707

708708
public function testProcessThrowsExceptionWhenExternallySignaled()
709709
{
710-
$this->expectException('Symfony\Component\Process\Exception\ProcessSignaledException');
710+
$this->expectException(\Symfony\Component\Process\Exception\ProcessSignaledException::class);
711711
$this->expectExceptionMessage('The process has been signaled with signal "9".');
712712
if (!\function_exists('posix_kill')) {
713713
$this->markTestSkipped('Function posix_kill is required.');
@@ -744,7 +744,7 @@ public function testRestart()
744744

745745
public function testRunProcessWithTimeout()
746746
{
747-
$this->expectException('Symfony\Component\Process\Exception\ProcessTimedOutException');
747+
$this->expectException(ProcessTimedOutException::class);
748748
$this->expectExceptionMessage('exceeded the timeout of 0.1 seconds.');
749749
$process = $this->getProcessForCode('sleep(30);');
750750
$process->setTimeout(0.1);
@@ -762,7 +762,7 @@ public function testRunProcessWithTimeout()
762762

763763
public function testIterateOverProcessWithTimeout()
764764
{
765-
$this->expectException('Symfony\Component\Process\Exception\ProcessTimedOutException');
765+
$this->expectException(ProcessTimedOutException::class);
766766
$this->expectExceptionMessage('exceeded the timeout of 0.1 seconds.');
767767
$process = $this->getProcessForCode('sleep(30);');
768768
$process->setTimeout(0.1);
@@ -794,7 +794,7 @@ public function testCheckTimeoutOnTerminatedProcess()
794794

795795
public function testCheckTimeoutOnStartedProcess()
796796
{
797-
$this->expectException('Symfony\Component\Process\Exception\ProcessTimedOutException');
797+
$this->expectException(ProcessTimedOutException::class);
798798
$this->expectExceptionMessage('exceeded the timeout of 0.1 seconds.');
799799
$process = $this->getProcessForCode('sleep(33);');
800800
$process->setTimeout(0.1);
@@ -857,7 +857,7 @@ public function testIdleTimeoutNotExceededWhenOutputIsSent()
857857

858858
public function testStartAfterATimeout()
859859
{
860-
$this->expectException('Symfony\Component\Process\Exception\ProcessTimedOutException');
860+
$this->expectException(ProcessTimedOutException::class);
861861
$this->expectExceptionMessage('exceeded the timeout of 0.1 seconds.');
862862
$process = $this->getProcessForCode('sleep(35);');
863863
$process->setTimeout(0.1);
@@ -934,7 +934,7 @@ public function testExitCodeIsAvailableAfterSignal()
934934

935935
public function testSignalProcessNotRunning()
936936
{
937-
$this->expectException('Symfony\Component\Process\Exception\LogicException');
937+
$this->expectException(LogicException::class);
938938
$this->expectExceptionMessage('Can not send signal on a non running process.');
939939
$process = $this->getProcess('foo');
940940
$process->signal(1); // SIGHUP
@@ -947,7 +947,7 @@ public function testMethodsThatNeedARunningProcess($method)
947947
{
948948
$process = $this->getProcess('foo');
949949

950-
$this->expectException('Symfony\Component\Process\Exception\LogicException');
950+
$this->expectException(LogicException::class);
951951
$this->expectExceptionMessage(sprintf('Process must be started before calling "%s()".', $method));
952952

953953
$process->{$method}();
@@ -969,7 +969,7 @@ public function provideMethodsThatNeedARunningProcess()
969969
*/
970970
public function testMethodsThatNeedATerminatedProcess($method)
971971
{
972-
$this->expectException('Symfony\Component\Process\Exception\LogicException');
972+
$this->expectException(LogicException::class);
973973
$this->expectExceptionMessage('Process must be terminated before calling');
974974
$process = $this->getProcessForCode('sleep(37);');
975975
$process->start();
@@ -1024,7 +1024,7 @@ public function testDisableOutputDisablesTheOutput()
10241024

10251025
public function testDisableOutputWhileRunningThrowsException()
10261026
{
1027-
$this->expectException('Symfony\Component\Process\Exception\RuntimeException');
1027+
$this->expectException(RuntimeException::class);
10281028
$this->expectExceptionMessage('Disabling output while the process is running is not possible.');
10291029
$p = $this->getProcessForCode('sleep(39);');
10301030
$p->start();
@@ -1033,7 +1033,7 @@ public function testDisableOutputWhileRunningThrowsException()
10331033

10341034
public function testEnableOutputWhileRunningThrowsException()
10351035
{
1036-
$this->expectException('Symfony\Component\Process\Exception\RuntimeException');
1036+
$this->expectException(RuntimeException::class);
10371037
$this->expectExceptionMessage('Enabling output while the process is running is not possible.');
10381038
$p = $this->getProcessForCode('sleep(40);');
10391039
$p->disableOutput();
@@ -1053,7 +1053,7 @@ public function testEnableOrDisableOutputAfterRunDoesNotThrowException()
10531053

10541054
public function testDisableOutputWhileIdleTimeoutIsSet()
10551055
{
1056-
$this->expectException('Symfony\Component\Process\Exception\LogicException');
1056+
$this->expectException(LogicException::class);
10571057
$this->expectExceptionMessage('Output can not be disabled while an idle timeout is set.');
10581058
$process = $this->getProcess('foo');
10591059
$process->setIdleTimeout(1);
@@ -1062,7 +1062,7 @@ public function testDisableOutputWhileIdleTimeoutIsSet()
10621062

10631063
public function testSetIdleTimeoutWhileOutputIsDisabled()
10641064
{
1065-
$this->expectException('Symfony\Component\Process\Exception\LogicException');
1065+
$this->expectException(LogicException::class);
10661066
$this->expectExceptionMessage('timeout can not be set while the output is disabled.');
10671067
$process = $this->getProcess('foo');
10681068
$process->disableOutput();
@@ -1081,7 +1081,7 @@ public function testSetNullIdleTimeoutWhileOutputIsDisabled()
10811081
*/
10821082
public function testGetOutputWhileDisabled($fetchMethod)
10831083
{
1084-
$this->expectException('Symfony\Component\Process\Exception\LogicException');
1084+
$this->expectException(LogicException::class);
10851085
$this->expectExceptionMessage('Output has been disabled.');
10861086
$p = $this->getProcessForCode('sleep(41);');
10871087
$p->disableOutput();
@@ -1485,15 +1485,15 @@ public function testPreparedCommandWithQuoteInIt()
14851485

14861486
public function testPreparedCommandWithMissingValue()
14871487
{
1488-
$this->expectException('Symfony\Component\Process\Exception\InvalidArgumentException');
1488+
$this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class);
14891489
$this->expectExceptionMessage('Command line is missing a value for parameter "abc": echo "${:abc}"');
14901490
$p = Process::fromShellCommandline('echo "${:abc}"');
14911491
$p->run(null, ['bcd' => 'BCD']);
14921492
}
14931493

14941494
public function testPreparedCommandWithNoValues()
14951495
{
1496-
$this->expectException('Symfony\Component\Process\Exception\InvalidArgumentException');
1496+
$this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class);
14971497
$this->expectExceptionMessage('Command line is missing a value for parameter "abc": echo "${:abc}"');
14981498
$p = Process::fromShellCommandline('echo "${:abc}"');
14991499
$p->run(null, []);

0 commit comments

Comments
 (0)