Code Duplication    Length = 26-26 lines in 3 locations

tests/unit/PoolTest.php 2 locations

@@ 324-349 (lines=26) @@
321
        $this->assertTrue($hit);
322
    }
323
324
    public function testOnProgressSetterIsCalledDuringProcessRun()
325
    {
326
        $process = Mockery::mock(Process::class);
327
        $process->shouldReceive('stop');
328
        $process->shouldReceive('isStarted')->andReturn(true);
329
        $process->shouldReceive('isRunning')->andReturn(false, false, true, false);
330
        $process->shouldReceive('start')->atLeast()->once();
331
        $process->shouldReceive('isSuccessful')->once()->andReturn(false);
332
333
        $hit = false;
334
335
        $pool = new Pool();
336
        $this->assertSame(
337
            $pool,
338
            $pool->setOnProgress(function ($proc) use ($process, &$hit) {
339
                $this->assertEquals($proc, $process);
340
                $hit = true;
341
            })
342
        );
343
344
        $pool->add($process);
345
346
        $pool->run(0);
347
348
        $this->assertTrue($hit);
349
    }
350
351
    public function testOnStartSetterIsCalledDuringProcessRun()
352
    {
@@ 351-376 (lines=26) @@
348
        $this->assertTrue($hit);
349
    }
350
351
    public function testOnStartSetterIsCalledDuringProcessRun()
352
    {
353
        $process = Mockery::mock(Process::class);
354
        $process->shouldReceive('stop');
355
        $process->shouldReceive('isStarted')->andReturn(true);
356
        $process->shouldReceive('isRunning')->andReturn(false, false, true, false);
357
        $process->shouldReceive('start')->atLeast()->once();
358
        $process->shouldReceive('isSuccessful')->once()->andReturn(false);
359
360
        $hit = false;
361
362
        $pool = new Pool();
363
        $this->assertSame(
364
            $pool,
365
            $pool->setOnStart(function ($proc) use ($process, &$hit) {
366
                $this->assertEquals($proc, $process);
367
                $hit = true;
368
            })
369
        );
370
371
        $pool->add($process);
372
373
        $pool->run(0);
374
375
        $this->assertTrue($hit);
376
    }
377
}
378

tests/unit/RunTest.php 1 location

@@ 162-187 (lines=26) @@
159
        $this->assertFalse($run->poll());
160
    }
161
162
    public function testOnProgress()
163
    {
164
        $process = Mockery::mock(Process::class);
165
        $process->shouldReceive('stop');
166
167
        $hit = false;
168
169
        $run = new Run(
170
            $process,
171
            null,
172
            null,
173
            function ($proc) use ($process, &$hit) {
174
                $this->assertSame($proc, $process);
175
                $hit = true;
176
            }
177
        );
178
179
        $process->shouldReceive('start')->once();
180
        $process->shouldReceive('isStarted')->andReturn(true);
181
        $process->shouldReceive('isRunning')->andReturn(false, true, false);
182
        $process->shouldReceive('isSuccessful')->once()->andReturn(true);
183
184
        $run->start();
185
        $this->assertTrue($run->poll());
186
        $this->assertFalse($run->poll());
187
    }
188
189
    public function testStartingAfterStartedWillDoNothing()
190
    {