Test Failed
Push — main ( 6df04e...456b77 )
by Alexandra
11:41 queued 02:13
created

ReceivedMapTest::testCreate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 5
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AHJ\ApprovalTests\Tests\Unit;
6
7
use AHJ\ApprovalTests\ReceivedMap;
8
use AHJ\ApprovalTests\Tests\Example\Item;
9
use Generator;
10
use PHPUnit\Framework\Assert;
11
use PHPUnit\Framework\TestCase;
12
13
final class ReceivedMapTest extends TestCase
14
{
15
    /**
16
     * @dataProvider provideTestInput
17
     */
18
    public function testCreate(array $input, array $output, string $expected): void
19
    {
20
        $actual = (new ReceivedMap())->create($input, $output);
21
22
        Assert::assertEquals($expected, $actual);
23
    }
24
25
    public function provideTestInput(): Generator
26
    {
27
        yield 'for item foo' => [
28
            'input' => [
29
                new Item('foo', 0, 1),
30
            ],
31
            'output' => [
32
                new Item('foo', -1, 0),
33
            ],
34
            'expected' => '[foo, 0, 1] -> [foo, -1, 0]',
35
        ];
36
37
        yield 'for item bar' => [
38
            'input' => [
39
                new Item('bar', 1, 1),
40
                new Item('bar', 1, 0),
41
                new Item('bar', 1, 100),
42
            ],
43
            'output' => [
44
                new Item('bar', -1, 0),
45
                new Item('bar', 1, 10),
46
                new Item('bar', -1, 50),
47
            ],
48
            'expected' => '[bar, 1, 1] -> [bar, -1, 0]
49
[bar, 1, 0] -> [bar, 1, 10]
50
[bar, 1, 100] -> [bar, -1, 50]',
51
        ];
52
    }
53
}
54