GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 53bcfa...6873de )
by SignpostMarv
03:59
created

dataProviderClassDoesNotImplementClassException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
* @author SignpostMarv
4
*/
5
declare(strict_types=1);
6
7
namespace SignpostMarv\DaftObject\Tests;
8
9
use SignpostMarv\DaftObject\ClassDoesNotImplementClassException;
10
use SignpostMarv\DaftObject\DaftJson;
11
use SignpostMarv\DaftObject\PropertyNotJsonDecodableException;
12
use SignpostMarv\DaftObject\PropertyNotJsonDecodableShouldBeArrayException;
13
use SignpostMarv\DaftObject\PropertyNotNullableException;
14
use SignpostMarv\DaftObject\ReadWriteJson;
15
use SignpostMarv\DaftObject\ReadWriteJsonJson;
16
use SignpostMarv\DaftObject\ReadWriteJsonJsonArray;
17
use SignpostMarv\DaftObject\ReadWriteJsonJsonArrayBad;
18
19
class DaftJsonExceptionTest extends TestCase
20
{
21
    public function dataProviderClassDoesNotImplementClassException() : array
22
    {
23
        return [
24
            [
25
                ReadWriteJsonJsonArrayBad::class,
26
                'stdClass',
27
                [
28
                    'json' => [
29
                        [
30
                            'Foo' => 'Foo',
31
                            'Bar' => 1.0,
32
                            'Baz' => 2,
33
                            'Bat' => true,
34
                        ],
35
                    ],
36
                ],
37
                true,
38
            ],
39
        ];
40
    }
41
42
    public function dataProviderPropertyNotThingableException() : array
43
    {
44
        return [
45
            [
46
                ReadWriteJsonJsonArrayBad::class,
47
                ReadWriteJsonJsonArrayBad::class,
48
                'json',
49
                PropertyNotNullableException::class,
50
                'nullable',
51
                [
52
                    'json' => null,
53
                ],
54
                true,
55
            ],
56
            [
57
                ReadWriteJsonJsonArray::class,
58
                ReadWriteJsonJsonArray::class,
59
                'notthere',
60
                PropertyNotJsonDecodableException::class,
61
                'json-decodable',
62
                [
63
                    'json' => [],
64
                    'notthere' => 1,
65
                ],
66
                true,
67
            ],
68
            [
69
                ReadWriteJsonJsonArray::class,
70
                ReadWriteJsonJsonArray::class,
71
                'json',
72
                PropertyNotJsonDecodableShouldBeArrayException::class,
73
                'json-decodable (should be an array)',
74
                [
75
                    'json' => 1,
76
                ],
77
                true,
78
            ],
79
            [
80
                ReadWriteJsonJson::class,
81
                ReadWriteJson::class,
82
                'json',
83
                PropertyNotJsonDecodableShouldBeArrayException::class,
84
                'json-decodable (should be an array)',
85
                [
86
                    'json' => 1,
87
                ],
88
                true,
89
            ],
90
            [
91
                ReadWriteJsonJsonArray::class,
92
                ReadWriteJson::class,
93
                'json',
94
                PropertyNotJsonDecodableShouldBeArrayException::class,
95
                'json-decodable (should be an array)',
96
                [
97
                    'json' => [
98
                        1,
99
                    ],
100
                ],
101
                true,
102
            ],
103
        ];
104
    }
105
106
    /**
107
    * @dataProvider dataProviderClassDoesNotImplementClassException
108
    */
109
    public function testClassDoesNotImplementClassException(
110
        string $implementation,
111
        string $expectingFailureWith,
112
        array $args,
113
        bool $writeAll
114
    ) : void {
115
        $this->expectException(ClassDoesNotImplementClassException::class);
116
        $this->expectExceptionMessage(
117
            sprintf(
118
                '%s does not implement %s',
119
                $expectingFailureWith,
120
                DaftJson::class
121
            )
122
        );
123
124
        $implementation::DaftObjectFromJsonArray($args, $writeAll);
125
    }
126
127
    /**
128
    * @dataProvider dataProviderPropertyNotThingableException
129
    */
130
    public function testPropertyNotThingableException(
131
        string $implementation,
132
        string $expectingFailureWithClass,
133
        string $expectingFailureWithProperty,
134
        string $expectingException,
135
        string $expectingThing,
136
        array $args,
137
        bool $writeAll
138
    ) : void {
139
        $this->expectException($expectingException);
140
        $this->expectExceptionMessage(
141
            sprintf(
142
                'Property not %s: %s::$%s',
143
                $expectingThing,
144
                $expectingFailureWithClass,
145
                $expectingFailureWithProperty
146
            )
147
        );
148
149
        $obj = $implementation::DaftObjectFromJsonArray($args, $writeAll);
150
151
        foreach ($implementation::DaftObjectPublicGetters() as $arg) {
152
            $obj->$arg;
153
        }
154
    }
155
}
156