33namespace MongoDB \Tests \GridFS ;
44
55use MongoDB \BSON \Binary ;
6+ use MongoDB \BSON \UTCDateTime ;
67
78/**
89 * Functional tests for the internal StreamWrapper class.
@@ -14,7 +15,7 @@ public function setUp()
1415 parent ::setUp ();
1516
1617 $ this ->filesCollection ->insertMany ([
17- ['_id ' => 'length-10 ' , 'length ' => 10 , 'chunkSize ' => 4 ],
18+ ['_id ' => 'length-10 ' , 'length ' => 10 , 'chunkSize ' => 4 , ' uploadDate ' => new UTCDateTime ( ' 1484202200000 ' ) ],
1819 ]);
1920
2021 $ this ->chunksCollection ->insertMany ([
@@ -58,6 +59,10 @@ public function testReadableStreamStat()
5859 $ this ->assertSame (0100444 , $ stat ['mode ' ]);
5960 $ this ->assertSame (10 , $ stat [7 ]);
6061 $ 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 ' ]);
6166 $ this ->assertSame (4 , $ stat [11 ]);
6267 $ this ->assertSame (4 , $ stat ['blksize ' ]);
6368 }
@@ -99,13 +104,18 @@ public function testWritableStreamRead()
99104
100105 public function testWritableStreamStat ()
101106 {
107+ $ currentTimestamp = time ();
102108 $ stream = $ this ->bucket ->openUploadStream ('filename ' , ['chunkSizeBytes ' => 1024 ]);
103109
104110 $ stat = fstat ($ stream );
105111 $ this ->assertSame (0100222 , $ stat [2 ]);
106112 $ this ->assertSame (0100222 , $ stat ['mode ' ]);
107113 $ this ->assertSame (0 , $ stat [7 ]);
108114 $ 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 ' ]);
109119 $ this ->assertSame (1024 , $ stat [11 ]);
110120 $ this ->assertSame (1024 , $ stat ['blksize ' ]);
111121
0 commit comments