Unverified Commit 9b925197 authored by Katherine Walker's avatar Katherine Walker Committed by GitHub

Merge pull request #463

parents 838436ca ea98b3a1
......@@ -102,7 +102,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]);
}
......@@ -224,6 +223,7 @@ class WritableStream
$this->file['length'] = $this->length;
$this->file['md5'] = $md5;
$this->file['uploadDate'] = new UTCDateTime;
try {
$this->collectionWrapper->insertFile($this->file);
......
......@@ -147,9 +147,8 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
$this->assertSame(-1, fseek($stream, 1, \SEEK_END));
}
public function testWritableStreamStat()
public function testWritableStreamStatBeforeSaving()
{
$currentTimestamp = time();
$stream = $this->bucket->openUploadStream('filename', ['chunkSizeBytes' => 1024]);
$stat = fstat($stream);
......@@ -157,10 +156,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->assertSame(0, $stat[9]);
$this->assertSame(0, $stat['mtime']);
$this->assertSame(0, $stat[10]);
$this->assertSame(0, $stat['ctime']);
$this->assertSame(1024, $stat[11]);
$this->assertSame(1024, $stat['blksize']);
......@@ -171,6 +170,23 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
$this->assertSame(6, $stat['size']);
}
public function testWritableStreamStatAfterSaving()
{
$stream = $this->bucket->openDownloadStream('length-10');
$stat = fstat($stream);
$this->assertSame(0100444, $stat[2]);
$this->assertSame(0100444, $stat['mode']);
$this->assertSame(10, $stat[7]);
$this->assertSame(10, $stat['size']);
$this->assertSame(1484202200, $stat[9]);
$this->assertSame(1484202200, $stat['mtime']);
$this->assertSame(1484202200, $stat[10]);
$this->assertSame(1484202200, $stat['ctime']);
$this->assertSame(4, $stat[11]);
$this->assertSame(4, $stat['blksize']);
}
public function testWritableStreamWrite()
{
$stream = $this->bucket->openUploadStream('filename');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment