Skip to content

Commit 862c51d

Browse files
committed
Added integration test for download object using stream
1 parent b6c670a commit 862c51d

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
require 'vendor/autoload.php';
4+
5+
$openstack = new OpenStack\OpenStack([
6+
'authUrl' => '{authUrl}',
7+
'region' => '{region}',
8+
'user' => [
9+
'id' => '{userId}',
10+
'password' => '{password}'
11+
],
12+
'scope' => ['project' => ['id' => '{projectId}']]
13+
]);
14+
15+
/** @var \GuzzleHttp\Stream\Stream $stream */
16+
$stream = $openstack->objectStoreV1()
17+
->getContainer('{containerName}')
18+
->getObject('{objectName}')
19+
->download(['requestOptions' => ['stream' => true]]);

tests/integration/ObjectStore/v1/CoreTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,17 @@ public function objects()
153153
$this->assertInstanceOf(StreamInterface::class, $stream);
154154
$this->assertEquals(1000, $stream->getSize());
155155

156+
$this->logStep('Downloading object using streaming');
157+
/** @var StreamInterface $stream */
158+
require_once $this->sampleFile($replacements, 'objects/download_stream.php');
159+
$this->assertInstanceOf(StreamInterface::class, $stream);
160+
161+
$body = '';
162+
while (!$stream->eof()) {
163+
$body .= $stream->read(64);
164+
}
165+
$this->assertEquals(1000, strlen($body));
166+
156167
$this->logStep('Get object');
157168
require_once $this->sampleFile($replacements, 'objects/get.php');
158169

0 commit comments

Comments
 (0)