| @@ 188-212 (lines=25) @@ | ||
| 185 | $this->assertTrue($pool->isRunning());  | 
                                |
| 186 | }  | 
                                |
| 187 | ||
| 188 | public function testOnSuccessIsCalledOnSuccessfulProcess()  | 
                                |
| 189 |     { | 
                                |
| 190 | $process = Mockery::mock(Process::class);  | 
                                |
| 191 |         $process->shouldReceive('stop'); | 
                                |
| 192 |         $process->shouldReceive('isStarted')->andReturn(true); | 
                                |
| 193 |         $process->shouldReceive('isRunning')->andReturn(false); | 
                                |
| 194 |         $process->shouldReceive('start')->atLeast()->once(); | 
                                |
| 195 |         $process->shouldReceive('isSuccessful')->once()->andReturn(true); | 
                                |
| 196 | ||
| 197 | $hit = false;  | 
                                |
| 198 | ||
| 199 | $pool = new Pool(  | 
                                |
| 200 | [],  | 
                                |
| 201 |             function ($proc) use ($process, &$hit) { | 
                                |
| 202 | $this->assertSame($proc, $process);  | 
                                |
| 203 | $hit = true;  | 
                                |
| 204 | }  | 
                                |
| 205 | );  | 
                                |
| 206 | ||
| 207 | $pool->add($process);  | 
                                |
| 208 | ||
| 209 | $pool->run(0);  | 
                                |
| 210 | ||
| 211 | $this->assertTrue($hit);  | 
                                |
| 212 | }  | 
                                |
| 213 | ||
| 214 | public function testOnFailureIsCalledForErroredProcess()  | 
                                |
| 215 |     { | 
                                |
| @@ 214-239 (lines=26) @@ | ||
| 211 | $this->assertTrue($hit);  | 
                                |
| 212 | }  | 
                                |
| 213 | ||
| 214 | public function testOnFailureIsCalledForErroredProcess()  | 
                                |
| 215 |     { | 
                                |
| 216 | $process = Mockery::mock(Process::class);  | 
                                |
| 217 |         $process->shouldReceive('stop'); | 
                                |
| 218 |         $process->shouldReceive('isStarted')->andReturn(true); | 
                                |
| 219 |         $process->shouldReceive('isRunning')->andReturn(false); | 
                                |
| 220 |         $process->shouldReceive('start')->atLeast()->once(); | 
                                |
| 221 |         $process->shouldReceive('isSuccessful')->once()->andReturn(false); | 
                                |
| 222 | ||
| 223 | $hit = false;  | 
                                |
| 224 | ||
| 225 | $pool = new Pool(  | 
                                |
| 226 | [],  | 
                                |
| 227 | null,  | 
                                |
| 228 |             function ($proc) use ($process, &$hit) { | 
                                |
| 229 | $this->assertEquals($proc, $process);  | 
                                |
| 230 | $hit = true;  | 
                                |
| 231 | }  | 
                                |
| 232 | );  | 
                                |
| 233 | ||
| 234 | $pool->add($process);  | 
                                |
| 235 | ||
| 236 | $pool->run(0);  | 
                                |
| 237 | ||
| 238 | $this->assertTrue($hit);  | 
                                |
| 239 | }  | 
                                |
| 240 | ||
| 241 | public function testOnProgressIsCalledDuringProcessRun()  | 
                                |
| 242 |     { | 
                                |
| @@ 113-135 (lines=23) @@ | ||
| 110 | $this->assertTrue($run->hasStarted());  | 
                                |
| 111 | }  | 
                                |
| 112 | ||
| 113 | public function testOnSuccess()  | 
                                |
| 114 |     { | 
                                |
| 115 | $process = Mockery::mock(Process::class);  | 
                                |
| 116 |         $process->shouldReceive('stop'); | 
                                |
| 117 | ||
| 118 | $hit = false;  | 
                                |
| 119 | ||
| 120 | $run = new Run(  | 
                                |
| 121 | $process,  | 
                                |
| 122 |             function ($proc) use ($process, &$hit) { | 
                                |
| 123 | $this->assertSame($proc, $process);  | 
                                |
| 124 | $hit = true;  | 
                                |
| 125 | }  | 
                                |
| 126 | );  | 
                                |
| 127 | ||
| 128 |         $process->shouldReceive('start')->once(); | 
                                |
| 129 |         $process->shouldReceive('isStarted')->andReturn(true); | 
                                |
| 130 |         $process->shouldReceive('isRunning')->andReturn(false); | 
                                |
| 131 |         $process->shouldReceive('isSuccessful')->once()->andReturn(true); | 
                                |
| 132 | ||
| 133 | $run->start();  | 
                                |
| 134 | $this->assertFalse($run->poll());  | 
                                |
| 135 | }  | 
                                |
| 136 | ||
| 137 | public function testOnFailure()  | 
                                |
| 138 |     { | 
                                |
| @@ 137-160 (lines=24) @@ | ||
| 134 | $this->assertFalse($run->poll());  | 
                                |
| 135 | }  | 
                                |
| 136 | ||
| 137 | public function testOnFailure()  | 
                                |
| 138 |     { | 
                                |
| 139 | $process = Mockery::mock(Process::class);  | 
                                |
| 140 |         $process->shouldReceive('stop'); | 
                                |
| 141 | ||
| 142 | $hit = false;  | 
                                |
| 143 | ||
| 144 | $run = new Run(  | 
                                |
| 145 | $process,  | 
                                |
| 146 | null,  | 
                                |
| 147 |             function ($proc) use ($process, &$hit) { | 
                                |
| 148 | $this->assertSame($proc, $process);  | 
                                |
| 149 | $hit = true;  | 
                                |
| 150 | }  | 
                                |
| 151 | );  | 
                                |
| 152 | ||
| 153 |         $process->shouldReceive('start')->once(); | 
                                |
| 154 |         $process->shouldReceive('isStarted')->andReturn(true); | 
                                |
| 155 |         $process->shouldReceive('isRunning')->andReturn(false); | 
                                |
| 156 |         $process->shouldReceive('isSuccessful')->once()->andReturn(false); | 
                                |
| 157 | ||
| 158 | $run->start();  | 
                                |
| 159 | $this->assertFalse($run->poll());  | 
                                |
| 160 | }  | 
                                |
| 161 | ||
| 162 | public function testOnProgress()  | 
                                |
| 163 |     { | 
                                |