These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | use AspectMock\Test as test; |
||
3 | |||
4 | class ParallelExecTest extends \Codeception\TestCase\Test |
||
5 | { |
||
6 | /** |
||
7 | * @var \CodeGuy |
||
8 | */ |
||
9 | protected $guy; |
||
10 | |||
11 | /** |
||
12 | * @var \AspectMock\Proxy\ClassProxy |
||
13 | */ |
||
14 | protected $process; |
||
15 | |||
16 | protected function _before() |
||
17 | { |
||
18 | $this->process = test::double('Symfony\Component\Process\Process', [ |
||
19 | 'run' => false, |
||
20 | 'start' => false, |
||
21 | 'isRunning' => false, |
||
22 | 'getOutput' => 'Hello world', |
||
23 | 'getExitCode' => 0, |
||
24 | 'logger' => new \Psr\Log\NullLogger(), |
||
25 | ]); |
||
26 | } |
||
27 | |||
28 | View Code Duplication | public function testParallelExec() |
|
29 | { |
||
30 | $task = new \Robo\Task\Base\ParallelExec(); |
||
31 | $task->setLogger($this->guy->logger()); |
||
32 | |||
33 | $result = $task |
||
34 | ->process('ls 1') |
||
35 | ->process('ls 2') |
||
36 | ->process('ls 3') |
||
37 | ->run(); |
||
38 | $this->process->verifyInvokedMultipleTimes('start', 3); |
||
39 | verify($result->getExitCode())->equals(0); |
||
40 | $this->guy->seeInOutput("3 processes finished"); |
||
41 | } |
||
42 | |||
43 | View Code Duplication | public function testParallelExecWithWaitInterval() |
|
0 ignored issues
–
show
|
|||
44 | { |
||
45 | $task = new \Robo\Task\Base\ParallelExec(); |
||
46 | $task->setLogger($this->guy->logger()); |
||
47 | |||
48 | $result = $task |
||
49 | ->process('ls 1') |
||
50 | ->process('ls 2') |
||
51 | ->process('ls 3') |
||
52 | ->waitInterval(1) |
||
53 | ->run(); |
||
54 | $this->process->verifyInvokedMultipleTimes('start', 3); |
||
55 | verify($result->getExitCode())->equals(0); |
||
56 | $this->guy->seeInOutput("3 processes finished"); |
||
57 | } |
||
58 | } |
||
59 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.