@@ -75,12 +75,12 @@ public function testSpecificationTests($testJson)
75
75
$ test ['assert ' ]['result ' ] = $ result ;
76
76
}
77
77
if ($ testResult == "void " ) {
78
- $ test [ ' assert ' ] ['result ' ] = null ;
78
+ $ fixedAssert ['result ' ] = null ;
79
79
}
80
80
$ this ->assertEquals ($ result , $ fixedAssert ['result ' ]);
81
81
}
82
82
if (isset ($ test ['assert ' ]['data ' ])) {
83
- $ this ->runCommands ($ fixedAssert , $ result );
83
+ $ this ->runCommands ($ fixedAssert[ ' data ' ] , $ result );
84
84
$ this ->collectionsEqual ($ this ->collections ['expected.files ' ],$ this ->bucket ->getFilesCollection ());
85
85
if (isset ($ this ->collections ['expected.chunks ' ])) {
86
86
$ this ->collectionsEqual ($ this ->collections ['expected.chunks ' ],$ this ->bucket ->getChunksCollection ());
@@ -91,7 +91,7 @@ public function testSpecificationTests($testJson)
91
91
92
92
public function provideSpecificationTests ()
93
93
{
94
- $ testPath =getcwd ().'/tests/GridFS/Specification/tests/download .json ' ;
94
+ $ testPath =getcwd ().'/tests/GridFS/Specification/tests/delete .json ' ;
95
95
96
96
$ testArgs = [];
97
97
foreach (glob ($ testPath ) as $ filename ) {
@@ -148,29 +148,30 @@ public function filterDoc($collection, $ignoreId)
148
148
149
149
public function runCommands ($ cmds , $ result )
150
150
{
151
- $ cmds = $ this ->fixTypes ($ cmds , true );
152
- foreach ($ cmds as $ cmd ) {
151
+ foreach ($ cmds as $ cmd ){
153
152
foreach ($ cmd as $ key => $ value ) {
154
153
if (isset ($ this ->commands [$ key ])) {
155
154
$ cmdName = $ key ;
156
155
$ collectionName = $ value ;
157
-
158
- foreach ($ cmd ['documents ' ] as $ docIndex => $ doc ) {
159
- foreach ($ doc as $ docKey => $ docVal ){
160
- if (is_string ($ docVal )) {
161
- if ($ docVal == '*result ' ) {
162
- $ doc [$ docKey ] = $ result ;
156
+ if (isset ($ cmd ['documents ' ])){
157
+ foreach ($ cmd ['documents ' ] as $ docIndex => $ doc ) {
158
+ foreach ($ doc as $ docKey => $ docVal ){
159
+ if (is_string ($ docVal )) {
160
+ if ($ docVal == '*result ' ) {
161
+ $ doc [$ docKey ] = $ result ;
162
+ }
163
163
}
164
164
}
165
+ $ cmd ['documents ' ][$ docIndex ] = $ doc ;
165
166
}
166
- $ cmd ['documents ' ][$ docIndex ] = $ doc ;
167
167
}
168
168
$ collection = new Collection ($ this ->manager , sprintf ("%s.%s " , $ this ->getDatabaseName (), $ collectionName ));
169
169
$ this ->commands [$ key ]($ collection , $ this ->fixTypes ($ cmd , true ));
170
170
$ this ->collections [$ collectionName ] = $ collection ;
171
171
}
172
172
}
173
173
}
174
+
174
175
}
175
176
176
177
public function initializeDatabases ($ data , $ test )
@@ -186,12 +187,15 @@ public function initializeDatabases($data, $test)
186
187
$ filesCollection ->insertMany ($ data ['files ' ]);
187
188
$ expectedFilesCollection = new Collection ($ this ->manager , sprintf ("%s.%s " , $ this ->getDatabaseName (), "expected.files " ));
188
189
$ expectedFilesCollection ->insertMany ($ data ['files ' ]);
190
+ $ this ->collections ['expected.files ' ] = $ expectedFilesCollection ;
189
191
}
190
192
if (isset ($ data ['chunks ' ]) && count ($ data ['chunks ' ]) > 0 ) {
191
193
$ chunksCollection = new Collection ($ this ->manager , sprintf ("%s.%s " , $ this ->getDatabaseName (), "fs.chunks " ));
192
194
$ chunksCollection ->insertMany ($ data ['chunks ' ]);
193
195
$ expectedChunksCollection = new Collection ($ this ->manager , sprintf ("%s.%s " , $ this ->getDatabaseName (), "expected.chunks " ));
194
196
$ expectedChunksCollection ->insertMany ($ data ['chunks ' ]);
197
+ $ this ->collections ['expected.chunks ' ] = $ expectedChunksCollection ;
198
+
195
199
}
196
200
if (isset ($ test ['arrange ' ])) {
197
201
foreach ($ test ['arrange ' ]['data ' ] as $ cmd ) {
@@ -203,9 +207,7 @@ public function initializeDatabases($data, $test)
203
207
}
204
208
}
205
209
}
206
-
207
210
}
208
-
209
211
public function uploadCommand ($ args )
210
212
{
211
213
$ args = $ this ->fixTypes ($ args , false );
@@ -230,7 +232,8 @@ function downloadCommand($args)
230
232
}
231
233
function deleteCommand ($ args )
232
234
{
233
-
235
+ $ args = $ this ->fixTypes ($ args , false );
236
+ $ this ->bucketReadWriter ->delete ($ args ['id ' ]);
234
237
}
235
238
function download_by_nameCommand ($ args )
236
239
{
0 commit comments