|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of graze/parallel-process. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright © 2018 Nature Delivered Ltd. <https://www.graze.com> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
* |
|
11
|
|
|
* @license https://github.com/graze/parallel-process/blob/master/LICENSE.md |
|
12
|
|
|
* @link https://github.com/graze/parallel-process |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Graze\ParallelProcess\Test; |
|
16
|
|
|
|
|
17
|
|
|
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; |
|
18
|
|
|
|
|
19
|
|
|
class TestCase extends \PHPUnit\Framework\TestCase |
|
20
|
|
|
{ |
|
21
|
|
|
use MockeryPHPUnitIntegration; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Compare the outputs with an expected input. |
|
25
|
|
|
* |
|
26
|
|
|
* Each element in the array is a call to `write/writeln/reWrite` |
|
27
|
|
|
* Each element in the child array is a line to be written |
|
28
|
|
|
* |
|
29
|
|
|
* @param string[][] $expected Set of regular expressions to match against |
|
30
|
|
|
* @param string[][] $actual The actual output |
|
31
|
|
|
*/ |
|
32
|
|
|
protected function compareOutputs(array $expected, array $actual) |
|
33
|
|
|
{ |
|
34
|
|
|
$this->assertSameSize($expected, $actual); |
|
35
|
|
|
|
|
36
|
|
|
$expectedCount = count($expected); |
|
37
|
|
|
for ($i = 0; $i < $expectedCount; $i++) { |
|
38
|
|
|
$this->assertSameSize($expected[$i], $actual[$i]); |
|
39
|
|
|
$expectedChildCount = count($expected[$i]); |
|
40
|
|
|
for ($j = 0; $j < $expectedChildCount; $j++) { |
|
41
|
|
|
$this->assertRegExp($expected[$i][$j], $actual[$i][$j], sprintf('group: %d, line: %d', $i + 1, $j + 1)); |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|