Skip to content

Commit cce37e7

Browse files
committed
Test stable rearrange
1 parent bea50fb commit cce37e7

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

tests/src/RearrangeArrayTest.php

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,54 @@ public function testRearrangeArray()
128128
$this->assertSame($expectedJson, json_encode($m->getRearranged(), JSON_PRETTY_PRINT));
129129
}
130130

131-
public function testRearrangeNoUnique()
131+
function testRearrangeKeepOriginal()
132132
{
133+
$old = json_decode('[
134+
{
135+
"type": "string",
136+
"name": "qp1",
137+
"in": "query"
138+
},
139+
{
140+
"type": "string",
141+
"name": "qp",
142+
"in": "query"
143+
},
144+
{
145+
"name": "body",
146+
"in": "body",
147+
"schema": {
148+
"$ref": "#/definitions/UsecaseSampleInput"
149+
},
150+
"required": true
151+
}
152+
]');
133153

134-
}
154+
$new = json_decode('[
155+
{
156+
"type": "string",
157+
"name": "qp1",
158+
"in": "query"
159+
},
160+
{
161+
"type": "string",
162+
"name": "qp2",
163+
"in": "query"
164+
},
165+
{
166+
"name": "body",
167+
"in": "body",
168+
"schema": {
169+
"$ref": "#/definitions/UsecaseSampleInput"
170+
},
171+
"required": true
172+
}
173+
]');
135174

175+
$m = new JsonDiff($old, $new, JsonDiff::REARRANGE_ARRAYS);
176+
$this->assertSame(
177+
json_encode($new, JSON_PRETTY_PRINT),
178+
json_encode($m->getRearranged(), JSON_PRETTY_PRINT)
179+
);
180+
}
136181
}

0 commit comments

Comments
 (0)