3
3
namespace MongoDB \Tests \GridFS ;
4
4
5
5
use MongoDB \Collection ;
6
+ use MongoDB \Driver \Command ;
6
7
use MongoDB \GridFS \Bucket ;
7
8
use MongoDB \Tests \FunctionalTestCase as BaseFunctionalTestCase ;
8
9
@@ -28,10 +29,28 @@ public function setUp(): void
28
29
parent ::setUp ();
29
30
30
31
$ this ->bucket = new Bucket ($ this ->manager , $ this ->getDatabaseName ());
31
- $ this ->bucket ->drop ();
32
32
33
- $ this ->chunksCollection = $ this ->createCollection ($ this ->getDatabaseName (), 'fs.chunks ' );
34
- $ this ->filesCollection = $ this ->createCollection ($ this ->getDatabaseName (), 'fs.files ' );
33
+ $ this ->chunksCollection = new Collection ($ this ->manager , $ this ->getDatabaseName (), 'fs.chunks ' );
34
+ $ this ->filesCollection = new Collection ($ this ->manager , $ this ->getDatabaseName (), 'fs.files ' );
35
+ $ this ->chunksCollection ->deleteMany ([]);
36
+ $ this ->filesCollection ->deleteMany ([]);
37
+ }
38
+
39
+ public function tearDown (): void
40
+ {
41
+ $ this ->chunksCollection ->deleteMany ([]);
42
+ $ this ->filesCollection ->deleteMany ([]);
43
+
44
+ parent ::tearDown ();
45
+ }
46
+
47
+ public static function tearDownAfterClass (): void
48
+ {
49
+ $ manager = static ::createTestManager ();
50
+ $ manager ->executeCommand (self ::getDatabaseName (), new Command (['drop ' => 'fs.chunks ' ]));
51
+ $ manager ->executeCommand (self ::getDatabaseName (), new Command (['drop ' => 'fs.files ' ]));
52
+
53
+ parent ::tearDownAfterClass ();
35
54
}
36
55
37
56
/**
0 commit comments