tigitz /
php-spellchecker
| 1 | <?php |
||||
| 2 | |||||
| 3 | declare(strict_types=1); |
||||
| 4 | |||||
| 5 | namespace PhpSpellcheck\Tests\Exception; |
||||
| 6 | |||||
| 7 | use PhpSpellcheck\Exception\ProcessFailedException; |
||||
| 8 | use PHPUnit\Framework\TestCase; |
||||
| 9 | use Symfony\Component\Process\Exception\ExceptionInterface; |
||||
| 10 | use Symfony\Component\Process\Process; |
||||
| 11 | |||||
| 12 | class ProcessFailedExceptionTest extends TestCase |
||||
| 13 | { |
||||
| 14 | public function testSymfonyRunningProcessFailedException() |
||||
| 15 | { |
||||
| 16 | $process = new Process('non_existing_binaries'); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 17 | try { |
||||
| 18 | $process->mustRun(); |
||||
| 19 | } catch (ExceptionInterface $exception) { |
||||
| 20 | $processFailure = new ProcessFailedException($process, $exception); |
||||
| 21 | $this->assertSame( |
||||
| 22 | 'Process with command "non_existing_binaries" has failed running with exit code 127(Command not found)', |
||||
| 23 | $processFailure->getMessage() |
||||
| 24 | ); |
||||
| 25 | } |
||||
| 26 | } |
||||
| 27 | |||||
| 28 | public function testSymfonyBootingProcessFailedException() |
||||
| 29 | { |
||||
| 30 | |||||
| 31 | $process = new Process('echo test', __DIR__ . '/notfound/'); |
||||
|
0 ignored issues
–
show
'echo test' of type string is incompatible with the type array expected by parameter $command of Symfony\Component\Process\Process::__construct().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 32 | try { |
||||
| 33 | $process->mustRun(); |
||||
| 34 | } catch (ExceptionInterface $exception) { |
||||
| 35 | $processFailure = new ProcessFailedException($process, $exception); |
||||
| 36 | $this->assertSame( |
||||
| 37 | 'Process with command "echo test" has failed with exit code 0()', |
||||
| 38 | $processFailure->getMessage() |
||||
| 39 | ); |
||||
| 40 | |||||
| 41 | return; |
||||
| 42 | } |
||||
| 43 | |||||
| 44 | $this->markTestSkipped('Test is only relevant for symfony/process: ^4.0'); |
||||
| 45 | } |
||||
| 46 | } |
||||
| 47 |