Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cast array keys to lowercase in MultipartUploader constructor
  • Loading branch information
jeskew committed Aug 7, 2015
1 parent b250573 commit 4b596ca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/S3/MultipartUploader.php
Expand Up @@ -95,7 +95,7 @@ public static function getStateFromService(
*/
public function __construct(S3Client $client, $source, array $config = [])
{
parent::__construct($client, $source, $config + [
parent::__construct($client, $source, array_change_key_case($config) + [
'bucket' => null,
'key' => null,
]);
Expand Down
18 changes: 18 additions & 0 deletions tests/S3/MultipartUploaderTest.php
Expand Up @@ -109,4 +109,22 @@ public function testCanLoadStateFromService()
$this->assertEquals(4 * self::MB, $uploader->getState()->getPartSize());
$this->assertEquals($url, $result['ObjectURL']);
}

public function testCanUseCaseInsensitiveConfigKeys()
{
$client = $this->getTestClient('s3');
$putObjectMup = new MultipartUploader($client, Psr7\stream_for('x'), [
'Bucket' => 'bucket',
'Key' => 'key',
]);
$classicMup = new MultipartUploader($client, Psr7\stream_for('x'), [
'bucket' => 'bucket',
'key' => 'key',
]);
$configProp = (new \ReflectionClass(MultipartUploader::class))
->getProperty('config');
$configProp->setAccessible(true);

$this->assertSame($configProp->getValue($classicMup), $configProp->getValue($putObjectMup));
}
}

0 comments on commit 4b596ca

Please sign in to comment.