Skip to content

Commit 3ace4fa

Browse files
authored
PHPLIB-624 Sync change stream spec tests for delta oplog entries (#814)
1 parent 52c5c98 commit 3ace4fa

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed

tests/UnifiedSpecTests/UnifiedSpecTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,19 @@ public function provideFailingTests()
178178
return $this->provideTests(__DIR__ . '/valid-fail');
179179
}
180180

181+
/**
182+
* @dataProvider provideChangeStreamsTests
183+
*/
184+
public function testChangeStreams(...$args)
185+
{
186+
$this->doTestCase(...$args);
187+
}
188+
189+
public function provideChangeStreamsTests()
190+
{
191+
return $this->provideTests(__DIR__ . '/change-streams');
192+
}
193+
181194
private function provideTests(string $dir)
182195
{
183196
$testArgs = [];
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
{
2+
"description": "change-streams",
3+
"schemaVersion": "1.0",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0"
8+
}
9+
},
10+
{
11+
"database": {
12+
"id": "database0",
13+
"client": "client0",
14+
"databaseName": "database0"
15+
}
16+
},
17+
{
18+
"collection": {
19+
"id": "collection0",
20+
"database": "database0",
21+
"collectionName": "collection0"
22+
}
23+
}
24+
],
25+
"initialData": [
26+
{
27+
"collectionName": "collection0",
28+
"databaseName": "database0",
29+
"documents": []
30+
}
31+
],
32+
"tests": [
33+
{
34+
"description": "Test array truncation",
35+
"runOnRequirements": [
36+
{
37+
"minServerVersion": "4.7",
38+
"topologies": [
39+
"replicaset"
40+
]
41+
}
42+
],
43+
"operations": [
44+
{
45+
"name": "insertOne",
46+
"object": "collection0",
47+
"arguments": {
48+
"document": {
49+
"_id": 1,
50+
"a": 1,
51+
"array": [
52+
"foo",
53+
{
54+
"a": "bar"
55+
},
56+
1,
57+
2,
58+
3
59+
]
60+
}
61+
}
62+
},
63+
{
64+
"name": "createChangeStream",
65+
"object": "collection0",
66+
"arguments": {
67+
"pipeline": []
68+
},
69+
"saveResultAsEntity": "changeStream0"
70+
},
71+
{
72+
"name": "updateOne",
73+
"object": "collection0",
74+
"arguments": {
75+
"filter": {
76+
"_id": 1
77+
},
78+
"update": [
79+
{
80+
"$set": {
81+
"array": [
82+
"foo",
83+
{
84+
"a": "bar"
85+
}
86+
]
87+
}
88+
}
89+
]
90+
}
91+
},
92+
{
93+
"name": "iterateUntilDocumentOrError",
94+
"object": "changeStream0",
95+
"expectResult": {
96+
"operationType": "update",
97+
"ns": {
98+
"db": "database0",
99+
"coll": "collection0"
100+
},
101+
"updateDescription": {
102+
"updatedFields": {},
103+
"removedFields": [],
104+
"truncatedArrays": [
105+
{
106+
"field": "array",
107+
"newSize": 2
108+
}
109+
]
110+
}
111+
}
112+
}
113+
]
114+
}
115+
]
116+
}

0 commit comments

Comments
 (0)