Skip to content

Commit 6040f68

Browse files
author
Patrick Rose
committed
Check container name if numeric
1 parent de8edb7 commit 6040f68

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/OpenCloud/ObjectStore/Service.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function listContainers(array $filter = array())
9292
*/
9393
public function getContainer($data = null)
9494
{
95-
if (is_string($data)) {
95+
if (is_string($data) || is_numeric($data)) {
9696
$this->checkContainerName($data);
9797
}
9898

tests/OpenCloud/Tests/ObjectStore/ServiceTest.php

+20-1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,24 @@ public function test_Get_Bad_Container_Name_Long()
123123
$this->service->getContainer(str_repeat('a', Service::MAX_CONTAINER_NAME_LENGTH + 1));
124124
}
125125

126+
/**
127+
* @expectedException OpenCloud\Common\Exceptions\InvalidArgumentError
128+
*/
129+
public function test_Get_Bad_Container_Name_Float()
130+
{
131+
$this->service->getContainer(4.5);
132+
}
133+
134+
public function test_Get_Container_String()
135+
{
136+
$this->assertInstanceOf('OpenCloud\ObjectStore\Resource\Container', $this->service->getContainer('foo'));
137+
}
138+
139+
public function test_Get_Container_Integer()
140+
{
141+
$this->assertInstanceOf('OpenCloud\ObjectStore\Resource\Container', $this->service->getContainer(1));
142+
}
143+
126144
public function test_Bulk_Extract()
127145
{
128146
$response = $this->service->bulkExtract('fooBarContainer', 'CONTENT', UrlType::TAR);
@@ -166,7 +184,8 @@ public function test_Batch_Delete_Returns_Array_Of_Responses()
166184
{
167185
$responses = array_fill(0, 2, new Response(200));
168186

169-
foreach ($responses as $response) {
187+
foreach ($responses as $response)
188+
{
170189
$this->addMockSubscriber($response);
171190
}
172191

0 commit comments

Comments
 (0)