Skip to content

Commit d279ae7

Browse files
Merge branch '4.4' into 5.1
* 4.4: Use createMock() and use import instead of FQCN
2 parents 9ee12c5 + 7e950b6 commit d279ae7

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

Tests/ProcessFailedExceptionTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Process\Exception\ProcessFailedException;
16+
use Symfony\Component\Process\Process;
1617

1718
/**
1819
* @author Sebastian Marek <proofek@gmail.com>
@@ -24,7 +25,7 @@ class ProcessFailedExceptionTest extends TestCase
2425
*/
2526
public function testProcessFailedExceptionThrowsException()
2627
{
27-
$process = $this->getMockBuilder(\Symfony\Component\Process\Process::class)->setMethods(['isSuccessful'])->setConstructorArgs([['php']])->getMock();
28+
$process = $this->getMockBuilder(Process::class)->setMethods(['isSuccessful'])->setConstructorArgs([['php']])->getMock();
2829
$process->expects($this->once())
2930
->method('isSuccessful')
3031
->willReturn(true);
@@ -48,7 +49,7 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput(
4849
$errorOutput = 'FATAL: Unexpected error';
4950
$workingDirectory = getcwd();
5051

51-
$process = $this->getMockBuilder(\Symfony\Component\Process\Process::class)->setMethods(['isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock();
52+
$process = $this->getMockBuilder(Process::class)->setMethods(['isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock();
5253
$process->expects($this->once())
5354
->method('isSuccessful')
5455
->willReturn(false);
@@ -96,7 +97,7 @@ public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput()
9697
$exitText = 'General error';
9798
$workingDirectory = getcwd();
9899

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

Tests/ProcessTest.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
namespace Symfony\Component\Process\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Process\Exception\InvalidArgumentException;
1516
use Symfony\Component\Process\Exception\LogicException;
17+
use Symfony\Component\Process\Exception\ProcessFailedException;
18+
use Symfony\Component\Process\Exception\ProcessSignaledException;
1619
use Symfony\Component\Process\Exception\ProcessTimedOutException;
1720
use Symfony\Component\Process\Exception\RuntimeException;
1821
use Symfony\Component\Process\InputStream;
@@ -78,13 +81,13 @@ public function testThatProcessDoesNotThrowWarningDuringRun()
7881

7982
public function testNegativeTimeoutFromConstructor()
8083
{
81-
$this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class);
84+
$this->expectException(InvalidArgumentException::class);
8285
$this->getProcess('', null, null, null, -1);
8386
}
8487

8588
public function testNegativeTimeoutFromSetter()
8689
{
87-
$this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class);
90+
$this->expectException(InvalidArgumentException::class);
8891
$p = $this->getProcess('');
8992
$p->setTimeout(-1);
9093
}
@@ -292,7 +295,7 @@ public function testSetInputWhileRunningThrowsAnException()
292295
*/
293296
public function testInvalidInput($value)
294297
{
295-
$this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class);
298+
$this->expectException(InvalidArgumentException::class);
296299
$this->expectExceptionMessage('"Symfony\Component\Process\Process::setInput" only accepts strings, Traversable objects or stream resources.');
297300
$process = $this->getProcess('foo');
298301
$process->setInput($value);
@@ -555,7 +558,7 @@ public function testSuccessfulMustRunHasCorrectExitCode()
555558

556559
public function testMustRunThrowsException()
557560
{
558-
$this->expectException(\Symfony\Component\Process\Exception\ProcessFailedException::class);
561+
$this->expectException(ProcessFailedException::class);
559562
$process = $this->getProcess('exit 1');
560563
$process->mustRun();
561564
}
@@ -707,7 +710,7 @@ public function testProcessIsSignaledIfStopped()
707710

708711
public function testProcessThrowsExceptionWhenExternallySignaled()
709712
{
710-
$this->expectException(\Symfony\Component\Process\Exception\ProcessSignaledException::class);
713+
$this->expectException(ProcessSignaledException::class);
711714
$this->expectExceptionMessage('The process has been signaled with signal "9".');
712715
if (!\function_exists('posix_kill')) {
713716
$this->markTestSkipped('Function posix_kill is required.');
@@ -1485,15 +1488,15 @@ public function testPreparedCommandWithQuoteInIt()
14851488

14861489
public function testPreparedCommandWithMissingValue()
14871490
{
1488-
$this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class);
1491+
$this->expectException(InvalidArgumentException::class);
14891492
$this->expectExceptionMessage('Command line is missing a value for parameter "abc": echo "${:abc}"');
14901493
$p = Process::fromShellCommandline('echo "${:abc}"');
14911494
$p->run(null, ['bcd' => 'BCD']);
14921495
}
14931496

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

0 commit comments

Comments
 (0)