3
3
namespace MongoDB \Tests \GridFS ;
4
4
5
5
use MongoDB \BSON \Binary ;
6
+ use MongoDB \BSON \UTCDateTime ;
6
7
7
8
/**
8
9
* Functional tests for the internal StreamWrapper class.
@@ -14,7 +15,7 @@ public function setUp()
14
15
parent ::setUp ();
15
16
16
17
$ this ->filesCollection ->insertMany ([
17
- ['_id ' => 'length-10 ' , 'length ' => 10 , 'chunkSize ' => 4 ],
18
+ ['_id ' => 'length-10 ' , 'length ' => 10 , 'chunkSize ' => 4 , ' uploadDate ' => new UTCDateTime ( ' 1484202200000 ' ) ],
18
19
]);
19
20
20
21
$ this ->chunksCollection ->insertMany ([
@@ -58,6 +59,10 @@ public function testReadableStreamStat()
58
59
$ this ->assertSame (0100444 , $ stat ['mode ' ]);
59
60
$ this ->assertSame (10 , $ stat [7 ]);
60
61
$ this ->assertSame (10 , $ stat ['size ' ]);
62
+ $ this ->assertSame (1484202200 , $ stat [9 ]);
63
+ $ this ->assertSame (1484202200 , $ stat ['mtime ' ]);
64
+ $ this ->assertSame (1484202200 , $ stat [10 ]);
65
+ $ this ->assertSame (1484202200 , $ stat ['ctime ' ]);
61
66
$ this ->assertSame (4 , $ stat [11 ]);
62
67
$ this ->assertSame (4 , $ stat ['blksize ' ]);
63
68
}
@@ -99,13 +104,18 @@ public function testWritableStreamRead()
99
104
100
105
public function testWritableStreamStat ()
101
106
{
107
+ $ currentTimestamp = time ();
102
108
$ stream = $ this ->bucket ->openUploadStream ('filename ' , ['chunkSizeBytes ' => 1024 ]);
103
109
104
110
$ stat = fstat ($ stream );
105
111
$ this ->assertSame (0100222 , $ stat [2 ]);
106
112
$ this ->assertSame (0100222 , $ stat ['mode ' ]);
107
113
$ this ->assertSame (0 , $ stat [7 ]);
108
114
$ this ->assertSame (0 , $ stat ['size ' ]);
115
+ $ this ->assertGreaterThanOrEqual ($ currentTimestamp , $ stat [9 ]);
116
+ $ this ->assertGreaterThanOrEqual ($ currentTimestamp , $ stat ['mtime ' ]);
117
+ $ this ->assertGreaterThanOrEqual ($ currentTimestamp , $ stat [10 ]);
118
+ $ this ->assertGreaterThanOrEqual ($ currentTimestamp , $ stat ['ctime ' ]);
109
119
$ this ->assertSame (1024 , $ stat [11 ]);
110
120
$ this ->assertSame (1024 , $ stat ['blksize ' ]);
111
121
0 commit comments