Completed
Pull Request — master (#12)
by Harry
02:36
created

TestCase::compareOutputs()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 2
1
<?php
2
3
/**
4
 * This file is part of graze/parallel-process.
5
 *
6
 * Copyright (c) 2017 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
class TestCase extends \PHPUnit_Framework_TestCase
18
{
19
    /**
20
     * Compare the outputs with an expected input.
21
     *
22
     * Each element in the array is a call to `write/writeln/reWrite`
23
     * Each element in the child array is a line to be written
24
     *
25
     * @param string[][] $expected Set of regular expressions to match against
26
     * @param string[][] $actual   The actual output
27
     */
28
    protected function compareOutputs(array $expected, array $actual)
29
    {
30
        $this->assertSameSize($expected, $actual);
31
32
        $expectedCount = count($expected);
33
        for ($i = 0; $i < $expectedCount; $i++) {
34
            $this->assertSameSize($expected[$i], $actual[$i]);
35
            $expectedChildCount = count($expected[$i]);
36
            for ($j = 0; $j < $expectedChildCount; $j++) {
37
                $this->assertRegExp($expected[$i][$j], $actual[$i][$j], sprintf('group: %d, line: %d', $i + 1, $j + 1));
38
            }
39
        }
40
    }
41
}
42