Completed
Push — dependabot/github_actions/acti... ( 224e90...b9dbf4 )
by
unknown
205:16 queued 195:17
created

ApiSpecificationTest::visibilityProvider()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 59

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 59
rs 8.8945
c 0
b 0
f 0

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 phpDocumentor\Configuration;
6
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * @coversDefaultClass \phpDocumentor\Configuration\ApiSpecification
11
 */
12
final class ApiSpecificationTest extends TestCase
13
{
14
    /**
15
     * @dataProvider visibilityProvider
16
     * @covers ::offsetSet
17
     * @covers ::isVisibilityAllowed
18
     */
19
    public function testVisibility(array $settings, array $expected)
20
    {
21
        $apiSpec = ApiSpecification::createDefault();
22
        $apiSpec['visibility'] = $settings;
23
24
        foreach ($expected as $visiblity => $result) {
25
            self::assertSame($result, $apiSpec->isVisibilityAllowed($visiblity));
26
        }
27
    }
28
29
    /**
30
     * @return array<array<string[], int>>
0 ignored issues
show
Documentation introduced by
The doc-type array<array<string[], could not be parsed: Expected ">" at position 9, but found "end of type". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
31
     */
32
    public function visibilityProvider() : array
33
    {
34
        return [
35
            [
36
                'settings' => ['public'],
37
                'expected' => [
38
                    ApiSpecification::VISIBILITY_PUBLIC => true,
39
                    ApiSpecification::VISIBILITY_PROTECTED => false,
40
                    ApiSpecification::VISIBILITY_PRIVATE => false,
41
                    ApiSpecification::VISIBILITY_INTERNAL => false,
42
                ],
43
            ],
44
            [
45
                'settings' => ['protected'],
46
                'expected' => [
47
                    ApiSpecification::VISIBILITY_PUBLIC => false,
48
                    ApiSpecification::VISIBILITY_PROTECTED => true,
49
                    ApiSpecification::VISIBILITY_PRIVATE => false,
50
                    ApiSpecification::VISIBILITY_INTERNAL => false,
51
                ],
52
            ],
53
            [
54
                'settings' => ['private'],
55
                'expected' => [
56
                    ApiSpecification::VISIBILITY_PUBLIC => false,
57
                    ApiSpecification::VISIBILITY_PROTECTED => false,
58
                    ApiSpecification::VISIBILITY_PRIVATE => true,
59
                    ApiSpecification::VISIBILITY_INTERNAL => false,
60
                ],
61
            ],
62
            [
63
                'settings' => ['public', 'private'],
64
                'expected' => [
65
                    ApiSpecification::VISIBILITY_PUBLIC => true,
66
                    ApiSpecification::VISIBILITY_PROTECTED => false,
67
                    ApiSpecification::VISIBILITY_PRIVATE => true,
68
                    ApiSpecification::VISIBILITY_INTERNAL => false,
69
                ],
70
            ],
71
            [
72
                'settings' => ['public', 'internal'],
73
                'expected' => [
74
                    ApiSpecification::VISIBILITY_PUBLIC => true,
75
                    ApiSpecification::VISIBILITY_PROTECTED => false,
76
                    ApiSpecification::VISIBILITY_PRIVATE => false,
77
                    ApiSpecification::VISIBILITY_INTERNAL => true,
78
                ],
79
            ],
80
            [
81
                'settings' => ['internal'],
82
                'expected' => [
83
                    ApiSpecification::VISIBILITY_PUBLIC => true,
84
                    ApiSpecification::VISIBILITY_PROTECTED => true,
85
                    ApiSpecification::VISIBILITY_PRIVATE => true,
86
                    ApiSpecification::VISIBILITY_INTERNAL => true,
87
                ],
88
            ],
89
        ];
90
    }
91
}
92