Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
5310c62b
Commit
5310c62b
authored
Jan 29, 2018
by
Katherine Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-306: Set GridFS uploadDate at completion time
parent
d3a3c4e8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
7 deletions
+30
-7
WritableStream.php
src/GridFS/WritableStream.php
+1
-1
StreamWrapperFunctionalTest.php
tests/GridFS/StreamWrapperFunctionalTest.php
+29
-6
No files found.
src/GridFS/WritableStream.php
View file @
5310c62b
...
...
@@ -101,7 +101,6 @@ class WritableStream
'_id'
=>
$options
[
'_id'
],
'chunkSize'
=>
$this
->
chunkSize
,
'filename'
=>
(
string
)
$filename
,
'uploadDate'
=>
new
UTCDateTime
,
]
+
array_intersect_key
(
$options
,
[
'aliases'
=>
1
,
'contentType'
=>
1
,
'metadata'
=>
1
]);
}
...
...
@@ -223,6 +222,7 @@ class WritableStream
$this
->
file
[
'length'
]
=
$this
->
length
;
$this
->
file
[
'md5'
]
=
$md5
;
$this
->
file
[
'uploadDate'
]
=
new
UTCDateTime
;
try
{
$this
->
collectionWrapper
->
insertFile
(
$this
->
file
);
...
...
tests/GridFS/StreamWrapperFunctionalTest.php
View file @
5310c62b
...
...
@@ -3,6 +3,7 @@
namespace
MongoDB\Tests\GridFS
;
use
MongoDB\BSON\Binary
;
use
MongoDB\BSON\ObjectId
;
use
MongoDB\BSON\UTCDateTime
;
/**
...
...
@@ -147,9 +148,8 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
$this
->
assertSame
(
-
1
,
fseek
(
$stream
,
1
,
\SEEK_END
));
}
public
function
testWritableStreamStat
()
public
function
testWritableStreamStat
BeforeSaving
()
{
$currentTimestamp
=
time
();
$stream
=
$this
->
bucket
->
openUploadStream
(
'filename'
,
[
'chunkSizeBytes'
=>
1024
]);
$stat
=
fstat
(
$stream
);
...
...
@@ -157,10 +157,10 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
$this
->
assertSame
(
0100222
,
$stat
[
'mode'
]);
$this
->
assertSame
(
0
,
$stat
[
7
]);
$this
->
assertSame
(
0
,
$stat
[
'size'
]);
$this
->
assertGreaterThanOrEqual
(
$currentTimestamp
,
$stat
[
9
]);
$this
->
assertGreaterThanOrEqual
(
$currentTimestamp
,
$stat
[
'mtime'
]);
$this
->
assertGreaterThanOrEqual
(
$currentTimestamp
,
$stat
[
10
]);
$this
->
assertGreaterThanOrEqual
(
$currentTimestamp
,
$stat
[
'ctime'
]);
$this
->
assertGreaterThanOrEqual
(
0
,
$stat
[
9
]);
$this
->
assertGreaterThanOrEqual
(
0
,
$stat
[
'mtime'
]);
$this
->
assertGreaterThanOrEqual
(
0
,
$stat
[
10
]);
$this
->
assertGreaterThanOrEqual
(
0
,
$stat
[
'ctime'
]);
$this
->
assertSame
(
1024
,
$stat
[
11
]);
$this
->
assertSame
(
1024
,
$stat
[
'blksize'
]);
...
...
@@ -171,6 +171,29 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
$this
->
assertSame
(
6
,
$stat
[
'size'
]);
}
public
function
testWritableStreamStatAfterSaving
()
{
$id
=
new
ObjectId
;
$stream
=
$this
->
bucket
->
openUploadStream
(
'filename'
,
[
'chunkSizeBytes'
=>
1024
,
'_id'
=>
$id
]);
$this
->
assertSame
(
6
,
fwrite
(
$stream
,
'foobar'
));
$this
->
assertTrue
(
fclose
(
$stream
));
$currentTimestamp
=
time
();
$stream
=
$this
->
bucket
->
openDownloadStream
(
$id
);
$stat
=
fstat
(
$stream
);
$this
->
assertSame
(
0100444
,
$stat
[
2
]);
$this
->
assertSame
(
0100444
,
$stat
[
'mode'
]);
$this
->
assertSame
(
6
,
$stat
[
7
]);
$this
->
assertSame
(
6
,
$stat
[
'size'
]);
$this
->
assertGreaterThanOrEqual
(
$currentTimestamp
,
$stat
[
9
]);
$this
->
assertGreaterThanOrEqual
(
$currentTimestamp
,
$stat
[
'mtime'
]);
$this
->
assertGreaterThanOrEqual
(
$currentTimestamp
,
$stat
[
10
]);
$this
->
assertGreaterThanOrEqual
(
$currentTimestamp
,
$stat
[
'ctime'
]);
$this
->
assertSame
(
1024
,
$stat
[
11
]);
$this
->
assertSame
(
1024
,
$stat
[
'blksize'
]);
}
public
function
testWritableStreamWrite
()
{
$stream
=
$this
->
bucket
->
openUploadStream
(
'filename'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment