Passed
Pull Request — master (#141)
by
unknown
11:36
created

ConfigTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 36
c 2
b 0
f 0
dl 0
loc 73
rs 10
wmc 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Genkgo\TestCamt\Unit;
6
7
use Genkgo\Camt\Camt052;
8
use Genkgo\Camt\Camt053;
9
use Genkgo\Camt\Camt054;
10
use Genkgo\Camt\Config;
11
use Genkgo\Camt\MessageFormatInterface;
12
use PHPUnit\Framework\TestCase;
13
14
/**
15
 * @group config
16
 */
17
class ConfigTest extends TestCase
18
{
19
    public function testDefaultConfigHasMessageFormats(): void
20
    {
21
        $config = Config::getDefault();
22
23
        $messageFormats = $config->getMessageFormats();
24
25
        $expectedMessageFormats = [
26
            Camt052\MessageFormat\V01::class,
27
            Camt052\MessageFormat\V02::class,
28
            Camt052\MessageFormat\V04::class,
29
            Camt052\MessageFormat\V06::class,
30
            Camt053\MessageFormat\V02::class,
31
            Camt053\MessageFormat\V03::class,
32
            Camt053\MessageFormat\V04::class,
33
            Camt054\MessageFormat\V02::class,
34
            Camt054\MessageFormat\V04::class,
35
            Camt054\MessageFormat\V08::class,
36
        ];
37
38
        $actualMessageFormats = array_map(static fn (MessageFormatInterface $messageFormat): string => get_class($messageFormat), $messageFormats);
39
40
        $additionalMessageFormats = array_diff(
41
            $actualMessageFormats,
42
            $expectedMessageFormats
43
        );
44
45
        self::assertEmpty($additionalMessageFormats, sprintf(
46
            <<<TXT
47
Failed asserting that the default configuration does not configure additional message formats.
48
49
Did you intend to add the following message formats?
50
51
- %s
52
53
TXT
54
            ,
55
            implode("\n- ", $additionalMessageFormats)
56
        ));
57
58
        $missingMessageFormats = array_diff(
59
            $expectedMessageFormats,
60
            $actualMessageFormats
61
        );
62
63
        self::assertEmpty($missingMessageFormats, sprintf(
64
            <<<TXT
65
Failed asserting that the default configuration configures all expected formats.
66
67
Have you forgotten to add the following message formats?
68
69
- %s
70
71
TXT
72
            ,
73
            implode("\n- ", $missingMessageFormats)
74
        ));
75
    }
76
77
    public function testDefaultConfigHasXsdValidation(): void
78
    {
79
        $config = Config::getDefault();
80
81
        self::assertTrue($config->getXsdValidation());
82
    }
83
84
    public function testNoValidateConfigHasNoXsdValidation(): void
85
    {
86
        $config = Config::getDefault();
87
        $config->disableXsdValidation();
88
89
        self::assertFalse($config->getXsdValidation());
90
    }
91
}
92