WithSuffixAbsolutePathStrategyTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
c 0
b 0
f 0
dl 0
loc 37
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A test_file_without_extension_neither_suffix_then_empty_string() 0 6 1
A test_file_with_extension_but_no_suffix_then_empty_string() 0 6 1
A test_file_without_extension_but_suffix() 0 8 1
A test_file_with_extension_and_suffix() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GacelaTest\Unit\Framework\Config\PathNormalizer;
6
7
use Gacela\Framework\Config\PathNormalizer\WithSuffixAbsolutePathStrategy;
8
use PHPUnit\Framework\TestCase;
9
10
final class WithSuffixAbsolutePathStrategyTest extends TestCase
11
{
12
    public function test_file_without_extension_neither_suffix_then_empty_string(): void
13
    {
14
        $strategy = new WithSuffixAbsolutePathStrategy('/app/root/');
15
        $relativePath = '/file-name';
16
17
        self::assertSame('', $strategy->generateAbsolutePath($relativePath));
18
    }
19
20
    public function test_file_without_extension_but_suffix(): void
21
    {
22
        $strategy = new WithSuffixAbsolutePathStrategy('/app/root/', 'suffix');
23
        $relativePath = '/file-name';
24
25
        self::assertSame(
26
            '/app/root/file-name-suffix',
27
            $strategy->generateAbsolutePath($relativePath),
28
        );
29
    }
30
31
    public function test_file_with_extension_but_no_suffix_then_empty_string(): void
32
    {
33
        $strategy = new WithSuffixAbsolutePathStrategy('/app/root/');
34
        $relativePath = '/file-name.ext';
35
36
        self::assertSame('', $strategy->generateAbsolutePath($relativePath));
37
    }
38
39
    public function test_file_with_extension_and_suffix(): void
40
    {
41
        $strategy = new WithSuffixAbsolutePathStrategy('/app/root/', 'suffix');
42
        $relativePath = '/file-name.ext';
43
44
        self::assertSame(
45
            '/app/root/file-name-suffix.ext',
46
            $strategy->generateAbsolutePath($relativePath),
47
        );
48
    }
49
}
50