-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathArrayHasKeyWithTest.yml
More file actions
175 lines (168 loc) · 6.26 KB
/
Copy pathArrayHasKeyWithTest.yml
File metadata and controls
175 lines (168 loc) · 6.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# PHPUnitArrayAssertions - Array-related PHPUnit assertions for API testing.
#
# @copyright Copyright (c) 2021, Daniel Rudolf (<https://www.daniel-rudolf.de>)
#
# This file is copyrighted by the contributors recorded in the version control
# history of the file, available from the following original location:
#
# <https://github.com/PhrozenByte/phpunit-array-asserts/blob/master/tests/data/ArrayHasKeyWithTest.yml>
#
# @license http://opensource.org/licenses/MIT The MIT License
#
# SPDX-License-Identifier: MIT
# License-Filename: LICENSE
~anchors:
paramsKeyTwo: ¶msKeyTwo
key: two
constraint:
~object: PhrozenByte\PHPUnitArrayAsserts\Tests\Utils\TestConstraint
options:
toString: is awesome
matches: false
count: 0
paramsKeyOne: ¶msKeyOne
key: one
constraint:
~object: PhrozenByte\PHPUnitArrayAsserts\Tests\Utils\TestConstraint
options:
toString: is funny
matches: false
count: 1
paramsKeyZero: ¶msKeyZero
key: 0
constraint:
~object: PhrozenByte\PHPUnitArrayAsserts\Tests\Utils\TestConstraint
options:
toString: matches something
matches: false
count: 2
paramsKeyStatic: ¶msKeyStatic
key: item
constraint: static value
constraintMatches: &constraintMatches
constraint: { options: { matches: true } }
testInvalidParameters:
- key:
- "this is no valid key"
constraint:
~object: PhrozenByte\PHPUnitArrayAsserts\Tests\Utils\TestConstraint
expectedException: PHPUnit\Framework\InvalidArgumentException
expectedExceptionMessage: >-
Argument #1 of PhrozenByte\PHPUnitArrayAsserts\Constraint\ArrayHasKeyWith::__construct()
must be an integer or string
testSelfDescribing:
- <<: *paramsKeyTwo
expectedDescription: is an array that has the key 'two' whose value is awesome
- <<: *paramsKeyOne
expectedDescription: is an array that has the key 'one' whose value is funny
- <<: *paramsKeyZero
expectedDescription: is an array that has the key 0 whose value matches something
- <<: *paramsKeyStatic
expectedDescription: is an array that has the key 'item' whose value is equal to 'static value'
testEvaluate:
- <<: *paramsKeyTwo
<<<: *constraintMatches
other:
two: [ 1, 2, 3 ]
one: [ 4, 5, 6 ]
0: [ 7, 8, 9 ]
expectedEvaluationValue: [ 1, 2, 3 ]
- <<: *paramsKeyOne
<<<: *constraintMatches
other:
~object: PhrozenByte\PHPUnitArrayAsserts\Tests\Utils\ArrayAccessible
data:
two: ~
one: [ "baz" ]
0: [ "foo", "bar" ]
expectedEvaluationValue: [ "baz" ]
- <<: *paramsKeyZero
<<<: *constraintMatches
other:
~object: PhrozenByte\PHPUnitArrayAsserts\Tests\Utils\ArrayAccessible
data: [ 1, 2, 3 ]
expectedEvaluationValue: 1
- <<: *paramsKeyStatic
other:
item: static value
other: 42
expectedEvaluationValue: static value
- key: 789
constraint:
~object: PhrozenByte\PHPUnitArrayAsserts\Tests\Utils\TestConstraint
options:
toString: matches something else
matches: true
other:
123: [ "foo", "bar" ]
456: [ "baz" ]
789: ~
expectedEvaluationValue: ~
testEvaluateFail:
- <<: *paramsKeyTwo
other: { "two": 1, "one": 2, 0: 3 }
expectedEvaluationValue: 1
expectedExceptionMessage: |-
Failed asserting that %s is an array that has the key 'two' whose value is awesome.
- <<: *paramsKeyZero
other:
~object: PhrozenByte\PHPUnitArrayAsserts\Tests\Utils\ArrayAccessible
data:
two: ~
one: [ "baz" ]
0: [ "foo", "bar" ]
expectedEvaluationValue: [ "foo", "bar" ]
expectedExceptionMessage: |-
Failed asserting that %s is an array that has the key 0 whose value matches something.
testPreEvaluateFail:
- <<: *paramsKeyTwo
other: {}
expectedExceptionMessage: |-
Failed asserting that %s is an array that has the key 'two' whose value is awesome.
- <<: *paramsKeyOne
other:
~object: PhrozenByte\PHPUnitArrayAsserts\Tests\Utils\ArrayAccessible
expectedExceptionMessage: |-
Failed asserting that %s is an array that has the key 'one' whose value is funny.
- <<: *paramsKeyZero
other: ~
expectedExceptionMessage: |-
Failed asserting that %s is an array that has the key 0 whose value matches something.
- <<: *paramsKeyStatic
other:
item: other value
other: 42
expectedExceptionMessage: |-
Failed asserting that %s is an array that has the key 'item' whose value is equal to 'static value'.
- key: non-existing
constraint:
~object: PhrozenByte\PHPUnitArrayAsserts\Tests\Utils\TestConstraint
options:
toString: is test data
matches: false
other: [ 1, 2, 3 ]
expectedExceptionMessage: |-
Failed asserting that %s is an array that has the key 'non-existing' whose value is test data.
- key: -1
constraint:
~object: PhrozenByte\PHPUnitArrayAsserts\Tests\Utils\TestConstraint
options:
toString: matches something else
matches: false
other:
~object: PhrozenByte\PHPUnitArrayAsserts\Tests\Utils\ArrayAccessible
data:
123: [ "foo", "bar" ]
456: [ "baz" ]
789: ~
expectedExceptionMessage: |-
Failed asserting that %s is an array that has the key -1 whose value matches something else.
testCountable:
- <<: *paramsKeyTwo
expectedCount: 1
- <<: *paramsKeyOne
expectedCount: 2
- <<: *paramsKeyZero
expectedCount: 3
- <<: *paramsKeyStatic
expectedCount: 2