Completed
Push — master ( 96d946...590739 )
by Adrien
31s queued 14s
created

ConfigTest::testDefaultConfigHasMessageFormats()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 56
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 31
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 56
rs 9.424

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
        ];
36
37
        $actualMessageFormats = array_map(static function (MessageFormatInterface $messageFormat): string {
38
            return get_class($messageFormat);
39
        }, $messageFormats);
40
41
        $additionalMessageFormats = array_diff(
42
            $actualMessageFormats,
43
            $expectedMessageFormats
44
        );
45
46
        self::assertEmpty($additionalMessageFormats, sprintf(
47
            <<<TXT
48
Failed asserting that the default configuration does not configure additional message formats.
49
50
Did you intend to add the following message formats?
51
52
- %s
53
54
TXT
55
            ,
56
            implode("\n- ", $additionalMessageFormats)
57
        ));
58
59
        $missingMessageFormats = array_diff(
60
            $expectedMessageFormats,
61
            $actualMessageFormats
62
        );
63
64
        self::assertEmpty($missingMessageFormats, sprintf(
65
            <<<TXT
66
Failed asserting that the default configuration configures all expected formats.
67
68
Have you forgotten to add the following message formats?
69
70
- %s
71
72
TXT
73
            ,
74
            implode("\n- ", $missingMessageFormats)
75
        ));
76
    }
77
78
    public function testDefaultConfigHasXsdValidation(): void
79
    {
80
        $config = Config::getDefault();
81
82
        self::assertTrue($config->getXsdValidation());
83
    }
84
85
    public function testNoValidateConfigHasNoXsdValidation(): void
86
    {
87
        $config = Config::getDefault();
88
        $config->disableXsdValidation();
89
90
        self::assertFalse($config->getXsdValidation());
91
    }
92
}
93