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

FilePathResolverTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetTestFileName() 0 4 1
A testGetApprovalFilePath() 0 4 1
A provideTestFileName() 0 12 1
A provideTestFilePath() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AHJ\ApprovalTests\Tests\Unit;
6
7
use AHJ\ApprovalTests\FilePathResolver;
8
use Generator;
9
use PHPUnit\Framework\Assert;
10
use PHPUnit\Framework\TestCase;
11
12
final class FilePathResolverTest extends TestCase
13
{
14
    /**
15
     * @dataProvider provideTestFilePath
16
     */
17
    public function testGetApprovalFilePath(string $testFilePath, string $expected): void
18
    {
19
        $actual = (new FilePathResolver())->getApprovalFilePath($testFilePath);
20
        Assert::assertEquals($expected, $actual);
21
    }
22
23
    public function provideTestFilePath(): Generator
24
    {
25
        yield 'simple test file path' => [
26
            'testFilePath' => '/Users/alex/Dev/approval-tests/tests/Example/GildedRoseTest.php',
27
            'expected' => 'tests/Example/approval',
28
        ];
29
30
        yield 'nested test file path' => [
31
            'testFilePath' => '/Users/alex/Dev/approval-tests/tests/Example/ExtraCase/GildedRoseTest.php',
32
            'expected' => 'tests/Example/ExtraCase/approval',
33
        ];
34
    }
35
36
    /**
37
     * @dataProvider provideTestFileName
38
     */
39
    public function testGetTestFileName(string $testFileName, string $testMethodName, string $expected): void
40
    {
41
        $actual = (new FilePathResolver())->getApprovalFileName($testFileName, $testMethodName);
42
        Assert::assertEquals($expected, $actual);
43
    }
44
45
    public function provideTestFileName(): Generator
46
    {
47
        yield 'name in simple test file path' => [
48
            'testFileName' => '/Users/alex/Dev/approval-tests/tests/Example/GildedRoseTest.php',
49
            'testMethodName' => 'testUpdateQuality',
50
            'expected' => 'GildedRoseTest.testUpdateQuality',
51
        ];
52
53
        yield 'name in nested test file path' => [
54
            'testFileName' => '/Users/alex/Dev/approval-tests/tests/ExtraCase/Example/ExtraCase/GildedRoseTest.php',
55
            'testMethodName' => 'testFunkyMethodInExtraCase',
56
            'expected' => 'GildedRoseTest.testFunkyMethodInExtraCase',
57
        ];
58
    }
59
}
60