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
ddd2c3e2
Commit
ddd2c3e2
authored
Jan 12, 2017
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-251: WriteableStream::getSize() should include buffer length
parent
bc98d9cc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
WritableStream.php
src/GridFS/WritableStream.php
+1
-1
StreamWrapperFunctionalTest.php
tests/GridFS/StreamWrapperFunctionalTest.php
+10
-0
WritableStreamFunctionalTest.php
tests/GridFS/WritableStreamFunctionalTest.php
+16
-0
No files found.
src/GridFS/WritableStream.php
View file @
ddd2c3e2
...
@@ -158,7 +158,7 @@ class WritableStream
...
@@ -158,7 +158,7 @@ class WritableStream
*/
*/
public
function
getSize
()
public
function
getSize
()
{
{
return
$this
->
length
;
return
$this
->
length
+
strlen
(
$this
->
buffer
)
;
}
}
/**
/**
...
...
tests/GridFS/StreamWrapperFunctionalTest.php
View file @
ddd2c3e2
...
@@ -56,6 +56,8 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
...
@@ -56,6 +56,8 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
$stat
=
fstat
(
$stream
);
$stat
=
fstat
(
$stream
);
$this
->
assertSame
(
0100444
,
$stat
[
2
]);
$this
->
assertSame
(
0100444
,
$stat
[
2
]);
$this
->
assertSame
(
0100444
,
$stat
[
'mode'
]);
$this
->
assertSame
(
0100444
,
$stat
[
'mode'
]);
$this
->
assertSame
(
10
,
$stat
[
7
]);
$this
->
assertSame
(
10
,
$stat
[
'size'
]);
}
}
public
function
testReadableStreamWrite
()
public
function
testReadableStreamWrite
()
...
@@ -100,6 +102,14 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
...
@@ -100,6 +102,14 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
$stat
=
fstat
(
$stream
);
$stat
=
fstat
(
$stream
);
$this
->
assertSame
(
0100222
,
$stat
[
2
]);
$this
->
assertSame
(
0100222
,
$stat
[
2
]);
$this
->
assertSame
(
0100222
,
$stat
[
'mode'
]);
$this
->
assertSame
(
0100222
,
$stat
[
'mode'
]);
$this
->
assertSame
(
0
,
$stat
[
7
]);
$this
->
assertSame
(
0
,
$stat
[
'size'
]);
$this
->
assertSame
(
6
,
fwrite
(
$stream
,
'foobar'
));
$stat
=
fstat
(
$stream
);
$this
->
assertSame
(
6
,
$stat
[
7
]);
$this
->
assertSame
(
6
,
$stat
[
'size'
]);
}
}
public
function
testWritableStreamWrite
()
public
function
testWritableStreamWrite
()
...
...
tests/GridFS/WritableStreamFunctionalTest.php
View file @
ddd2c3e2
...
@@ -61,6 +61,22 @@ class WritableStreamFunctionalTest extends FunctionalTestCase
...
@@ -61,6 +61,22 @@ class WritableStreamFunctionalTest extends FunctionalTestCase
new
WritableStream
(
$this
->
collectionWrapper
,
'filename'
,
[
'chunkSizeBytes'
=>
0
]);
new
WritableStream
(
$this
->
collectionWrapper
,
'filename'
,
[
'chunkSizeBytes'
=>
0
]);
}
}
public
function
testWriteBytesAlwaysUpdatesFileSize
()
{
$stream
=
new
WritableStream
(
$this
->
collectionWrapper
,
'filename'
,
[
'chunkSizeBytes'
=>
1024
]);
$this
->
assertSame
(
0
,
$stream
->
getSize
());
$this
->
assertSame
(
512
,
$stream
->
writeBytes
(
str_repeat
(
'a'
,
512
)));
$this
->
assertSame
(
512
,
$stream
->
getSize
());
$this
->
assertSame
(
512
,
$stream
->
writeBytes
(
str_repeat
(
'a'
,
512
)));
$this
->
assertSame
(
1024
,
$stream
->
getSize
());
$this
->
assertSame
(
512
,
$stream
->
writeBytes
(
str_repeat
(
'a'
,
512
)));
$this
->
assertSame
(
1536
,
$stream
->
getSize
());
$stream
->
close
();
$this
->
assertSame
(
1536
,
$stream
->
getSize
());
}
/**
/**
* @dataProvider provideInputDataAndExpectedMD5
* @dataProvider provideInputDataAndExpectedMD5
*/
*/
...
...
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